ShermanAI commited on
Commit
d57d1a5
·
1 Parent(s): bfd3f7f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -13
app.py CHANGED
@@ -18,20 +18,14 @@ load_dotenv() # load environment variables from .env file
18
  api_key = os.getenv("OPENAI_API_KEY") # access the value of the OPENAI_API_KEY environment variable
19
 
20
  def openai_chat(prompt):
21
- completions = openai.Completion.create(
22
- engine="text-davinci-003",
23
- prompt=prompt,
24
- max_tokens=1024,
25
- n=1,
26
- temperature=0.5,
27
- )
28
-
29
- message = completions.choices[0].text
30
- return message.strip()
31
  def chatbot(input, history=[]):
32
- output = openai_chat(input)
33
- history.append((input, output))
34
- return history, history
35
 
36
  gr.Interface(fn = chatbot,
37
  inputs = ["text",'state'],
 
18
  api_key = os.getenv("OPENAI_API_KEY") # access the value of the OPENAI_API_KEY environment variable
19
 
20
  def openai_chat(prompt):
21
+ completions = openai.Completion.create( engine="text-davinci-003",prompt=prompt,max_tokens=1024,n=1,temperature=0.5,)
22
+ message = completions.choices[0].text
23
+ return message.strip()
24
+
 
 
 
 
 
 
25
  def chatbot(input, history=[]):
26
+ output = openai_chat(input)
27
+ history.append((input, output))
28
+ return history, history
29
 
30
  gr.Interface(fn = chatbot,
31
  inputs = ["text",'state'],