jost commited on
Commit
e4e9f4c
1 Parent(s): 8596472

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -12
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
- Function to send user input to OpenAI’s Chat Completion API and return the response.
7
- """
8
- openai.api_key = api_key
9
- response = openai.ChatCompletion.create(
10
- model='gpt-3.5-turbo', # You can change the model as needed
11
- messages=[
12
- {"role": "system", "content": "You are a helpful assistant."},
13
- {"role": "user", "content": user_input},
14
- ]
15
- )
16
 
17
- return response.choices[0].message['content']
 
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."