ghsambit commited on
Commit
43033c2
Β·
1 Parent(s): 71467d9

Updated Version

Browse files
Files changed (3) hide show
  1. README.md +22 -13
  2. app.py +17 -14
  3. requirements.txt +1 -4
README.md CHANGED
@@ -1,13 +1,22 @@
1
- ---
2
- title: Sambit AI
3
- emoji: πŸ’¬
4
- colorFrom: yellow
5
- colorTo: purple
6
- sdk: gradio
7
- sdk_version: 5.0.1
8
- app_file: app.py
9
- pinned: false
10
- short_description: Your helpful AI classmate
11
- ---
12
-
13
- An example chatbot using [Gradio](https://gradio.app), [`huggingface_hub`](https://huggingface.co/docs/huggingface_hub/v0.22.2/en/index), and the [Hugging Face Inference API](https://huggingface.co/docs/api-inference/index).
 
 
 
 
 
 
 
 
 
 
1
+ # Sambit AI (Gradio + Together API)
2
+
3
+ This is a chatbot powered by [Together.ai](https://www.together.ai/) and the Mixtral 8x7B model, deployed with Gradio.
4
+
5
+ ## πŸ”§ Setup
6
+
7
+ 1. Create a new Space on Hugging Face β†’ Gradio template.
8
+ 2. Add your Together API key in the **Settings > Secrets** tab as:
9
+
10
+ ```
11
+ TOGETHER_API_KEY=your_api_key_here
12
+ ```
13
+
14
+ 3. Upload these files or the full ZIP.
15
+
16
+ ## πŸš€ Model Used
17
+ - Model: `mistralai/Mixtral-8x7B-Instruct-v0.1`
18
+ - Provider: [Together.ai](https://docs.together.ai/docs/inference)
19
+
20
+ ## πŸŽ™ Usage
21
+
22
+ Just ask anything! Sambit AI will respond with answers from the Together inference API.
app.py CHANGED
@@ -1,12 +1,11 @@
1
  import gradio as gr
2
- import os
3
  import requests
 
4
 
5
- # βœ… Load API key from Hugging Face Secrets (set in Settings β†’ Secrets)
6
- API_KEY = os.getenv("TOGETHER_API_KEY")
7
  MODEL_NAME = "mistralai/Mixtral-8x7B-Instruct-v0.1"
8
 
9
- def ask_ai(message):
10
  if not API_KEY:
11
  return "❌ API key not found. Please set it in Settings β†’ Secrets."
12
 
@@ -15,12 +14,16 @@ def ask_ai(message):
15
  "Authorization": f"Bearer {API_KEY}",
16
  "Content-Type": "application/json"
17
  }
 
 
 
 
 
 
 
18
  data = {
19
  "model": MODEL_NAME,
20
- "messages": [
21
- {"role": "system", "content": "You are Sambit AI, a helpful assistant."},
22
- {"role": "user", "content": message}
23
- ]
24
  }
25
 
26
  try:
@@ -32,9 +35,9 @@ def ask_ai(message):
32
  except Exception as e:
33
  return f"❌ Error: {str(e)}"
34
 
35
- # βœ… Gradio UI
36
- chat_interface = gr.ChatInterface(fn=ask_ai, title="Sambit AI πŸ€– β€” Powered by Together & LLaMA 3")
37
-
38
- # βœ… Launch the app
39
- if __name__ == "__main__":
40
- chat_interface.launch()
 
1
  import gradio as gr
 
2
  import requests
3
+ import os
4
 
5
+ API_KEY = os.environ.get("TOGETHER_API_KEY")
 
6
  MODEL_NAME = "mistralai/Mixtral-8x7B-Instruct-v0.1"
7
 
8
+ def ask_ai(message, history):
9
  if not API_KEY:
10
  return "❌ API key not found. Please set it in Settings β†’ Secrets."
11
 
 
14
  "Authorization": f"Bearer {API_KEY}",
15
  "Content-Type": "application/json"
16
  }
17
+
18
+ messages = [{"role": "system", "content": "You are Sambit AI, a helpful assistant."}]
19
+ for user, bot in history:
20
+ messages.append({"role": "user", "content": user})
21
+ messages.append({"role": "assistant", "content": bot})
22
+ messages.append({"role": "user", "content": message})
23
+
24
  data = {
25
  "model": MODEL_NAME,
26
+ "messages": messages
 
 
 
27
  }
28
 
29
  try:
 
35
  except Exception as e:
36
  return f"❌ Error: {str(e)}"
37
 
38
+ gr.ChatInterface(
39
+ fn=ask_ai,
40
+ title="Sambit AI πŸ€– β€” Powered by Together & LLaMA 3",
41
+ chatbot=gr.Chatbot(type="messages"),
42
+ description="Ask anything. Sambit AI uses Together's Mixtral 8x7B model.",
43
+ ).launch()
requirements.txt CHANGED
@@ -1,5 +1,2 @@
1
-
2
  gradio==5.30.0
3
- requests
4
- together
5
- gtts
 
 
1
  gradio==5.30.0
2
+ requests