hugforziio commited on
Commit
e8e5a6c
1 Parent(s): 0fc8db7

now can select model

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -13,9 +13,7 @@ import openai
13
 
14
 
15
  DEFAULT_PROMPT = [
16
- ["system", "(assistant)是一名疯狂的摇滚乐手,用户(user)是你的粉丝。"],
17
- ["user", "我们来玩一个角色扮演游戏吧!请你扮演一名疯狂的摇滚乐手,而我将扮演你的粉丝。"],
18
- ["assistant", "真是个有趣的游戏!我将扮演一名疯狂的摇滚乐手,而你是我的粉丝。听起来真不错!让我们开始吧!"],
19
  ]
20
 
21
 
@@ -47,7 +45,7 @@ DEFAULT_PROMPT = [
47
 
48
  def on_click_send_btn(
49
  old_state, api_key_text, chat_input_role, chat_input, prompt_table, chat_use_prompt, chat_use_history, chat_log,
50
- temperature, top_p, choices_num, stream, max_tokens, presence_penalty, frequency_penalty, logit_bias,
51
  ):
52
 
53
  print(prompt_table)
@@ -89,7 +87,7 @@ def on_click_send_btn(
89
  openai.api_key = api_key_text
90
 
91
  props = {
92
- 'model': "gpt-3.5-turbo",
93
  'messages': [xx for xx in map(lambda it: {'role':it[0], 'content':it[1]}, req_hist)],
94
  'temperature': temperature,
95
  'top_p': top_p,
@@ -226,6 +224,10 @@ with gradio.Blocks(title="ChatGPT", css=css) as demo:
226
  with gradio.Column(scale=4):
227
  with gradio.Box():
228
  gradio.Markdown("See https://platform.openai.com/docs/api-reference/chat/create .")
 
 
 
 
229
  chat_temperature = gradio.Slider(label="temperature", value=1, minimum=0, maximum=2)
230
  chat_top_p = gradio.Slider(label="top_p", value=1, minimum=0, maximum=1)
231
  chat_choices_num = gradio.Slider(label="choices num(n)", value=1, minimum=1, maximum=20)
@@ -258,7 +260,7 @@ with gradio.Blocks(title="ChatGPT", css=css) as demo:
258
  on_click_send_btn,
259
  inputs=[
260
  global_state, api_key_text, chat_input_role, chat_input, prompt_table, chat_use_prompt, chat_use_history, chat_log,
261
- chat_temperature, chat_top_p, chat_choices_num, chat_stream, chat_max_tokens, chat_presence_penalty, chat_frequency_penalty, chat_logit_bias,
262
  ],
263
  outputs=[global_state, chat_log, chat_log_box, chat_last_resp, chat_last_req, chat_input],
264
  api_name="click-send-btn",
 
13
 
14
 
15
  DEFAULT_PROMPT = [
16
+ ["system", "You(assistant) are a helpful AI assistant."],
 
 
17
  ]
18
 
19
 
 
45
 
46
  def on_click_send_btn(
47
  old_state, api_key_text, chat_input_role, chat_input, prompt_table, chat_use_prompt, chat_use_history, chat_log,
48
+ chat_model, temperature, top_p, choices_num, stream, max_tokens, presence_penalty, frequency_penalty, logit_bias,
49
  ):
50
 
51
  print(prompt_table)
 
87
  openai.api_key = api_key_text
88
 
89
  props = {
90
+ 'model': chat_model,
91
  'messages': [xx for xx in map(lambda it: {'role':it[0], 'content':it[1]}, req_hist)],
92
  'temperature': temperature,
93
  'top_p': top_p,
 
224
  with gradio.Column(scale=4):
225
  with gradio.Box():
226
  gradio.Markdown("See https://platform.openai.com/docs/api-reference/chat/create .")
227
+ chat_model = gradio.Dropdown(label="model", choices=[
228
+ "gpt-3.5-turbo", "gpt-3.5-turbo-0301",
229
+ "gpt-4", "gpt-4-0314", "gpt-4-32k", "gpt-4-32k-0314",
230
+ ], value="gpt-3.5-turbo")
231
  chat_temperature = gradio.Slider(label="temperature", value=1, minimum=0, maximum=2)
232
  chat_top_p = gradio.Slider(label="top_p", value=1, minimum=0, maximum=1)
233
  chat_choices_num = gradio.Slider(label="choices num(n)", value=1, minimum=1, maximum=20)
 
260
  on_click_send_btn,
261
  inputs=[
262
  global_state, api_key_text, chat_input_role, chat_input, prompt_table, chat_use_prompt, chat_use_history, chat_log,
263
+ chat_model, chat_temperature, chat_top_p, chat_choices_num, chat_stream, chat_max_tokens, chat_presence_penalty, chat_frequency_penalty, chat_logit_bias,
264
  ],
265
  outputs=[global_state, chat_log, chat_log_box, chat_last_resp, chat_last_req, chat_input],
266
  api_name="click-send-btn",