Merge branch 'main' into santiagxf/azure-ai-inference

This commit is contained in:
Facundo Santiago 2024-11-07 12:43:55 -05:00 committed by GitHub
commit 5c429b0b67
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
273 changed files with 5491 additions and 5418 deletions

View file

@ -49,6 +49,9 @@ def text_from_choice(choice) -> str:
if hasattr(choice, "message"):
return choice.message.content
if hasattr(choice, "message"):
return choice.message.content
return choice.text
@ -102,7 +105,6 @@ def process_chat_completion_response(
async def process_completion_stream_response(
stream: AsyncGenerator[OpenAICompatCompletionResponse, None], formatter: ChatFormat
) -> AsyncGenerator:
stop_reason = None
async for chunk in stream:
@ -162,6 +164,7 @@ async def process_chat_completion_stream_response(
text = text_from_choice(choice)
if not text:
# Sometimes you get empty chunks from providers
continue
# check if its a tool call ( aka starts with <|python_tag|> )