Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- nlp_service_mock.py +32 -0
- requirements.txt +70 -0
nlp_service_mock.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()
|
requirements.txt
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
aiofiles==23.2.1
|
2 |
+
altair==5.2.0
|
3 |
+
annotated-types==0.6.0
|
4 |
+
anyio==4.2.0
|
5 |
+
attrs==23.2.0
|
6 |
+
certifi==2024.2.2
|
7 |
+
charset-normalizer==3.3.2
|
8 |
+
click==8.1.7
|
9 |
+
colorama==0.4.6
|
10 |
+
contourpy==1.1.1
|
11 |
+
cycler==0.12.1
|
12 |
+
distro==1.9.0
|
13 |
+
exceptiongroup==1.2.0
|
14 |
+
fastapi==0.109.2
|
15 |
+
ffmpy==0.3.1
|
16 |
+
filelock==3.13.1
|
17 |
+
fonttools==4.48.1
|
18 |
+
fsspec==2024.2.0
|
19 |
+
gradio==4.17.0
|
20 |
+
gradio_client==0.9.0
|
21 |
+
h11==0.14.0
|
22 |
+
httpcore==1.0.2
|
23 |
+
httpx==0.26.0
|
24 |
+
huggingface-hub==0.20.3
|
25 |
+
idna==3.6
|
26 |
+
importlib-resources==6.1.1
|
27 |
+
Jinja2==3.1.3
|
28 |
+
jsonschema==4.21.1
|
29 |
+
jsonschema-specifications==2023.12.1
|
30 |
+
kiwisolver==1.4.5
|
31 |
+
markdown-it-py==3.0.0
|
32 |
+
MarkupSafe==2.1.5
|
33 |
+
matplotlib==3.7.4
|
34 |
+
mdurl==0.1.2
|
35 |
+
numpy==1.24.4
|
36 |
+
openai==1.11.1
|
37 |
+
orjson==3.9.13
|
38 |
+
packaging==23.2
|
39 |
+
pandas==2.0.3
|
40 |
+
pillow==10.2.0
|
41 |
+
pkgutil_resolve_name==1.3.10
|
42 |
+
pydantic==2.6.1
|
43 |
+
pydantic_core==2.16.2
|
44 |
+
pydub==0.25.1
|
45 |
+
Pygments==2.17.2
|
46 |
+
pyparsing==3.1.1
|
47 |
+
python-dateutil==2.8.2
|
48 |
+
python-multipart==0.0.7
|
49 |
+
pytz==2024.1
|
50 |
+
PyYAML==6.0.1
|
51 |
+
referencing==0.33.0
|
52 |
+
requests==2.31.0
|
53 |
+
rich==13.7.0
|
54 |
+
rpds-py==0.17.1
|
55 |
+
ruff==0.2.1
|
56 |
+
semantic-version==2.10.0
|
57 |
+
shellingham==1.5.4
|
58 |
+
six==1.16.0
|
59 |
+
sniffio==1.3.0
|
60 |
+
starlette==0.36.3
|
61 |
+
tomlkit==0.12.0
|
62 |
+
toolz==0.12.1
|
63 |
+
tqdm==4.66.1
|
64 |
+
typer==0.9.0
|
65 |
+
typing_extensions==4.9.0
|
66 |
+
tzdata==2023.4
|
67 |
+
urllib3==2.2.0
|
68 |
+
uvicorn==0.27.0.post1
|
69 |
+
websockets==11.0.3
|
70 |
+
zipp==3.17.0
|