aquibmoin commited on
Commit
4815dab
1 Parent(s): 5cdeca9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -23,16 +23,19 @@ def generate_response(user_input, context_embedding):
23
  combined_input = f"Question: {user_input}\nContext: {context_str}\nAnswer:"
24
 
25
  # Generate a response using GPT-4
26
- response = openai.Completion.create(
27
- engine="gpt-4-turbo", # Use GPT-4 engine if available, otherwise use text-davinci-003
28
- prompt=combined_input,
 
 
 
29
  max_tokens=150,
30
  temperature=0.5,
31
  top_p=0.9,
32
  frequency_penalty=0.5,
33
  presence_penalty=0.0
34
  )
35
- return response.choices[0].text.strip()
36
 
37
  def chatbot(user_input, context=""):
38
  context_embedding = encode_text(context) if context else ""
@@ -56,3 +59,4 @@ iface.launch()
56
 
57
 
58
 
 
 
23
  combined_input = f"Question: {user_input}\nContext: {context_str}\nAnswer:"
24
 
25
  # Generate a response using GPT-4
26
+ response = openai.ChatCompletion.create(
27
+ model="gpt-4", # Use GPT-4 model
28
+ messages=[
29
+ {"role": "system", "content": "You are a helpful assistant."},
30
+ {"role": "user", "content": combined_input}
31
+ ],
32
  max_tokens=150,
33
  temperature=0.5,
34
  top_p=0.9,
35
  frequency_penalty=0.5,
36
  presence_penalty=0.0
37
  )
38
+ return response.choices[0].message['content'].strip()
39
 
40
  def chatbot(user_input, context=""):
41
  context_embedding = encode_text(context) if context else ""
 
59
 
60
 
61
 
62
+