AegionX commited on
Commit
327497b
Β·
verified Β·
1 Parent(s): 39748b8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -9
app.py CHANGED
@@ -2,10 +2,11 @@ import gradio as gr
2
  import random
3
  import os
4
  import json
5
- from huggingface_hub import InferenceClient
6
 
7
- # Use Zephyr for general AI chatbot
8
- client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
 
9
 
10
  # 🧠 MEMORY SETUP
11
  MEMORY_FILE = "hoopmind_memory.json"
@@ -32,13 +33,20 @@ def update_memory(user_input):
32
  save_memory(memory)
33
  return memory
34
 
35
- # πŸ’¬ Normal chatbot fallback
36
  def alpha_chatbot_response(user_input):
37
  try:
38
- system_prompt = "You are a helpful, smart, and friendly AI assistant."
39
- prompt = f"<|system|>\n{system_prompt}\n<|user|>\n{user_input}\n<|assistant|>"
40
- response = client.text_generation(prompt, max_new_tokens=200, temperature=0.7)
41
- return response.strip()
 
 
 
 
 
 
 
42
  except Exception as e:
43
  return "Oops πŸ˜“ I had a lil error trying to respond. Try again in a bit!"
44
 
@@ -109,7 +117,7 @@ def hoopmind_chat(user_input, history=[]):
109
  "I’m your personal trainer + hype man + homie rolled in one 🧠πŸ”₯"
110
  ])
111
 
112
- # Fallback: use Zephyr for normal chat
113
  return alpha_chatbot_response(user_input)
114
 
115
  # πŸš€ CHAT INTERFACE
@@ -136,3 +144,4 @@ Drop a question or say what's up πŸ‘‡
136
  chat.launch()
137
 
138
 
 
 
2
  import random
3
  import os
4
  import json
5
+ import openai
6
 
7
+ # πŸ” SWITCHED TO OPENROUTER + MISTRAL MODEL
8
+ openai.api_base = "https://openrouter.ai/api/v1"
9
+ openai.api_key = "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"
10
 
11
  # 🧠 MEMORY SETUP
12
  MEMORY_FILE = "hoopmind_memory.json"
 
33
  save_memory(memory)
34
  return memory
35
 
36
+ # πŸ’¬ General fallback chat using Mistral
37
  def alpha_chatbot_response(user_input):
38
  try:
39
+ messages = [
40
+ {"role": "system", "content": "You are a helpful, smart, and friendly AI assistant."},
41
+ {"role": "user", "content": user_input}
42
+ ]
43
+ response = openai.ChatCompletion.create(
44
+ model="mistral/mistral-7b-instruct", # or "mistral/mixtral-8x7b-instruct"
45
+ messages=messages,
46
+ temperature=0.7,
47
+ max_tokens=200
48
+ )
49
+ return response.choices[0].message["content"].strip()
50
  except Exception as e:
51
  return "Oops πŸ˜“ I had a lil error trying to respond. Try again in a bit!"
52
 
 
117
  "I’m your personal trainer + hype man + homie rolled in one 🧠πŸ”₯"
118
  ])
119
 
120
+ # Fallback: use Mistral
121
  return alpha_chatbot_response(user_input)
122
 
123
  # πŸš€ CHAT INTERFACE
 
144
  chat.launch()
145
 
146
 
147
+