bhaskartripathi commited on
Commit
99776b9
1 Parent(s): 1605348

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -6
app.py CHANGED
@@ -118,20 +118,35 @@ def load_recommender(path, start_page=1):
118
 
119
 
120
 
121
- def generate_text(openAI_key,prompt, engine="text-davinci-003"):
 
 
 
 
 
 
 
 
 
 
 
 
 
122
  openai.api_key = openAI_key
123
- completions = openai.Completion.create(
124
- engine=engine,
125
- prompt=prompt,
 
 
 
126
  max_tokens=512,
127
  n=1,
128
  stop=None,
129
  temperature=0.7,
130
  )
131
- message = completions.choices[0].text
132
  return message
133
 
134
-
135
  def generate_answer(question,openAI_key):
136
  topn_chunks = recommender(question)
137
  prompt = ""
 
118
 
119
 
120
 
121
+ #def generate_text(openAI_key,prompt, engine="text-davinci-003"):
122
+ # openai.api_key = openAI_key
123
+ # completions = openai.Completion.create(
124
+ # engine=engine,
125
+ # prompt=prompt,
126
+ # max_tokens=512,
127
+ # n=1,
128
+ # stop=None,
129
+ #temperature=0.7,
130
+ #)
131
+ #message = completions.choices[0].text
132
+ #return message
133
+
134
+ def generate_text(openAI_key, prompt, engine="gpt-3.5-turbo"):
135
  openai.api_key = openAI_key
136
+ messages = [{'role': 'system', 'content': 'You are a helpful assistant.'},
137
+ {'role': 'user', 'content': prompt}]
138
+
139
+ completions = openai.ChatCompletion.create(
140
+ model=engine,
141
+ messages=messages,
142
  max_tokens=512,
143
  n=1,
144
  stop=None,
145
  temperature=0.7,
146
  )
147
+ message = completions.choices[0].message['content']
148
  return message
149
 
 
150
  def generate_answer(question,openAI_key):
151
  topn_chunks = recommender(question)
152
  prompt = ""