Assorted minor improvements after code review
This commit is contained in:
@@ -28,6 +28,7 @@ class BaseLLMAdapter(ABC, Generic[TLLMInvocationParams]):
|
|||||||
Provides a standard interface for converting to provider-specific formats.
|
Provides a standard interface for converting to provider-specific formats.
|
||||||
|
|
||||||
Handles:
|
Handles:
|
||||||
|
|
||||||
- Extracting provider-specific parameters for LLM invocation from a
|
- Extracting provider-specific parameters for LLM invocation from a
|
||||||
universal LLM context
|
universal LLM context
|
||||||
- Converting standardized tools schema to provider-specific tool formats.
|
- Converting standardized tools schema to provider-specific tool formats.
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
import base64
|
import base64
|
||||||
import json
|
import json
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Any, List, Optional, TypedDict
|
from typing import Any, Dict, List, Optional, TypedDict
|
||||||
|
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
from openai import NotGiven
|
from openai import NotGiven
|
||||||
@@ -71,7 +71,7 @@ class GeminiLLMAdapter(BaseLLMAdapter[GeminiLLMInvocationParams]):
|
|||||||
"tools": self.from_standard_tools(context.tools),
|
"tools": self.from_standard_tools(context.tools),
|
||||||
}
|
}
|
||||||
|
|
||||||
def to_provider_tools_format(self, tools_schema: ToolsSchema) -> List[Any]:
|
def to_provider_tools_format(self, tools_schema: ToolsSchema) -> List[Dict[str, Any]]:
|
||||||
"""Convert tool schemas to Gemini's function-calling format.
|
"""Convert tool schemas to Gemini's function-calling format.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -139,11 +139,13 @@ class GeminiLLMAdapter(BaseLLMAdapter[GeminiLLMInvocationParams]):
|
|||||||
System messages are added back to the context as user messages when needed.
|
System messages are added back to the context as user messages when needed.
|
||||||
|
|
||||||
The final message order is preserved as:
|
The final message order is preserved as:
|
||||||
|
|
||||||
1. Function calls (from model)
|
1. Function calls (from model)
|
||||||
2. Function responses (from user)
|
2. Function responses (from user)
|
||||||
3. Text messages (converted from system messages)
|
3. Text messages (converted from system messages)
|
||||||
|
|
||||||
Note:
|
Note::
|
||||||
|
|
||||||
System messages are only added back when there are no regular text
|
System messages are only added back when there are no regular text
|
||||||
messages in the context, ensuring proper conversation continuity
|
messages in the context, ensuring proper conversation continuity
|
||||||
after function calls.
|
after function calls.
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ class OpenAILLMAdapter(BaseLLMAdapter[OpenAILLMInvocationParams]):
|
|||||||
"""OpenAI-specific adapter for Pipecat.
|
"""OpenAI-specific adapter for Pipecat.
|
||||||
|
|
||||||
Handles:
|
Handles:
|
||||||
|
|
||||||
- Extracting parameters for OpenAI's ChatCompletion API from a universal
|
- Extracting parameters for OpenAI's ChatCompletion API from a universal
|
||||||
LLM context
|
LLM context
|
||||||
- Converting Pipecat's standardized tools schema to OpenAI's function-calling format.
|
- Converting Pipecat's standardized tools schema to OpenAI's function-calling format.
|
||||||
|
|||||||
Reference in New Issue
Block a user