cjzhi98 commited on
Commit
e72da8a
·
verified ·
1 Parent(s): 49f23d9

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +29 -0
  2. dataset_loader.py +20 -0
  3. requirements.txt +9 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import os
3
+ from dataset_loader import load_dataset
4
+
5
+ if not os.path.isdir("klse_cahtbot_data"):
6
+ load_dataset()
7
+
8
+ from klse_cahtbot_data.conversation import run_conversation
9
+
10
+
11
+ # Initialize the conversation
12
+ conversation = []
13
+
14
+
15
+ def respond_to_input(user_input):
16
+ response = run_conversation(user_input)
17
+
18
+ return response
19
+
20
+
21
+ # Create the Gradio interface
22
+ iface = gr.Interface(
23
+ title="KLSE chatbot", fn=respond_to_input, inputs="text", outputs="text"
24
+ )
25
+
26
+ iface.queue(default_concurrency_limit=None)
27
+
28
+ # Launch the app
29
+ iface.launch()
dataset_loader.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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="klse_cahtbot_data",
14
+ repo_type="dataset",
15
+ clone_from="dahreply/klse-bot",
16
+ git_user=os.getenv("GIT_USER"),
17
+ git_email=os.getenv("GIT_EMAIL"),
18
+ token=True,
19
+ )
20
+ repo.git_pull()
requirements.txt ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ openai
2
+ python_dotenv
3
+ requests
4
+ beautifulsoup4
5
+ fuzzywuzzy
6
+ python-Levenshtein
7
+ gradio
8
+ huggingface_hub
9
+ icecream