Updates
This commit is contained in:
+3
-4
@@ -9,16 +9,15 @@ def _llm() -> llm.LLM:
|
|||||||
return openai.LLM(model="gpt-4o-mini", temperature=0.45)
|
return openai.LLM(model="gpt-4o-mini", temperature=0.45)
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_greeting() -> None:
|
async def test_offers_assistance() -> None:
|
||||||
|
|
||||||
async with (
|
async with (
|
||||||
_llm() as llm,
|
_llm() as llm,
|
||||||
AgentSession(llm=llm) as session,
|
AgentSession(llm=llm) as session,
|
||||||
):
|
):
|
||||||
await session.start(Assistant())
|
await session.start(Assistant())
|
||||||
result = await session.run(user_input="Hi there how are you?")
|
result = await session.run(user_input="Hello")
|
||||||
await result.expect.message(role="assistant").judge(
|
await result.expect.message(role="assistant").judge(
|
||||||
llm, intent="should offer a friendly greeting to the user"
|
llm, intent="Offers a friendly introduction and offer of assistance."
|
||||||
)
|
)
|
||||||
result.expect.no_more_events()
|
result.expect.no_more_events()
|
||||||
|
|
||||||
+5
-9
@@ -28,16 +28,12 @@ load_dotenv()
|
|||||||
class Assistant(Agent):
|
class Assistant(Agent):
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
super().__init__(
|
super().__init__(
|
||||||
instructions="Your name is Kelly. You would interact with users via voice."
|
instructions="""You are a helpful voice AI assistant named Kit.
|
||||||
"with that in mind keep your responses concise and to the point."
|
You eagerly assist users with their questions by providing information from your extensive knowledge.
|
||||||
"You are curious and friendly, and have a sense of humor.",
|
Your responses are concise, to the point, and without any complex formatting or punctuation.
|
||||||
|
You are curious, friendly, and have a sense of humor.""",
|
||||||
)
|
)
|
||||||
|
|
||||||
async def on_enter(self):
|
|
||||||
# when the agent is added to the session, it'll generate a reply
|
|
||||||
# according to its instructions
|
|
||||||
self.session.generate_reply()
|
|
||||||
|
|
||||||
# all functions annotated with @function_tool will be passed to the LLM when this
|
# all functions annotated with @function_tool will be passed to the LLM when this
|
||||||
# agent is active
|
# agent is active
|
||||||
@function_tool
|
@function_tool
|
||||||
@@ -96,7 +92,7 @@ async def entrypoint(ctx: JobContext):
|
|||||||
ctx.add_shutdown_callback(log_usage)
|
ctx.add_shutdown_callback(log_usage)
|
||||||
|
|
||||||
await session.start(
|
await session.start(
|
||||||
agent=MyAgent(),
|
agent=Assistant(),
|
||||||
room=ctx.room,
|
room=ctx.room,
|
||||||
room_input_options=RoomInputOptions(
|
room_input_options=RoomInputOptions(
|
||||||
# LiveKit Cloud enhanced noise cancellation
|
# LiveKit Cloud enhanced noise cancellation
|
||||||
|
|||||||
Reference in New Issue
Block a user