Updated Version
Browse files- README.md +22 -13
- app.py +17 -14
- requirements.txt +1 -4
README.md
CHANGED
|
@@ -1,13 +1,22 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
|
| 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 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
|
|
|
| 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
|
|
|
|
|
|