SantoshKumar1310 commited on
Commit
5567bb1
·
verified ·
1 Parent(s): f4522ca

Update model.py

Browse files
Files changed (1) hide show
  1. model.py +11 -7
model.py CHANGED
@@ -16,9 +16,11 @@ class LiteLLMModel:
16
  def __init__(self, model_id: str):
17
  self.model_id = model_id
18
 
19
- if "gemini" in model_id.lower():
20
- if not os.getenv("GEMINI_API_KEY"):
21
- print("⚠️ GEMINI_API_KEY not set in environment")
 
 
22
 
23
  def generate(self, messages: List[Dict], tools: Optional[List] = None) -> Dict:
24
  if not litellm:
@@ -39,12 +41,13 @@ class LiteLLMModel:
39
  for tool in tools
40
  ]
41
 
42
- if "gemini" in self.model_id.lower():
43
- api_key = os.getenv("GEMINI_API_KEY")
 
44
  if not api_key:
45
- raise RuntimeError("GEMINI_API_KEY not set in environment")
46
 
47
- print(f"DEBUG: Using model id: {self.model_id}")
48
 
49
  response = litellm.completion(
50
  model=self.model_id,
@@ -54,6 +57,7 @@ class LiteLLMModel:
54
  temperature=0.1
55
  )
56
  else:
 
57
  response = litellm.completion(
58
  model=self.model_id,
59
  messages=messages,
 
16
  def __init__(self, model_id: str):
17
  self.model_id = model_id
18
 
19
+ # Check for Groq API key
20
+ if "groq" in model_id.lower():
21
+ if not os.getenv("GROQ_API_KEY"):
22
+ print("⚠️ GROQ_API_KEY not set in environment")
23
+ raise RuntimeError("GROQ_API_KEY not set. Please add it to your Space secrets.")
24
 
25
  def generate(self, messages: List[Dict], tools: Optional[List] = None) -> Dict:
26
  if not litellm:
 
41
  for tool in tools
42
  ]
43
 
44
+ # Groq configuration
45
+ if "groq" in self.model_id.lower():
46
+ api_key = os.getenv("GROQ_API_KEY")
47
  if not api_key:
48
+ raise RuntimeError("GROQ_API_KEY not set in environment")
49
 
50
+ print(f"DEBUG: Using Groq model: {self.model_id}")
51
 
52
  response = litellm.completion(
53
  model=self.model_id,
 
57
  temperature=0.1
58
  )
59
  else:
60
+ # Generic model support
61
  response = litellm.completion(
62
  model=self.model_id,
63
  messages=messages,