asuhag commited on
Commit
a5cf5f1
1 Parent(s): faf2b7e

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import openai
2
+ import gradio as gr
3
+ from openai import OpenAI
4
+ import os
5
+
6
+ openai_api_key = os.getenv("OPENAI_API_KEY")
7
+
8
+ client = OpenAI(api_key=openai_api_key)
9
+
10
+ def predict(input,_):
11
+ response = client.chat.completions.create(
12
+ model="gpt-3.5-turbo",
13
+ messages=[
14
+ {
15
+ "role": "system",
16
+ "content": "A text will be passed to you. List all dates and time from the text. Output the date and time in the format YYYY-MM-DD hour:minutes. "
17
+ },
18
+ {
19
+ "role": "user",
20
+ "content": f"{input}"
21
+ }
22
+ ],
23
+ temperature=0,
24
+ max_tokens=10,
25
+ top_p=1
26
+ )
27
+ return response.choices[0].message.content
28
+
29
+
30
+ #print(predict('Are you available for a meeting on 13th Feb at 2 pm '))
31
+
32
+ gr.ChatInterface(predict).launch()