cjzhi98 commited on
Commit
411a726
1 Parent(s): 694213c

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +37 -0
  2. dataset_loader.py +18 -0
  3. requirements.txt +6 -0
app.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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("cytron_recommendation_chatbot_data"):
9
+ load_dataset()
10
+
11
+ from cytron_recommendation_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="Cytron Chatbot",
27
+ fn=respond_to_input,
28
+ inputs="text",
29
+ outputs="text",
30
+ description=(
31
+ "This is a chatbot for Cytron Technologies. Ask me anything related to electronics for projects!\n\n"
32
+ "Note: This chatbot does not implement memory module, ask specific questions and don't expect it to remember previous conversation.\n"
33
+ ),
34
+ )
35
+
36
+ # Launch the app
37
+ 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="cytron_recommendation_chatbot_data",
14
+ repo_type="dataset",
15
+ clone_from="cjzhi98/cytron_recommendation_chatbot",
16
+ token=True,
17
+ )
18
+ repo.git_pull()
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ openai
2
+ python-dotenv
3
+ numpy
4
+ boto3
5
+ gradio
6
+ prettyprint