Handle audio transcript from gpt-4o-audio and clean up logs
This commit is contained in:
@@ -166,7 +166,7 @@ class AnthropicLLMService(LLMService):
|
|||||||
await self.start_processing_metrics()
|
await self.start_processing_metrics()
|
||||||
|
|
||||||
logger.debug(
|
logger.debug(
|
||||||
f"{self}: Generating chat [{context.system}] | [{context.get_messages_for_logging()}]"
|
f"{self}: Generating chat [{context.system}] | {context.get_messages_for_logging()}"
|
||||||
)
|
)
|
||||||
|
|
||||||
messages = context.messages
|
messages = context.messages
|
||||||
|
|||||||
@@ -508,7 +508,7 @@ class GoogleLLMService(LLMService):
|
|||||||
try:
|
try:
|
||||||
logger.debug(
|
logger.debug(
|
||||||
# f"{self}: Generating chat [{self._system_instruction}] | [{context.get_messages_for_logging()}]"
|
# f"{self}: Generating chat [{self._system_instruction}] | [{context.get_messages_for_logging()}]"
|
||||||
f"{self}: Generating chat [{context.get_messages_for_logging()}]"
|
f"{self}: Generating chat {context.get_messages_for_logging()}"
|
||||||
)
|
)
|
||||||
|
|
||||||
messages = context.messages
|
messages = context.messages
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ class BaseOpenAILLMService(LLMService):
|
|||||||
async def _stream_chat_completions(
|
async def _stream_chat_completions(
|
||||||
self, context: OpenAILLMContext
|
self, context: OpenAILLMContext
|
||||||
) -> AsyncStream[ChatCompletionChunk]:
|
) -> AsyncStream[ChatCompletionChunk]:
|
||||||
logger.debug(f"{self}: Generating chat [{context.get_messages_for_logging()}]")
|
logger.debug(f"{self}: Generating chat {context.get_messages_for_logging()}")
|
||||||
|
|
||||||
messages: List[ChatCompletionMessageParam] = context.get_messages()
|
messages: List[ChatCompletionMessageParam] = context.get_messages()
|
||||||
|
|
||||||
@@ -240,6 +240,13 @@ class BaseOpenAILLMService(LLMService):
|
|||||||
elif chunk.choices[0].delta.content:
|
elif chunk.choices[0].delta.content:
|
||||||
await self.push_frame(LLMTextFrame(chunk.choices[0].delta.content))
|
await self.push_frame(LLMTextFrame(chunk.choices[0].delta.content))
|
||||||
|
|
||||||
|
# When gpt-4o-audio / gpt-4o-mini-audio is used for llm or stt+llm
|
||||||
|
# we need to get LLMTextFrame for the transcript
|
||||||
|
elif hasattr(chunk.choices[0].delta, "audio") and chunk.choices[0].delta.audio.get(
|
||||||
|
"transcript"
|
||||||
|
):
|
||||||
|
await self.push_frame(LLMTextFrame(chunk.choices[0].delta.audio["transcript"]))
|
||||||
|
|
||||||
# if we got a function name and arguments, check to see if it's a function with
|
# if we got a function name and arguments, check to see if it's a function with
|
||||||
# a registered handler. If so, run the registered callback, save the result to
|
# a registered handler. If so, run the registered callback, save the result to
|
||||||
# the context, and re-prompt to get a chat answer. If we don't have a registered
|
# the context, and re-prompt to get a chat answer. If we don't have a registered
|
||||||
|
|||||||
Reference in New Issue
Block a user