Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import openai
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
system_content = "You are a travel agent. Be descriptive and helpful."
|
| 5 |
+
user_content = "Tell me about San Francisco"
|
| 6 |
+
|
| 7 |
+
client = openai.OpenAI(
|
| 8 |
+
api_key="f722a9f6e3afd6b9999e6aee02aeac9e751ea3a67b124c3667ab50c85c7fa99e",
|
| 9 |
+
base_url="https://api.together.xyz/v1",
|
| 10 |
+
)
|
| 11 |
+
|
| 12 |
+
def chat_completion = client.chat.completions.create(
|
| 13 |
+
model="mistralai/Mixtral-8x7B-Instruct-v0.1",
|
| 14 |
+
messages=[
|
| 15 |
+
{"role": "system", "content": system_content},
|
| 16 |
+
{"role": "user", "content": user_content},
|
| 17 |
+
],
|
| 18 |
+
temperature=0.7,
|
| 19 |
+
max_tokens=1024,
|
| 20 |
+
)
|
| 21 |
+
response = chat_completion.choices[0].message.content
|
| 22 |
+
|
| 23 |
+
gr.ChatInterface(predict).queue().launch()
|