move the LLM instance directly to Assistant to make it cleaner to share with tests (#71)
* Attach models to agent subclass * Fix up * comment * ruff * 4.1-mini * remove comment
This commit is contained in:
+4
-12
@@ -3,15 +3,10 @@ import textwrap
|
||||
import pytest
|
||||
from livekit.agents import AgentSession, inference, llm
|
||||
|
||||
from agent import AGENT_MODEL, Assistant
|
||||
|
||||
|
||||
def _agent_llm() -> llm.LLM:
|
||||
return inference.LLM(model=AGENT_MODEL)
|
||||
from agent import Assistant
|
||||
|
||||
|
||||
def _judge_llm() -> llm.LLM:
|
||||
# The judge LLM can be a cheaper model since it only evaluates agent responses
|
||||
return inference.LLM(model="openai/gpt-4.1-mini")
|
||||
|
||||
|
||||
@@ -19,9 +14,8 @@ def _judge_llm() -> llm.LLM:
|
||||
async def test_offers_assistance() -> None:
|
||||
"""Evaluation of the agent's friendly nature."""
|
||||
async with (
|
||||
_agent_llm() as agent_llm,
|
||||
_judge_llm() as judge_llm,
|
||||
AgentSession(llm=agent_llm) as session,
|
||||
AgentSession() as session,
|
||||
):
|
||||
await session.start(Assistant())
|
||||
|
||||
@@ -54,9 +48,8 @@ async def test_offers_assistance() -> None:
|
||||
async def test_grounding() -> None:
|
||||
"""Evaluation of the agent's ability to refuse to answer when it doesn't know something."""
|
||||
async with (
|
||||
_agent_llm() as agent_llm,
|
||||
_judge_llm() as judge_llm,
|
||||
AgentSession(llm=agent_llm) as session,
|
||||
AgentSession() as session,
|
||||
):
|
||||
await session.start(Assistant())
|
||||
|
||||
@@ -99,9 +92,8 @@ async def test_grounding() -> None:
|
||||
async def test_refuses_harmful_request() -> None:
|
||||
"""Evaluation of the agent's ability to refuse inappropriate or harmful requests."""
|
||||
async with (
|
||||
_agent_llm() as agent_llm,
|
||||
_judge_llm() as judge_llm,
|
||||
AgentSession(llm=agent_llm) as session,
|
||||
AgentSession() as session,
|
||||
):
|
||||
await session.start(Assistant())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user