@@ -175,7 +175,7 @@ async def _generate_response(
175
175
# Get a response from the model.
176
176
hisorical_messages = await self ._memory .get_messages ()
177
177
response = await self ._client .create (
178
- self ._system_messages + convert_messages_to_llm_messages (hisorical_messages , self .metadata ["name " ]),
178
+ self ._system_messages + convert_messages_to_llm_messages (hisorical_messages , self .metadata ["type " ]),
179
179
tools = self ._tools ,
180
180
json_output = response_format == ResponseFormat .json_object ,
181
181
)
@@ -190,25 +190,25 @@ async def _generate_response(
190
190
):
191
191
# Send a function call message to itself.
192
192
response = await self .send_message (
193
- message = FunctionCallMessage (content = response .content , source = self .metadata ["name " ]),
193
+ message = FunctionCallMessage (content = response .content , source = self .metadata ["type " ]),
194
194
recipient = self .id ,
195
195
cancellation_token = cancellation_token ,
196
196
)
197
197
# Make an assistant message from the response.
198
198
hisorical_messages = await self ._memory .get_messages ()
199
199
response = await self ._client .create (
200
- self ._system_messages + convert_messages_to_llm_messages (hisorical_messages , self .metadata ["name " ]),
200
+ self ._system_messages + convert_messages_to_llm_messages (hisorical_messages , self .metadata ["type " ]),
201
201
tools = self ._tools ,
202
202
json_output = response_format == ResponseFormat .json_object ,
203
203
)
204
204
205
205
final_response : Message
206
206
if isinstance (response .content , str ):
207
207
# If the response is a string, return a text message.
208
- final_response = TextMessage (content = response .content , source = self .metadata ["name " ])
208
+ final_response = TextMessage (content = response .content , source = self .metadata ["type " ])
209
209
elif isinstance (response .content , list ) and all (isinstance (x , FunctionCall ) for x in response .content ):
210
210
# If the response is a list of function calls, return a function call message.
211
- final_response = FunctionCallMessage (content = response .content , source = self .metadata ["name " ])
211
+ final_response = FunctionCallMessage (content = response .content , source = self .metadata ["type " ])
212
212
else :
213
213
raise ValueError (f"Unexpected response: { response .content } " )
214
214
0 commit comments