introduce Ruff formatting
This commit is contained in:
@@ -4,7 +4,7 @@ import asyncio
|
||||
import os
|
||||
from pipecat.processors.aggregators.openai_llm_context import (
|
||||
OpenAILLMContext,
|
||||
OpenAILLMContextFrame
|
||||
OpenAILLMContextFrame,
|
||||
)
|
||||
from pipecat.services.azure import AzureLLMService
|
||||
|
||||
@@ -13,6 +13,7 @@ from openai.types.chat import (
|
||||
)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@unittest.skip("Skip azure integration test")
|
||||
async def test_chat():
|
||||
llm = AzureLLMService(
|
||||
@@ -22,7 +23,8 @@ if __name__ == "__main__":
|
||||
)
|
||||
context = OpenAILLMContext()
|
||||
message: ChatCompletionSystemMessageParam = ChatCompletionSystemMessageParam(
|
||||
content="Please tell the world hello.", name="system", role="system")
|
||||
content="Please tell the world hello.", name="system", role="system"
|
||||
)
|
||||
context.add_message(message)
|
||||
frame = OpenAILLMContextFrame(context)
|
||||
async for s in llm.process_frame(frame):
|
||||
|
||||
@@ -3,7 +3,7 @@ import unittest
|
||||
import asyncio
|
||||
from pipecat.processors.aggregators.openai_llm_context import (
|
||||
OpenAILLMContext,
|
||||
OpenAILLMContextFrame
|
||||
OpenAILLMContextFrame,
|
||||
)
|
||||
|
||||
from openai.types.chat import (
|
||||
@@ -12,12 +12,14 @@ from openai.types.chat import (
|
||||
from pipecat.services.ollama import OLLamaLLMService
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@unittest.skip("Skip azure integration test")
|
||||
async def test_chat():
|
||||
llm = OLLamaLLMService()
|
||||
context = OpenAILLMContext()
|
||||
message: ChatCompletionSystemMessageParam = ChatCompletionSystemMessageParam(
|
||||
content="Please tell the world hello.", name="system", role="system")
|
||||
content="Please tell the world hello.", name="system", role="system"
|
||||
)
|
||||
context.add_message(message)
|
||||
frame = OpenAILLMContextFrame(context)
|
||||
async for s in llm.process_frame(frame):
|
||||
|
||||
@@ -5,11 +5,7 @@ from typing import List
|
||||
|
||||
from pipecat.services.openai import OpenAILLMContextFrame, OpenAILLMContext
|
||||
from pipecat.processors.frame_processor import FrameDirection, FrameProcessor
|
||||
from pipecat.frames.frames import (
|
||||
LLMFullResponseStartFrame,
|
||||
LLMFullResponseEndFrame,
|
||||
TextFrame
|
||||
)
|
||||
from pipecat.frames.frames import LLMFullResponseStartFrame, LLMFullResponseEndFrame, TextFrame
|
||||
from pipecat.utils.test_frame_processor import TestFrameProcessor
|
||||
from openai.types.chat import (
|
||||
ChatCompletionSystemMessageParam,
|
||||
@@ -34,21 +30,19 @@ tools = [
|
||||
},
|
||||
"format": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"celsius",
|
||||
"fahrenheit"],
|
||||
"enum": ["celsius", "fahrenheit"],
|
||||
"description": "The temperature unit to use. Infer this from the users location.",
|
||||
},
|
||||
},
|
||||
"required": [
|
||||
"location",
|
||||
"format"],
|
||||
"required": ["location", "format"],
|
||||
},
|
||||
})]
|
||||
},
|
||||
)
|
||||
]
|
||||
|
||||
if __name__ == "__main__":
|
||||
async def test_simple_functions():
|
||||
|
||||
async def test_simple_functions():
|
||||
async def get_weather_from_api(llm, args):
|
||||
return json.dumps({"conditions": "nice", "temperature": "75"})
|
||||
|
||||
@@ -60,11 +54,7 @@ if __name__ == "__main__":
|
||||
)
|
||||
|
||||
llm.register_function("get_current_weather", get_weather_from_api)
|
||||
t = TestFrameProcessor([
|
||||
LLMFullResponseStartFrame,
|
||||
TextFrame,
|
||||
LLMFullResponseEndFrame
|
||||
])
|
||||
t = TestFrameProcessor([LLMFullResponseStartFrame, TextFrame, LLMFullResponseEndFrame])
|
||||
llm.link(t)
|
||||
|
||||
context = OpenAILLMContext(tools=tools)
|
||||
@@ -82,9 +72,13 @@ if __name__ == "__main__":
|
||||
await llm.process_frame(frame, FrameDirection.DOWNSTREAM)
|
||||
|
||||
async def test_advanced_functions():
|
||||
|
||||
async def get_weather_from_api(llm, args):
|
||||
return [{"role": "system", "content": "The user has asked for live weather. Respond by telling them we don't currently support live weather for that area, but it's coming soon."}]
|
||||
return [
|
||||
{
|
||||
"role": "system",
|
||||
"content": "The user has asked for live weather. Respond by telling them we don't currently support live weather for that area, but it's coming soon.",
|
||||
}
|
||||
]
|
||||
|
||||
api_key = os.getenv("OPENAI_API_KEY")
|
||||
|
||||
@@ -94,11 +88,7 @@ if __name__ == "__main__":
|
||||
)
|
||||
|
||||
llm.register_function("get_current_weather", get_weather_from_api)
|
||||
t = TestFrameProcessor([
|
||||
LLMFullResponseStartFrame,
|
||||
TextFrame,
|
||||
LLMFullResponseEndFrame
|
||||
])
|
||||
t = TestFrameProcessor([LLMFullResponseStartFrame, TextFrame, LLMFullResponseEndFrame])
|
||||
llm.link(t)
|
||||
|
||||
context = OpenAILLMContext(tools=tools)
|
||||
@@ -117,11 +107,7 @@ if __name__ == "__main__":
|
||||
|
||||
async def test_chat():
|
||||
api_key = os.getenv("OPENAI_API_KEY")
|
||||
t = TestFrameProcessor([
|
||||
LLMFullResponseStartFrame,
|
||||
TextFrame,
|
||||
LLMFullResponseEndFrame
|
||||
])
|
||||
t = TestFrameProcessor([LLMFullResponseStartFrame, TextFrame, LLMFullResponseEndFrame])
|
||||
llm = OpenAILLMService(
|
||||
api_key=api_key or "",
|
||||
model="gpt-4o",
|
||||
@@ -129,7 +115,8 @@ if __name__ == "__main__":
|
||||
llm.link(t)
|
||||
context = OpenAILLMContext()
|
||||
message: ChatCompletionSystemMessageParam = ChatCompletionSystemMessageParam(
|
||||
content="Please tell the world hello.", name="system", role="system")
|
||||
content="Please tell the world hello.", name="system", role="system"
|
||||
)
|
||||
context.add_message(message)
|
||||
frame = OpenAILLMContextFrame(context)
|
||||
await llm.process_frame(frame, FrameDirection.DOWNSTREAM)
|
||||
|
||||
Reference in New Issue
Block a user