Skip to content

Commit

Permalink
Merge pull request #138 from cvaske/no-tool-calling
Browse files Browse the repository at this point in the history
Pass no tool argument when none provided
  • Loading branch information
rgbkrk committed Feb 28, 2024
2 parents 1cce85a + d6d6f51 commit 8592749
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions chatlab/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ async def submit(self, *messages: Union[ChatCompletionMessageParam, str], stream
stream: Whether to stream chat into markdown or not. If False, the entire chat will be sent once.
"""

full_messages: List[ChatCompletionMessageParam] = []
full_messages.extend(self.messages)

Expand All @@ -285,14 +286,14 @@ async def submit(self, *messages: Union[ChatCompletionMessageParam, str], stream
"temperature": kwargs.get("temperature", 0),
}

if self.legacy_function_calling:
chat_create_kwargs.update(self.function_registry.api_manifest())
else:
chat_create_kwargs["tools"] = self.function_registry.tools or None

# Due to the strict response typing based on `Literal` typing on `stream`, we have to process these
# two cases separately
if stream:
if self.legacy_function_calling:
chat_create_kwargs.update(self.function_registry.api_manifest())
else:
chat_create_kwargs["tools"] = self.function_registry.tools

streaming_response = await client.chat.completions.create(
**chat_create_kwargs,
stream=True,
Expand Down

0 comments on commit 8592749

Please sign in to comment.