jost commited on
Commit
cdd8f1e
1 Parent(s): 7e723b7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -3,7 +3,7 @@ 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=anyscale_base_url, api_key=api_key)
@@ -20,12 +20,12 @@ 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."
21
  with gr.Blocks() as demo:
22
  with gr.Row():
23
- api_key_input = gr.Textbox(label="API Key", placeholder="Enter your OpenAI API key here", show_label=True, type="password")
24
  user_input = gr.Textbox(label="Your Message", placeholder="Enter your message here")
25
  submit_btn = gr.Button("Submit")
26
  output = gr.Textbox(label="Chatbot Response")
27
 
28
- submit_btn.click(fn=chat_with_openai, inputs=[api_key_input, user_input], outputs=output)
29
 
30
  demo.launch()
31
 
 
3
 
4
  anyscale_base_url = "https://api.endpoints.anyscale.com/v1"
5
 
6
+ def predict(api_key, user_input):
7
  prompt = f"""[INST] {user_input} [/INST]"""
8
 
9
  client = OpenAI(base_url=anyscale_base_url, api_key=api_key)
 
20
  description = "This is a simple interface to interact with OpenAI’s Chat Completion API. Please enter your API key and your message."
21
  with gr.Blocks() as demo:
22
  with gr.Row():
23
+ api_key_input = gr.Textbox(label="API Key", placeholder="Enter your API key here", show_label=True, type="password")
24
  user_input = gr.Textbox(label="Your Message", placeholder="Enter your message here")
25
  submit_btn = gr.Button("Submit")
26
  output = gr.Textbox(label="Chatbot Response")
27
 
28
+ submit_btn.click(fn=predict, inputs=[api_key_input, user_input], outputs=output)
29
 
30
  demo.launch()
31