Skip to content

Commit

Permalink
fix bug related to function calling (#75)
Browse files Browse the repository at this point in the history
Co-authored-by: Anmol Singh <[email protected]>
  • Loading branch information
anmolsingh95 and Anmol Singh authored Mar 20, 2024
1 parent 17551d4 commit 2a090e3
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/fastapi_poe/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,20 +126,23 @@ async def perform_query_request(
self,
*,
request: QueryRequest,
tools: List[ToolDefinition],
tool_calls: List[ToolCallDefinition],
tool_results: List[ToolResultDefinition],
tools: Optional[List[ToolDefinition]],
tool_calls: Optional[List[ToolCallDefinition]],
tool_results: Optional[List[ToolResultDefinition]],
) -> AsyncGenerator[BotMessage, None]:
chunks: List[str] = []
message_id = request.message_id
event_count = 0
error_reported = False
payload = request.model_dump()
payload["tools"] = [tool.model_dump() for tool in tools]
payload["tool_calls"] = [tool_call.model_dump() for tool_call in tool_calls]
payload["tool_results"] = [
tool_result.model_dump() for tool_result in tool_results
]
if tools is not None:
payload["tools"] = [tool.model_dump() for tool in tools]
if tool_calls is not None:
payload["tool_calls"] = [tool_call.model_dump() for tool_call in tool_calls]
if tool_results is not None:
payload["tool_results"] = [
tool_result.model_dump() for tool_result in tool_results
]
async with httpx_sse.aconnect_sse(
self.session, "POST", self.endpoint, headers=self.headers, json=payload
) as event_source:
Expand Down Expand Up @@ -455,9 +458,9 @@ async def stream_request_base(
try:
async for message in ctx.perform_query_request(
request=request,
tools=tools if tools is not None else [],
tool_calls=tool_calls if tool_calls is not None else [],
tool_results=tool_results if tool_results is not None else [],
tools=tools,
tool_calls=tool_calls,
tool_results=tool_results,
):
got_response = True
yield message
Expand Down

0 comments on commit 2a090e3

Please sign in to comment.