suhailidrees commited on
Commit
be4164d
·
1 Parent(s): 1344c2d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -3
app.py CHANGED
@@ -12,10 +12,19 @@ import gradio as gr
12
  import openai
13
  import json
14
 
15
- def call_openai(msg, api_key):
 
 
 
 
 
 
 
 
 
16
  openai.api_key = api_key
17
  response = openai.ChatCompletion.create(
18
- model="gpt-3.5-turbo",
19
  messages=[
20
  {"role": "system", "content": "You are a helpful assistant."},
21
  {"role": "user", "content": msg}
@@ -30,7 +39,8 @@ iface = gr.Interface(
30
  fn = call_openai,
31
  inputs = [
32
  gr.Textbox(placeholder="Message"),
33
- gr.Textbox(placeholder="OpenAI API key")
 
34
  ],
35
  outputs = [
36
  gr.Textbox(label="Assistant message"),
 
12
  import openai
13
  import json
14
 
15
+ gpt_models = [
16
+ "gpt-4",
17
+ "gpt-4-0314",
18
+ "gpt-4-32k",
19
+ "gpt-4-32k-0314",
20
+ "gpt-3.5-turbo",
21
+ "gpt-3.5-turbo-0301"
22
+ ]
23
+
24
+ def call_openai(msg, api_key, model):
25
  openai.api_key = api_key
26
  response = openai.ChatCompletion.create(
27
+ model=model,
28
  messages=[
29
  {"role": "system", "content": "You are a helpful assistant."},
30
  {"role": "user", "content": msg}
 
39
  fn = call_openai,
40
  inputs = [
41
  gr.Textbox(placeholder="Message"),
42
+ gr.Textbox(placeholder="OpenAI API key"),
43
+ gr.Dropdown(choices=gpt_models, value=gpt_models[4])
44
  ],
45
  outputs = [
46
  gr.Textbox(label="Assistant message"),