lmx0 commited on
Commit
0e5e09f
·
1 Parent(s): 7ba7b65

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -9,13 +9,13 @@ API_URL = "https://api.openai.com/v1/chat/completions" #os.getenv("API_URL") + "
9
  #Testing with my Open AI Key
10
  #OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
11
 
12
- def predict(inputs, top_p, temperature, openai_api_key, chat_counter, chatbot=[], history=[]): #repetition_penalty, top_k
13
-
 
 
14
  payload = {
15
  "model": "gpt-3.5-turbo",
16
  "messages": [{"role": "user", "content": f"{inputs}"}],
17
- "temperature" : 1.0,
18
- "top_p":1.0,
19
  "n" : 1,
20
  "stream": True,
21
  "presence_penalty":0,
@@ -117,14 +117,14 @@ with gr.Blocks(css = """#col_container {margin-left: auto; margin-right: auto;}
117
 
118
  #inputs, top_p, temperature, top_k, repetition_penalty
119
  with gr.Accordion("参数", open=False):
120
- top_p = gr.Slider( minimum=-0, maximum=1.0, value=1.0, step=0.05, interactive=True, label="Top-p (nucleus sampling)",)
121
- temperature = gr.Slider( minimum=-0, maximum=5.0, value=1.0, step=0.1, interactive=True, label="Temperature",)
122
  #top_k = gr.Slider( minimum=1, maximum=50, value=4, step=1, interactive=True, label="Top-k",)
123
  #repetition_penalty = gr.Slider( minimum=0.1, maximum=3.0, value=1.03, step=0.01, interactive=True, label="Repetition Penalty", )
124
  chat_counter = gr.Number(value=0, visible=False, precision=0)
125
 
126
- inputs.submit( predict, [inputs, top_p, temperature, openai_api_key, chat_counter, chatbot, state], [chatbot, state, chat_counter],)
127
- b1.click( predict, [inputs, top_p, temperature, openai_api_key, chat_counter, chatbot, state], [chatbot, state, chat_counter],)
128
  b1.click(reset_textbox, [], [inputs])
129
  inputs.submit(reset_textbox, [], [inputs])
130
 
 
9
  #Testing with my Open AI Key
10
  #OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
11
 
12
+ def predict(inputs, openai_api_key, chat_counter, chatbot=[], history=[]): #repetition_penalty, top_k
13
+ temperature = 1.0
14
+ top_p = 1.0
15
+
16
  payload = {
17
  "model": "gpt-3.5-turbo",
18
  "messages": [{"role": "user", "content": f"{inputs}"}],
 
 
19
  "n" : 1,
20
  "stream": True,
21
  "presence_penalty":0,
 
117
 
118
  #inputs, top_p, temperature, top_k, repetition_penalty
119
  with gr.Accordion("参数", open=False):
120
+ # top_p = gr.Slider( minimum=-0, maximum=1.0, value=1.0, step=0.05, interactive=True, label="Top-p (nucleus sampling)",)
121
+ # temperature = gr.Slider( minimum=-0, maximum=5.0, value=1.0, step=0.1, interactive=True, label="Temperature",)
122
  #top_k = gr.Slider( minimum=1, maximum=50, value=4, step=1, interactive=True, label="Top-k",)
123
  #repetition_penalty = gr.Slider( minimum=0.1, maximum=3.0, value=1.03, step=0.01, interactive=True, label="Repetition Penalty", )
124
  chat_counter = gr.Number(value=0, visible=False, precision=0)
125
 
126
+ inputs.submit( predict, [inputs, openai_api_key, chat_counter, chatbot, state], [chatbot, state, chat_counter],)
127
+ b1.click( predict, [inputs, openai_api_key, chat_counter, chatbot, state], [chatbot, state, chat_counter],)
128
  b1.click(reset_textbox, [], [inputs])
129
  inputs.submit(reset_textbox, [], [inputs])
130