bhaskartripathi commited on
Commit
5d26343
·
verified ·
1 Parent(s): b198b79

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -17
app.py CHANGED
@@ -102,11 +102,11 @@ def load_recommender(path, start_page=1):
102
 
103
  def generate_text(openAI_key, prompt, model="gpt-3.5-turbo"):
104
  openai.api_key = openAI_key
105
- temperature=0.7
106
- max_tokens=256
107
- top_p=1
108
- frequency_penalty=0
109
- presence_penalty=0
110
 
111
  if model == "text-davinci-003":
112
  completions = openai.Completion.create(
@@ -119,19 +119,19 @@ def generate_text(openAI_key, prompt, model="gpt-3.5-turbo"):
119
  )
120
  message = completions.choices[0].text
121
  else:
122
- message = openai.ChatCompletion.create(
123
  model=model,
124
  messages=[
125
  {"role": "system", "content": "You are a helpful assistant."},
126
- {"role": "assistant", "content": "Here is some initial assistant message."},
127
  {"role": "user", "content": prompt}
128
  ],
129
- temperature=.3,
130
  max_tokens=max_tokens,
131
  top_p=top_p,
132
  frequency_penalty=frequency_penalty,
133
  presence_penalty=presence_penalty,
134
- ).choices[0].message['content']
 
135
  return message
136
 
137
 
@@ -255,16 +255,13 @@ with gr.Blocks(css="""#chatbot { font-size: 14px; min-height: 1200; }""") as dem
255
  # Model Selection
256
  model = gr.Radio(
257
  choices=[
258
- 'gpt-3.5-turbo',
259
- 'gpt-3.5-turbo-16k',
260
- 'gpt-3.5-turbo-0613',
261
- 'gpt-3.5-turbo-16k-0613',
262
- 'text-davinci-003',
263
- 'gpt-4',
264
- 'gpt-4-32k'
265
  ],
266
  label='Select Model',
267
- value='gpt-3.5-turbo'
268
  )
269
 
270
  # Chat Interface
 
102
 
103
  def generate_text(openAI_key, prompt, model="gpt-3.5-turbo"):
104
  openai.api_key = openAI_key
105
+ temperature = 0.1
106
+ max_tokens = 256
107
+ top_p = 1
108
+ frequency_penalty = 0
109
+ presence_penalty = 0
110
 
111
  if model == "text-davinci-003":
112
  completions = openai.Completion.create(
 
119
  )
120
  message = completions.choices[0].text
121
  else:
122
+ response = openai.ChatCompletion.create(
123
  model=model,
124
  messages=[
125
  {"role": "system", "content": "You are a helpful assistant."},
 
126
  {"role": "user", "content": prompt}
127
  ],
128
+ temperature=temperature,
129
  max_tokens=max_tokens,
130
  top_p=top_p,
131
  frequency_penalty=frequency_penalty,
132
  presence_penalty=presence_penalty,
133
+ )
134
+ message = response['choices'][0]['message']['content']
135
  return message
136
 
137
 
 
255
  # Model Selection
256
  model = gr.Radio(
257
  choices=[
258
+ 'gpt-4o',
259
+ 'gpt-4o-mini',
260
+ 'o1-preview',
261
+ 'o1-mini'
 
 
 
262
  ],
263
  label='Select Model',
264
+ value='gpt-4o'
265
  )
266
 
267
  # Chat Interface