Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
@@ -8,28 +8,28 @@ openai_api_key = os.getenv("OPENAI_API_KEY")
|
|
8 |
|
9 |
client = OpenAI(api_key=openai_api_key)
|
10 |
|
11 |
-
def predict(input,_):
|
12 |
-
response =
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
)
|
32 |
-
return response.choices[0].message
|
33 |
|
34 |
|
35 |
#print(predict('Are you available for a meeting on 13th Feb at 2 pm '))
|
|
|
8 |
|
9 |
client = OpenAI(api_key=openai_api_key)
|
10 |
|
11 |
+
def predict(input, _):
|
12 |
+
response = openai.ChatCompletion.create(
|
13 |
+
model="gpt-3.5-turbo",
|
14 |
+
messages=[
|
15 |
+
{
|
16 |
+
"role": "system",
|
17 |
+
"content": f"""Today's date and time is {datetime.now()}. A text will be passed to you. Extract date and time from it. Output the date and time in the format YYYY-MM-DD hour:minutes.
|
18 |
+
|
19 |
+
If multiple date times are available, extract all dates and time from the text as a list data type and output them in the format YYYY-MM-DD hour:minutes.
|
20 |
+
|
21 |
+
Return an empty string if no date times are detected."""
|
22 |
+
},
|
23 |
+
{
|
24 |
+
"role": "user",
|
25 |
+
"content": input
|
26 |
+
}
|
27 |
+
],
|
28 |
+
temperature=0,
|
29 |
+
max_tokens=10,
|
30 |
+
top_p=1
|
31 |
+
)
|
32 |
+
return response.choices[0].message["content"]
|
33 |
|
34 |
|
35 |
#print(predict('Are you available for a meeting on 13th Feb at 2 pm '))
|