Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,20 +1,20 @@
|
|
1 |
import openai
|
2 |
import gradio as gr
|
3 |
|
|
|
|
|
4 |
def chat_with_openai(api_key, user_input):
|
5 |
-
"""
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
{"role": "user", "content": user_input},
|
14 |
-
]
|
15 |
-
)
|
16 |
|
17 |
-
|
|
|
18 |
|
19 |
def main():
|
20 |
description = "This is a simple interface to interact with OpenAI’s Chat Completion API. Please enter your API key and your message."
|
|
|
1 |
import openai
|
2 |
import gradio as gr
|
3 |
|
4 |
+
anyscale_base_url = "https://api.endpoints.anyscale.com/v1"
|
5 |
+
|
6 |
def chat_with_openai(api_key, user_input):
|
7 |
+
prompt = f"""[INST] {user_input} [/INST]"""
|
8 |
+
|
9 |
+
client = OpenAI(base_url=self.api_base, api_key=self.token)
|
10 |
+
completion = client.completions.create(
|
11 |
+
model="mistralai/Mixtral-8x7B-Instruct-v0.1",
|
12 |
+
prompt=prompt,
|
13 |
+
temperature=0.7,
|
14 |
+
max_tokens=100)
|
|
|
|
|
|
|
15 |
|
16 |
+
response = completion.choices[0].text
|
17 |
+
return response
|
18 |
|
19 |
def main():
|
20 |
description = "This is a simple interface to interact with OpenAI’s Chat Completion API. Please enter your API key and your message."
|