Spaces:
Runtime error
Runtime error
Upload 3 files
Browse files- app.py +30 -0
- dataset_loader.py +18 -0
- requirements.txt +5 -0
app.py
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import os
|
3 |
+
from dataset_loader import load_dataset
|
4 |
+
from dotenv import load_dotenv
|
5 |
+
|
6 |
+
load_dotenv()
|
7 |
+
|
8 |
+
if not os.path.isdir("low_partners_chatbot_data"):
|
9 |
+
load_dataset()
|
10 |
+
|
11 |
+
from low_partners_chatbot_data.utils import run_conversation
|
12 |
+
|
13 |
+
|
14 |
+
# Initialize the conversation
|
15 |
+
conversation = []
|
16 |
+
|
17 |
+
|
18 |
+
def respond_to_input(user_input):
|
19 |
+
response = run_conversation(user_input)
|
20 |
+
|
21 |
+
return response
|
22 |
+
|
23 |
+
|
24 |
+
# Create the Gradio interface
|
25 |
+
iface = gr.Interface(
|
26 |
+
title="KLSE chatbot", fn=respond_to_input, inputs="text", outputs="text"
|
27 |
+
)
|
28 |
+
|
29 |
+
# Launch the app
|
30 |
+
iface.launch()
|
dataset_loader.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from huggingface_hub import Repository
|
2 |
+
from huggingface_hub import login
|
3 |
+
import os
|
4 |
+
from dotenv import load_dotenv
|
5 |
+
|
6 |
+
load_dotenv()
|
7 |
+
|
8 |
+
|
9 |
+
def load_dataset():
|
10 |
+
login(token=os.getenv("HUB_TOKEN"))
|
11 |
+
|
12 |
+
repo = Repository(
|
13 |
+
local_dir="low_partners_chatbot_data",
|
14 |
+
repo_type="dataset",
|
15 |
+
clone_from="cjzhi98/low-partners-chatbot",
|
16 |
+
token=True,
|
17 |
+
)
|
18 |
+
repo.git_pull()
|
requirements.txt
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
openai
|
2 |
+
python-dotenv
|
3 |
+
pandas
|
4 |
+
gradio
|
5 |
+
huggingface_hub
|