Spaces:
Runtime error
Runtime error
Commit
·
e1653e4
1
Parent(s):
eedcbe4
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,10 +8,13 @@ api_key = "YOUR_API_KEY"
|
|
| 8 |
openai.api_key = api_key
|
| 9 |
|
| 10 |
# Define a function to generate responses using GPT-3.5 Turbo
|
| 11 |
-
def generate_response(
|
| 12 |
response = openai.Completion.create(
|
| 13 |
model="gpt-3.5-turbo", # Use GPT-3.5 Turbo engine
|
| 14 |
-
prompt=
|
|
|
|
|
|
|
|
|
|
| 15 |
max_tokens=50, # You can adjust this to limit the response length
|
| 16 |
)
|
| 17 |
return response.choices[0].text
|
|
|
|
| 8 |
openai.api_key = api_key
|
| 9 |
|
| 10 |
# Define a function to generate responses using GPT-3.5 Turbo
|
| 11 |
+
def generate_response(user_prompt):
|
| 12 |
response = openai.Completion.create(
|
| 13 |
model="gpt-3.5-turbo", # Use GPT-3.5 Turbo engine
|
| 14 |
+
prompt= f'''I will give you a question and you detect which category does this question belong to. It should be from these categories -
|
| 15 |
+
physical activity, sleep, nutrition and preventive care. Make sure you just reply with response in json format "category":"[sleep,nutrition]".
|
| 16 |
+
Note that single question may belong to multiple categories. Dont add any opening lines just reply with json response.
|
| 17 |
+
Question: {user_prompt}''',
|
| 18 |
max_tokens=50, # You can adjust this to limit the response length
|
| 19 |
)
|
| 20 |
return response.choices[0].text
|