Walterchamy commited on
Commit
1df5cf1
1 Parent(s): b496528

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -12
app.py CHANGED
@@ -2,7 +2,7 @@ import os
2
  import openai
3
  from gtts import gTTS
4
  import streamlit as st
5
- from openai==0.28 import OpenAI
6
 
7
  client = OpenAI(
8
  api_key=os.environ['OPENAI_API_KEY'], # this is also the default, it can be omitted
@@ -191,19 +191,15 @@ For contact information:
191
  #if __name__ == '__main__':
192
  # main()
193
  def generate_response(user_input):
194
- response = openai.Completion.create(
195
- engine="davinci-codex",
196
- prompt=[
197
- {"role": "system", "content": "i have create a streamlit app of question and answering and i'm using chatgpt by using openaiAPI but gives me the error provided"},
198
  {"role": "user", "content": user_input}
199
- ],
200
- temperature=0.7,
201
- max_tokens=100,
202
- top_p=1.0,
203
- frequency_penalty=0.0,
204
- presence_penalty=0.0
205
  )
206
- return response.choices[0].message.content
 
207
 
208
  def main():
209
  st.title("Question and Answering with OpenAI")
 
2
  import openai
3
  from gtts import gTTS
4
  import streamlit as st
5
+ from openai import OpenAI
6
 
7
  client = OpenAI(
8
  api_key=os.environ['OPENAI_API_KEY'], # this is also the default, it can be omitted
 
191
  #if __name__ == '__main__':
192
  # main()
193
  def generate_response(user_input):
194
+ response = openai.ChatCompletion.create(
195
+ model="gpt-3.5-turbo",
196
+ messages=[
197
+ {"role": "system", "content": "You are a highly skilled AI assistant that can understand and answer questions in a natural and intelligent manner."},
198
  {"role": "user", "content": user_input}
199
+ ]
 
 
 
 
 
200
  )
201
+ return response['choices'][0]['message']['content']
202
+
203
 
204
  def main():
205
  st.title("Question and Answering with OpenAI")