Spaces:
Sleeping
Sleeping
File size: 1,178 Bytes
a5cf5f1 36e6577 a5cf5f1 36e6577 fddc714 36e6577 9c41bcd fddc714 36e6577 fddc714 f1c4868 a5cf5f1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
import openai
import gradio as gr
from openai import OpenAI
import os
from datetime import datetime, date
import calendar
openai_api_key = os.getenv("OPENAI_API_KEY")
client = OpenAI(api_key=openai_api_key)
def predict(input, _):
response = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{
"role": "system",
"content": f"""Today's day, date and time is {calendar.day_name[date.today().weekday()], 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.
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.
Return an empty string if no date times are detected."""
},
{
"role": "user",
"content": input
}
],
temperature=0,
max_tokens=10,
top_p=1
)
return response.choices[0].message.content
#print(predict('Are you available for a meeting on 13th Feb at 2 pm '))
gr.ChatInterface(predict).launch() |