Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass no tool argument when none provided #138

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading