anasfsd123 commited on
Commit
c5a5632
·
verified ·
1 Parent(s): f384976

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -7
app.py CHANGED
@@ -13,7 +13,7 @@ import litellm
13
  # Configuration
14
  NASA_API_URL = "https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY"
15
  HF_MODEL_NAME = "sentence-transformers/all-MiniLM-L6-v2"
16
- LLM_MODEL = "HuggingFaceH4/zephyr-7b-beta"
17
  HUGGINGFACE_API_TOKEN = os.getenv("HUGGINGFACE_API_KEY")
18
 
19
  # Set Hugging Face API token for litellm
@@ -74,11 +74,9 @@ def call_llm(prompt):
74
  """Correctly call Hugging Face models using litellm"""
75
  try:
76
  response = litellm.completion(
77
- model="huggingface",
78
  messages=[{"role": "user", "content": prompt}],
79
- api_base="https://api-inference.huggingface.co/models",
80
- api_key=HUGGINGFACE_API_TOKEN,
81
- model_kwargs={"model": LLM_MODEL, "temperature": 0.4}
82
  )
83
  return response["choices"][0]["message"]["content"]
84
  except Exception as e:
@@ -90,7 +88,7 @@ def setup_agents(language='en'):
90
  goal="Analyze and validate space information",
91
  backstory="Expert in multilingual space data analysis with NASA mission experience.",
92
  verbose=True,
93
- llm=call_llm # ✅ Now correctly calls Hugging Face using litellm
94
  )
95
 
96
  educator = Agent(
@@ -98,7 +96,7 @@ def setup_agents(language='en'):
98
  goal=f"Explain complex concepts in {language} using simple terms",
99
  backstory=f"Multilingual science communicator specializing in {language} explanations.",
100
  verbose=True,
101
- llm=call_llm # ✅ Now correctly calls Hugging Face using litellm
102
  )
103
 
104
  return researcher, educator
 
13
  # Configuration
14
  NASA_API_URL = "https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY"
15
  HF_MODEL_NAME = "sentence-transformers/all-MiniLM-L6-v2"
16
+ LLM_MODEL = "huggingface/HuggingFaceH4/zephyr-7b-beta"
17
  HUGGINGFACE_API_TOKEN = os.getenv("HUGGINGFACE_API_KEY")
18
 
19
  # Set Hugging Face API token for litellm
 
74
  """Correctly call Hugging Face models using litellm"""
75
  try:
76
  response = litellm.completion(
77
+ model=LLM_MODEL,
78
  messages=[{"role": "user", "content": prompt}],
79
+ api_key=HUGGINGFACE_API_TOKEN
 
 
80
  )
81
  return response["choices"][0]["message"]["content"]
82
  except Exception as e:
 
88
  goal="Analyze and validate space information",
89
  backstory="Expert in multilingual space data analysis with NASA mission experience.",
90
  verbose=True,
91
+ llm="huggingface/HuggingFaceH4/zephyr-7b-beta" # ✅ Now correctly set as a model string
92
  )
93
 
94
  educator = Agent(
 
96
  goal=f"Explain complex concepts in {language} using simple terms",
97
  backstory=f"Multilingual science communicator specializing in {language} explanations.",
98
  verbose=True,
99
+ llm="huggingface/HuggingFaceH4/zephyr-7b-beta" # ✅ Now correctly set as a model string
100
  )
101
 
102
  return researcher, educator