Update InputAudioTranscription to use gpt-4o-transcribe model, update 19 examples to use FunctionSchema

This commit is contained in:
Mark Backman
2025-03-20 15:12:43 -04:00
parent 8f6d92ce7d
commit 541a4b6063
4 changed files with 61 additions and 46 deletions

View File

@@ -11,6 +11,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added `default_headers` parameter to `BaseOpenAILLMService` constructor. - Added `default_headers` parameter to `BaseOpenAILLMService` constructor.
### Changed
- Changed the default `InputAudioTranscription` model to `gpt-4o-transcribe`
for `OpenAIRealtimeBetaLLMService`.
### Other
- Update the `19-openai-realtime-beta.py` and `19a-azure-realtime-beta.py`
examples to use the FunctionSchema format.
## [0.0.59] - 2025-03-20 ## [0.0.59] - 2025-03-20
### Added ### Added

View File

@@ -14,6 +14,8 @@ from dotenv import load_dotenv
from loguru import logger from loguru import logger
from runner import configure from runner import configure
from pipecat.adapters.schemas.function_schema import FunctionSchema
from pipecat.adapters.schemas.tools_schema import ToolsSchema
from pipecat.audio.vad.silero import SileroVADAnalyzer from pipecat.audio.vad.silero import SileroVADAnalyzer
from pipecat.audio.vad.vad_analyzer import VADParams from pipecat.audio.vad.vad_analyzer import VADParams
from pipecat.pipeline.pipeline import Pipeline from pipecat.pipeline.pipeline import Pipeline
@@ -46,28 +48,25 @@ async def fetch_weather_from_api(function_name, tool_call_id, args, llm, context
) )
tools = [ weather_function = FunctionSchema(
{ name="get_current_weather",
"type": "function", description="Get the current weather",
"name": "get_current_weather", properties={
"description": "Get the current weather", "location": {
"parameters": { "type": "string",
"type": "object", "description": "The city and state, e.g. San Francisco, CA",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA",
},
"format": {
"type": "string",
"enum": ["celsius", "fahrenheit"],
"description": "The temperature unit to use. Infer this from the users location.",
},
},
"required": ["location", "format"],
}, },
} "format": {
] "type": "string",
"enum": ["celsius", "fahrenheit"],
"description": "The temperature unit to use. Infer this from the users location.",
},
},
required=["location", "format"],
)
# Create tools schema
tools = ToolsSchema(standard_tools=[weather_function])
async def main(): async def main():

View File

@@ -10,11 +10,12 @@ import sys
from datetime import datetime from datetime import datetime
import aiohttp import aiohttp
import websockets
from dotenv import load_dotenv from dotenv import load_dotenv
from loguru import logger from loguru import logger
from runner import configure from runner import configure
from pipecat.adapters.schemas.function_schema import FunctionSchema
from pipecat.adapters.schemas.tools_schema import ToolsSchema
from pipecat.audio.vad.silero import SileroVADAnalyzer from pipecat.audio.vad.silero import SileroVADAnalyzer
from pipecat.audio.vad.vad_analyzer import VADParams from pipecat.audio.vad.vad_analyzer import VADParams
from pipecat.pipeline.pipeline import Pipeline from pipecat.pipeline.pipeline import Pipeline
@@ -47,28 +48,26 @@ async def fetch_weather_from_api(function_name, tool_call_id, args, llm, context
) )
tools = [ # Define weather function using standardized schema
{ weather_function = FunctionSchema(
"type": "function", name="get_current_weather",
"name": "get_current_weather", description="Get the current weather",
"description": "Get the current weather", properties={
"parameters": { "location": {
"type": "object", "type": "string",
"properties": { "description": "The city and state, e.g. San Francisco, CA",
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA",
},
"format": {
"type": "string",
"enum": ["celsius", "fahrenheit"],
"description": "The temperature unit to use. Infer this from the users location.",
},
},
"required": ["location", "format"],
}, },
} "format": {
] "type": "string",
"enum": ["celsius", "fahrenheit"],
"description": "The temperature unit to use. Infer this from the users location.",
},
},
required=["location", "format"],
)
# Create tools schema
tools = ToolsSchema(standard_tools=[weather_function])
async def main(): async def main():

View File

@@ -14,17 +14,24 @@ from pydantic import BaseModel, Field
# #
# session properties # session properties
# #
InputAudioTranscriptionModel = Literal["whisper-1", "gpt-4o-transcribe"]
class InputAudioTranscription(BaseModel): class InputAudioTranscription(BaseModel):
model: InputAudioTranscriptionModel """Configuration for audio transcription settings.
Attributes:
model: Transcription model to use (e.g., "gpt-4o-transcribe", "whisper-1").
language: Optional language code for transcription.
prompt: Optional transcription hint text.
"""
model: str = "gpt-4o-transcribe"
language: Optional[str] language: Optional[str]
prompt: Optional[str] prompt: Optional[str]
def __init__( def __init__(
self, self,
model: Optional[InputAudioTranscriptionModel] = "whisper-1", model: Optional[str] = "gpt-4o-transcribe",
language: Optional[str] = None, language: Optional[str] = None,
prompt: Optional[str] = None, prompt: Optional[str] = None,
): ):