got a weird audio bug happening

This commit is contained in:
Chad Bailey
2024-02-12 21:15:12 +00:00
parent fd5ff5fee5
commit 33ea1f9925
6 changed files with 138 additions and 36 deletions

View File

@@ -27,11 +27,11 @@ class OpenAILLMService(LLMService):
tools=self._tools
)
async def run_llm_async(self, messages) -> AsyncGenerator[str, None]:
async def run_llm_async(self, messages, tool_choice=None) -> AsyncGenerator[str, None]:
messages_for_log = json.dumps(messages)
self.logger.debug(f"Generating chat via openai: {messages_for_log}")
chunks = await self._client.chat.completions.create(model=self._model, stream=True, messages=messages, tools=self._tools)
chunks = await self._client.chat.completions.create(model=self._model, stream=True, messages=messages, tools=self._tools, tool_choice=tool_choice)
async for chunk in chunks:
if len(chunk.choices) == 0:
continue
@@ -39,6 +39,7 @@ class OpenAILLMService(LLMService):
yield chunk.choices[0].delta.content
elif chunk.choices[0].delta.tool_calls:
yield chunk.choices[0].delta.tool_calls[0]
async def run_llm(self, messages) -> str | None:
messages_for_log = json.dumps(messages)
self.logger.debug(f"Generating chat via openai: {messages_for_log}")