Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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.
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
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].
|
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 |
+
|