@@ -82,18 +82,8 @@ async def async_main(args: argparse.Namespace) -> None:
82
82
completer = create_completer (["!help" , "!exit" , "!reset" ])
83
83
initial_prompt = args .prompt
84
84
85
- # Log chat history
86
- def p_hist (* args , ** kwargs ) -> None :
87
- pass
88
-
89
- if args .history_file :
90
- history_file_path = Path (args .history_file )
91
- f = history_file_path .open ("a+" , encoding = "utf-8" )
92
- p_hist = _create_history_logger (f )
93
-
94
85
while True :
95
86
print ("\n You:" )
96
- p_hist ("\n You:" )
97
87
if initial_prompt :
98
88
question = initial_prompt
99
89
print (question )
@@ -105,7 +95,6 @@ def p_hist(*args, **kwargs) -> None:
105
95
else await get_input_async (session = session , completer = completer )
106
96
)
107
97
print ()
108
- p_hist (question + "\n " )
109
98
if question == "!exit" :
110
99
await bot .close ()
111
100
break
@@ -122,62 +111,14 @@ def p_hist(*args, **kwargs) -> None:
122
111
await bot .reset ()
123
112
continue
124
113
print ("Bot:" )
125
- p_hist ("Bot:" )
126
- if args .no_stream :
127
- response = (
128
- await bot .ask (
129
- prompt = question ,
130
- conversation_style = args .style ,
131
- wss_link = args .wss_link ,
132
- search_result = args .search_result ,
133
- locale = args .locale ,
134
- )
135
- )["item" ]["messages" ][- 1 ]["adaptiveCards" ][0 ]["body" ][0 ]["text" ]
136
- print (response )
137
- p_hist (response )
138
- else :
139
- wrote = 0
140
- if args .rich :
141
- md = Markdown ("" )
142
- with Live (md , auto_refresh = False ) as live :
143
- async for final , response in bot .ask_stream (
144
- prompt = question ,
145
- conversation_style = args .style ,
146
- wss_link = args .wss_link ,
147
- search_result = args .search_result ,
148
- locale = args .locale ,
149
- ):
150
- if not final :
151
- if not wrote :
152
- p_hist (response , end = "" )
153
- else :
154
- p_hist (response [wrote :], end = "" )
155
- if wrote > len (response ):
156
- print (md )
157
- print (Markdown ("***Bing revoked the response.***" ))
158
- wrote = len (response )
159
- md = Markdown (response )
160
- live .update (md , refresh = True )
161
- else :
162
- async for final , response in bot .ask_stream (
163
- prompt = question ,
164
- conversation_style = args .style ,
165
- wss_link = args .wss_link ,
166
- search_result = args .search_result ,
167
- locale = args .locale ,
168
- ):
169
- if not final :
170
- if not wrote :
171
- print (response , end = "" , flush = True )
172
- p_hist (response , end = "" )
173
- else :
174
- print (response [wrote :], end = "" , flush = True )
175
- p_hist (response [wrote :], end = "" )
176
- wrote = len (response )
177
- print ()
178
- p_hist ()
179
- if args .history_file :
180
- f .close ()
114
+ response = await bot .ask (
115
+ prompt = question ,
116
+ conversation_style = args .style ,
117
+ wss_link = args .wss_link ,
118
+ locale = args .locale ,
119
+ simplify_response = True
120
+ )
121
+ print (response .get ("text" , "No response" ))
181
122
await bot .close ()
182
123
183
124
@@ -226,13 +167,6 @@ def main() -> None:
226
167
required = False ,
227
168
help = "path to cookie file" ,
228
169
)
229
- parser .add_argument (
230
- "--history-file" ,
231
- type = str ,
232
- default = "" ,
233
- required = False ,
234
- help = "path to history file" ,
235
- )
236
170
parser .add_argument (
237
171
"--locale" ,
238
172
type = str ,
0 commit comments