File size: 438 Bytes
61411b5
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from __future__ import annotations

import os
from functools import lru_cache
from langchain_groq import ChatGroq


@lru_cache(maxsize=1)
def get_groq_llm(model: str = "llama-3.3-70b-versatile", temperature: float = 0.0) -> ChatGroq:
    api_key = os.getenv("GROQ_API_KEY", "")
    if not api_key:
        raise ValueError("Missing GROQ_API_KEY.")
    return ChatGroq(model=model, temperature=temperature, api_key=api_key)