ghengx commited on
Commit
633086f
·
1 Parent(s): 282ba8f
Files changed (2) hide show
  1. app.py +58 -0
  2. requirements.txt +60 -0
app.py ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ # login(token = os.environ['HF_TOKEN'])
9
+
10
+ # repo = Repository(
11
+ # local_dir="function",
12
+ # repo_type="dataset",
13
+ # clone_from=os.environ['DATASET'],
14
+ # token=True
15
+ # )
16
+ # repo.git_pull()
17
+
18
+ import streamlit as st
19
+ import time
20
+ from agent_function.agent import answer,check_password
21
+
22
+ st.title("Tynox Chatbot")
23
+
24
+ if "messages" not in st.session_state:
25
+ st.session_state.messages = []
26
+
27
+ if "auth" not in st.session_state:
28
+ st.session_state.auth = False
29
+
30
+ if st.session_state.auth:
31
+ for message in st.session_state.messages:
32
+ with st.chat_message(message["role"]):
33
+ st.markdown(message["content"])
34
+
35
+ if prompt := st.chat_input("What is up?"):
36
+ st.chat_message("user").markdown(prompt)
37
+ st.session_state.messages.append({"role": "user", "content": prompt})
38
+ result=answer(prompt)
39
+ assistant_message = st.chat_message("assistant")
40
+ placeholder = assistant_message.empty()
41
+
42
+ typed_response = ""
43
+ for chunk in result:
44
+ typed_response += chunk
45
+ placeholder.markdown(typed_response)
46
+ time.sleep(0.01)
47
+
48
+ st.session_state.messages.append({"role": "assistant", "content": typed_response})
49
+ else:
50
+ password = st.text_input("Password")
51
+ if password:
52
+ valid = check_password(password)
53
+ if valid:
54
+ st.session_state.auth = valid
55
+ st.rerun()
56
+ else:
57
+ st.error('Incorrect password',icon='❌')
58
+
requirements.txt ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ altair==5.5.0
2
+ annotated-types==0.7.0
3
+ anyio==4.8.0
4
+ attrs==25.1.0
5
+ blinker==1.9.0
6
+ cachetools==5.5.1
7
+ certifi==2025.1.31
8
+ charset-normalizer==3.4.1
9
+ click==8.1.8
10
+ distro==1.9.0
11
+ filelock==3.17.0
12
+ fsspec==2025.2.0
13
+ gitdb==4.0.12
14
+ GitPython==3.1.44
15
+ h11==0.14.0
16
+ httpcore==1.0.7
17
+ httpx==0.28.1
18
+ huggingface-hub==0.28.1
19
+ idna==3.10
20
+ Jinja2==3.1.5
21
+ jiter==0.8.2
22
+ jsonschema==4.23.0
23
+ jsonschema-specifications==2024.10.1
24
+ markdown-it-py==3.0.0
25
+ MarkupSafe==3.0.2
26
+ mdurl==0.1.2
27
+ narwhals==1.25.0
28
+ numpy==2.2.2
29
+ openai==1.61.0
30
+ packaging==24.2
31
+ pandas==2.2.3
32
+ pandasql==0.7.3
33
+ pillow==11.1.0
34
+ protobuf==5.29.3
35
+ pyarrow==19.0.0
36
+ pydantic==2.10.6
37
+ pydantic_core==2.27.2
38
+ pydeck==0.9.1
39
+ Pygments==2.19.1
40
+ python-dateutil==2.9.0.post0
41
+ python-dotenv==1.0.1
42
+ pytz==2025.1
43
+ PyYAML==6.0.2
44
+ referencing==0.36.2
45
+ requests==2.32.3
46
+ rich==13.9.4
47
+ rpds-py==0.22.3
48
+ six==1.17.0
49
+ smmap==5.0.2
50
+ sniffio==1.3.1
51
+ SQLAlchemy==2.0.37
52
+ streamlit==1.41.1
53
+ tabulate==0.9.0
54
+ tenacity==9.0.0
55
+ toml==0.10.2
56
+ tornado==6.4.2
57
+ tqdm==4.67.1
58
+ typing_extensions==4.12.2
59
+ tzdata==2025.1
60
+ urllib3==2.3.0