@@ -139,17 +139,14 @@ def ask(
139139
140140 session .headers .update (self .headers )
141141 payload = {
142- "input" : {
143- "messages" : [
144- # self.conversation.chat_history if conversationally else "",
145- {
146- "content" : conversation_prompt ,
147- "additional_kwargs" : {},
148- "type" : "human" ,
149- "example" : False ,
150- },
151- ]
152- },
142+ "input" : [
143+ {
144+ "content" : conversation_prompt ,
145+ "additional_kwargs" : {},
146+ "type" : "human" ,
147+ "example" : False ,
148+ },
149+ ],
153150 "assistant_id" : self .assistant_id ,
154151 "thread_id" : "" ,
155152 }
@@ -174,8 +171,10 @@ def for_stream():
174171 try :
175172 modified_value = re .sub ("data:" , "" , value )
176173 resp = json .loads (modified_value )
177- self .last_response .update (resp )
178- yield value if raw else resp
174+ if len (resp ) == 1 :
175+ continue
176+ self .last_response .update (resp [1 ])
177+ yield value if raw else resp [1 ]
179178 except json .decoder .JSONDecodeError :
180179 pass
181180 self .conversation .update_chat_history (
@@ -234,6 +233,4 @@ def get_message(self, response: dict) -> str:
234233 str: Message extracted
235234 """
236235 assert isinstance (response , dict ), "Response should be of dict data-type only"
237- return (
238- response ["messages" ][1 ]["content" ] if "messages" in response .keys () else ""
239- )
236+ return response ["content" ]
0 commit comments