agnixcode commited on
Commit
2423ede
·
verified ·
1 Parent(s): 63d7ebf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py CHANGED
@@ -136,6 +136,27 @@ Question:
136
  return response.choices[0].message.content
137
 
138
  # ... (keep all previous code until chat function)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
 
140
  def chat(user_input, history):
141
  answer = generate_answer(user_input)
 
136
  return response.choices[0].message.content
137
 
138
  # ... (keep all previous code until chat function)
139
+ # Add to app.py
140
+ MODELS = {
141
+ "Fast (Groq)": "llama-3.1-8b-instant",
142
+ "Smart (Groq)": "llama-3.1-70b-versatile",
143
+ "Your Bot": "yourusername/finance-bot" # After fine-tuning
144
+ }
145
+
146
+ model_dropdown = gr.Dropdown(choices=list(MODELS.keys()), value="Fast (Groq)", label="🤖 AI Model")
147
+
148
+ def generate_answer(query, conversation_context="", model_name="Fast (Groq)"):
149
+ # ... RAG logic ...
150
+ model_id = MODELS[model_name]
151
+
152
+ if "Your Bot" in model_name:
153
+ # Use HF Inference API for your model
154
+ response = requests.post("https://api-inference.huggingface.co/models/yourusername/finance-bot",
155
+ json={"inputs": full_prompt})
156
+ return response.json()[0]["generated_text"]
157
+ else:
158
+ # Groq API
159
+ response = client.chat.completions.create(model=model_id, ...)
160
 
161
  def chat(user_input, history):
162
  answer = generate_answer(user_input)