services(openai, anthropic): a None result should not run inference
This commit is contained in:
@@ -490,32 +490,33 @@ class AnthropicAssistantContextAggregator(LLMAssistantContextAggregator):
|
|||||||
if self._function_call_result:
|
if self._function_call_result:
|
||||||
frame = self._function_call_result
|
frame = self._function_call_result
|
||||||
self._function_call_result = None
|
self._function_call_result = None
|
||||||
self._context.add_message({
|
if frame.result:
|
||||||
"role": "assistant",
|
self._context.add_message({
|
||||||
"content": [
|
"role": "assistant",
|
||||||
{
|
"content": [
|
||||||
"type": "text",
|
{
|
||||||
"text": aggregation
|
"type": "text",
|
||||||
},
|
"text": aggregation
|
||||||
{
|
},
|
||||||
"type": "tool_use",
|
{
|
||||||
"id": frame.tool_call_id,
|
"type": "tool_use",
|
||||||
"name": frame.function_name,
|
"id": frame.tool_call_id,
|
||||||
"input": frame.arguments
|
"name": frame.function_name,
|
||||||
}
|
"input": frame.arguments
|
||||||
]
|
}
|
||||||
})
|
]
|
||||||
self._context.add_message({
|
})
|
||||||
"role": "user",
|
self._context.add_message({
|
||||||
"content": [
|
"role": "user",
|
||||||
|
"content": [
|
||||||
{
|
{
|
||||||
"type": "tool_result",
|
"type": "tool_result",
|
||||||
"tool_use_id": frame.tool_call_id,
|
"tool_use_id": frame.tool_call_id,
|
||||||
"content": json.dumps(frame.result)
|
"content": json.dumps(frame.result)
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
run_llm = True
|
run_llm = True
|
||||||
else:
|
else:
|
||||||
self._context.add_message({"role": "assistant", "content": aggregation})
|
self._context.add_message({"role": "assistant", "content": aggregation})
|
||||||
|
|
||||||
|
|||||||
@@ -399,26 +399,27 @@ class OpenAIAssistantContextAggregator(LLMAssistantContextAggregator):
|
|||||||
try:
|
try:
|
||||||
if self._function_call_result:
|
if self._function_call_result:
|
||||||
frame = self._function_call_result
|
frame = self._function_call_result
|
||||||
self._context.add_message({
|
|
||||||
"role": "assistant",
|
|
||||||
"tool_calls": [
|
|
||||||
{
|
|
||||||
"id": frame.tool_call_id,
|
|
||||||
"function": {
|
|
||||||
"name": frame.function_name,
|
|
||||||
"arguments": json.dumps(frame.arguments)
|
|
||||||
},
|
|
||||||
"type": "function"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
})
|
|
||||||
self._context.add_message({
|
|
||||||
"role": "tool",
|
|
||||||
"content": json.dumps(frame.result),
|
|
||||||
"tool_call_id": frame.tool_call_id
|
|
||||||
})
|
|
||||||
self._function_call_result = None
|
self._function_call_result = None
|
||||||
run_llm = True
|
if frame.result:
|
||||||
|
self._context.add_message({
|
||||||
|
"role": "assistant",
|
||||||
|
"tool_calls": [
|
||||||
|
{
|
||||||
|
"id": frame.tool_call_id,
|
||||||
|
"function": {
|
||||||
|
"name": frame.function_name,
|
||||||
|
"arguments": json.dumps(frame.arguments)
|
||||||
|
},
|
||||||
|
"type": "function"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
self._context.add_message({
|
||||||
|
"role": "tool",
|
||||||
|
"content": json.dumps(frame.result),
|
||||||
|
"tool_call_id": frame.tool_call_id
|
||||||
|
})
|
||||||
|
run_llm = True
|
||||||
else:
|
else:
|
||||||
self._context.add_message({"role": "assistant", "content": aggregation})
|
self._context.add_message({"role": "assistant", "content": aggregation})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user