RamV commited on
Commit
ae4c441
·
1 Parent(s): 1c08aa3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -11
app.py CHANGED
@@ -1,5 +1,6 @@
1
  import os
2
- import openai
 
3
  import gradio as gr
4
 
5
 
@@ -26,16 +27,18 @@ def generate_response(user_input):
26
 
27
 
28
  # Generate a response using the OpenAI API
29
- response = openai.Completion.create(
30
- model="text-davinci-003",
31
- prompt=prompt,
32
- temperature=0.9,
33
- max_tokens=150,
34
- top_p=1,
35
- frequency_penalty=0,
36
- presence_penalty=0.6,
37
- stop=["Human:", "AI:"]
38
- )
 
 
39
 
40
  # Extract the response from the API output
41
  chat_response = response.choices[0].text.strip()
 
1
  import os
2
+ from openai import OpenAI
3
+ client = OpenAI()
4
  import gradio as gr
5
 
6
 
 
27
 
28
 
29
  # Generate a response using the OpenAI API
30
+ from openai import OpenAI
31
+ client = OpenAI()
32
+
33
+ response = client.chat.completions.create(
34
+ model="gpt-3.5-turbo-1106",
35
+ response_format={ "type": "json_object" },
36
+ messages=[
37
+ {"role": "system", "content": "You are a helpful assistant designed to output JSON."},
38
+ {"role": "user", "content": "Who won the world series in 2020?"}
39
+ ]
40
+ )
41
+ print(response.choices[0].message.content)
42
 
43
  # Extract the response from the API output
44
  chat_response = response.choices[0].text.strip()