asuhag commited on
Commit
fddc714
1 Parent(s): d81ed4f

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -22
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 = client.chat.completions.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 time are avaialble, 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 time are detected. "
22
- },
23
- {
24
- "role": "user",
25
- "content": f"{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 '))
 
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 '))