hi, I am using Groq API for LLM inference (as show...
# ask-ai
r
hi, I am using Groq API for LLM inference (as shown below) large_language_model = groq.LLM( model="llama-3.3-70b-versatile", temperature=0.20, tool_choice="auto", top_p=0.85, ) I have a tricky situation where the prompt is probably getting cached at GROQ servers and then I don't correct response or the voice agent automatically calls tools to pre-fill (exapmle customer name) - even before asking the customer. I checked and the LLM api from LiveKit does not support SEED or NO-CACHE options. What is the best practices to avoid such a situation Scenario: I am running the agent multiple times to test it "as-if" I am a user and have conversation. I always restart the agent, so there is no chance of caching anything locally.
t
Thanks for reaching out, Mitesh. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! To help you avoid caching hiccups and unexpected tool calls when working with the LiveKit LLM API—especially during testing—here are some friendly tips you might find useful: • Use Ephemeral Caching: Try setting the
caching
parameter to "ephemeral." This way, your system prompts and chat history are temporarily cached without sticking around between sessions. • Control Tool Calling Behavior: If you want to keep things predictable, use
tool_choice="none"
to stop any tool calls, or specify exactly which tools to use with
tool_choice
. • Manage Chat Context: For clean testing, use separate chat contexts each time so previous chats don’t interfere. • Set Explicit Model Parameters: Setting parameters like
temperature=0.0
helps you get consistent results, and
top_k=1
can reduce randomness. • Disable Browser Caching: When testing in a browser, you might want to disable caching via developer tools or switch up ports between tests to keep things fresh. • Limit Context Window: Sending only a limited chat history to the model can make outputs more predictable. Give these a try—they should make your testing smoother and help keep those caching issues at bay. If you hit any snags, I’m here to help! Sources: livekit-agents/livekit/agents/voice/agent_activity.py | LLM Integrations | livekit/livekit_composite | DeepWiki | tools/server/tests/unit/test_slot_save.py
r
To differentiate prompts for each LLM Call I am already adding NONCE and TIMESTAMP which will have changes in prompts everytime (but not sure if this is the correct way) I have these in my prompt NONCE: {str(uuid.uuid4()} TODAY'S DATE TIME: {datetime.now().strftime("%Y-%m-%d %H:%M:%S")}
t
Hey there! Just a quick heads-up: adding
NONCE
and
TIMESTAMP
directly to prompts isn’t something the LiveKit API officially recommends for distinguishing LLM calls. The framework actually takes care of telemetry and metrics like request IDs and timestamps behind the scenes, so tweaking prompts like this isn’t really needed and might not be the best way to go. Instead, you might want to try using the
caching
parameter set to "ephemeral" or explicitly managing chat contexts to make sure each call is handled separately. If you’d like, I’m here to help walk you through these options or answer any questions you have! Sources: livekit-plugins/livekit-plugins-anthropic/livekit/plugins/anthropic/llm.py | plugins/openai/src/llm.ts | Large language model (LLM) integrations | LiveKit Docs | LLM Integrations | livekit/livekit_composite | DeepWiki
r
help me how to configure caching parameter.
t
Hey there! To set up the caching parameter in the LiveKit LLM API, you just need to specify it when you initialize your LLM instance. Here’s a quick guide to help you out: For Anthropic LLM:
Copy code
from livekit.plugins.anthropic import LLM
anthropic_llm = LLM(
    model="claude-3-5-sonnet-20241022",
    caching="ephemeral"
)
For OpenAI LLM:
Copy code
from livekit.plugins.openai import LLM
openai_llm = LLM(
    model="gpt-4o",
    prompt_cache_key="my_cache_key",
    store=True
)
Using
caching="ephemeral"
means your system prompts, tools, and chat history are cached temporarily, which is super handy for testing and keeping things tidy. If you have any questions or want me to walk you through it, just give me a shout! Sources: livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/llm.py
r
large_language_model = groq.LLM( model="llama-3.3-70b-versatile", temperature=0.20, tool_choice="auto", prompt_cache_key=str(uuid.uuid4()), top_p=0.85, ) Will this work? and have I used the UUID correctly or should I use something static string such as "app-cache-key"
t
Hey there! Just wanted to share a quick tip about the
prompt_cache_key
parameter in the LiveKit LLM API. You can use either a UUID or a static string here, depending on how you want caching to work for you: • Go with a static string: This is great if you want to get consistent cache hits for the same prompt contexts, like reusable system prompts or templates. • Or use a UUID: This helps if you want to skip caching altogether and make sure each request is handled fresh. For example:
prompt_cache_key=str(uuid.uuid4())
. Since how
prompt_cache_key
behaves can vary depending on your LLM provider, it’s a good idea to check how it’s working by looking at usage metrics or the provider’s docs. If you’re ever in doubt, using a UUID is a safe bet to avoid any surprise caching. Sources: Flutter SDK | livekit/livekit_composite | DeepWiki | tools/server/README.md | livekit-plugins/livekit-plugins-aws/livekit/plugins/aws/experimental/realti...
r
I'm using UUID but got livekit.agents._exceptions.APIStatusError: Error code: 400 - {'error': {'message': "property 'prompt_cache_key' is unsupported", 'type': 'invalid_request_error'}}
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!