FloydTan1987 commited on
Commit
b895330
1 Parent(s): bc848f7

Upload 5 files

Browse files

Push it to the main app

Files changed (5) hide show
  1. .gitignore +160 -0
  2. agent.JPG +0 -0
  3. cx.JPG +0 -0
  4. livechat.py +42 -0
  5. requirements.tx +110 -0
.gitignore ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # poetry
98
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102
+ #poetry.lock
103
+
104
+ # pdm
105
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106
+ #pdm.lock
107
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108
+ # in version control.
109
+ # https://pdm.fming.dev/#use-with-ide
110
+ .pdm.toml
111
+
112
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
113
+ __pypackages__/
114
+
115
+ # Celery stuff
116
+ celerybeat-schedule
117
+ celerybeat.pid
118
+
119
+ # SageMath parsed files
120
+ *.sage.py
121
+
122
+ # Environments
123
+ .env
124
+ .venv
125
+ env/
126
+ venv/
127
+ ENV/
128
+ env.bak/
129
+ venv.bak/
130
+
131
+ # Spyder project settings
132
+ .spyderproject
133
+ .spyproject
134
+
135
+ # Rope project settings
136
+ .ropeproject
137
+
138
+ # mkdocs documentation
139
+ /site
140
+
141
+ # mypy
142
+ .mypy_cache/
143
+ .dmypy.json
144
+ dmypy.json
145
+
146
+ # Pyre type checker
147
+ .pyre/
148
+
149
+ # pytype static type analyzer
150
+ .pytype/
151
+
152
+ # Cython debug symbols
153
+ cython_debug/
154
+
155
+ # PyCharm
156
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
157
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
158
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
159
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
160
+ #.idea/
agent.JPG ADDED
cx.JPG ADDED
livechat.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import ollama
3
+
4
+ def format_history(msg: str, history: list[list[str, str]], system_prompt: str):
5
+ chat_history = [{"role": "system", "content":system_prompt}]
6
+ for query, response in history:
7
+ chat_history.append({"role": "user", "content": query})
8
+ chat_history.append({"role": "assistant", "content": response})
9
+ chat_history.append({"role": "user", "content": msg})
10
+ return chat_history
11
+
12
+ def generate_response(msg: str, history: list[list[str, str]], system_prompt: str):
13
+ chat_history = format_history(msg, history, system_prompt)
14
+ response = ollama.chat(model='llama2', stream=True, messages=chat_history)
15
+ message = ""
16
+ for partial_resp in response:
17
+ token = partial_resp["message"]["content"]
18
+ message += token
19
+ yield message
20
+
21
+ chatbot = gr.ChatInterface(
22
+ generate_response,
23
+ chatbot=gr.Chatbot(
24
+ avatar_images=["cx.jpg", "agent.jpg"],
25
+ height="64vh"
26
+ ),
27
+ additional_inputs=[
28
+ gr.Textbox(
29
+ "Behave as if you are order placer agent.",
30
+ label="System Prompt"
31
+ )
32
+ ],
33
+ title="Door Treats",
34
+ description="Please ask any questions you may have about your order.🤔",
35
+ theme="soft",
36
+ submit_btn="⬅ Send",
37
+ retry_btn="🔄 Regenerate Response",
38
+ undo_btn="↩ Delete Previous",
39
+ clear_btn="🗑️ Clear Chat"
40
+ )
41
+
42
+ chatbot.launch()
requirements.tx ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file may be used to create an environment using:
2
+ # $ conda create --name <env> --file <this file>
3
+ # platform: win-64
4
+ anaconda-anon-usage=0.4.4=py312hfc23b7f_100
5
+ archspec=0.2.3=pyhd3eb1b0_0
6
+ asttokens=2.4.1=pyhd8ed1ab_0
7
+ boltons=23.0.0=py312haa95532_0
8
+ brotli-python=1.0.9=py312hd77b12b_8
9
+ bzip2=1.0.8=h2bbff1b_6
10
+ ca-certificates=2024.6.2=h56e8100_0
11
+ certifi=2024.6.2=pyhd8ed1ab_0
12
+ cffi=1.16.0=py312h2bbff1b_1
13
+ charset-normalizer=2.0.4=pyhd3eb1b0_0
14
+ colorama=0.4.6=py312haa95532_0
15
+ comm=0.2.2=pyhd8ed1ab_0
16
+ conda=24.5.0=py312h2e8e312_0
17
+ conda-content-trust=0.2.0=py312haa95532_1
18
+ conda-libmamba-solver=24.1.0=pyhd3eb1b0_0
19
+ conda-package-handling=2.3.0=py312haa95532_0
20
+ conda-package-streaming=0.10.0=py312haa95532_0
21
+ console_shortcut_miniconda=0.1.1=haa95532_2
22
+ cryptography=42.0.5=py312h89fc84f_1
23
+ debugpy=1.8.2=py312h275cf98_0
24
+ decorator=5.1.1=pyhd8ed1ab_0
25
+ distro=1.9.0=py312haa95532_0
26
+ exceptiongroup=1.2.0=pyhd8ed1ab_2
27
+ executing=2.0.1=pyhd8ed1ab_0
28
+ expat=2.6.2=hd77b12b_0
29
+ fmt=9.1.0=h6d14046_1
30
+ frozendict=2.4.2=py312haa95532_0
31
+ idna=3.7=py312haa95532_0
32
+ importlib-metadata=8.0.0=pyha770c72_0
33
+ importlib_metadata=8.0.0=hd8ed1ab_0
34
+ ipykernel=6.29.5=pyh4bbf305_0
35
+ ipython=8.26.0=pyh7428d3b_0
36
+ jedi=0.19.1=pyhd8ed1ab_0
37
+ jsonpatch=1.33=py312haa95532_1
38
+ jsonpointer=2.1=pyhd3eb1b0_0
39
+ jupyter_client=8.6.2=pyhd8ed1ab_0
40
+ jupyter_core=5.7.2=py312h2e8e312_0
41
+ krb5=1.21.3=hdf4eb48_0
42
+ libarchive=3.6.2=hb62f4d4_3
43
+ libcurl=8.7.1=h86230a5_0
44
+ libexpat=2.6.2=h63175ca_0
45
+ libffi=3.4.4=hd77b12b_1
46
+ libiconv=1.16=h2bbff1b_3
47
+ libmamba=1.5.8=h99b1521_2
48
+ libmambapy=1.5.8=py312h77c03ed_2
49
+ libsodium=1.0.18=h8d14728_1
50
+ libsolv=0.7.24=h23ce68f_1
51
+ libsqlite=3.46.0=h2466b09_0
52
+ libssh2=1.11.0=h291bd65_0
53
+ libxml2=2.10.4=h0ad7f3c_2
54
+ libzlib=1.2.13=h2466b09_6
55
+ lz4-c=1.9.4=h2bbff1b_1
56
+ matplotlib-inline=0.1.7=pyhd8ed1ab_0
57
+ menuinst=2.1.1=py312h5da7b33_0
58
+ nest-asyncio=1.6.0=pyhd8ed1ab_0
59
+ openssl=3.3.1=h2466b09_1
60
+ packaging=23.2=py312haa95532_0
61
+ parso=0.8.4=pyhd8ed1ab_0
62
+ pcre2=10.42=h0ff8eda_1
63
+ pickleshare=0.7.5=py_1003
64
+ pip=24.0=py312haa95532_0
65
+ platformdirs=3.10.0=py312haa95532_0
66
+ pluggy=1.0.0=py312haa95532_1
67
+ powershell_shortcut_miniconda=0.0.1=haa95532_2
68
+ prompt-toolkit=3.0.47=pyha770c72_0
69
+ psutil=6.0.0=py312h4389bb4_0
70
+ pure_eval=0.2.2=pyhd8ed1ab_0
71
+ pybind11-abi=5=hd3eb1b0_0
72
+ pycosat=0.6.6=py312h2bbff1b_1
73
+ pycparser=2.21=pyhd3eb1b0_0
74
+ pygments=2.18.0=pyhd8ed1ab_0
75
+ pysocks=1.7.1=py312haa95532_0
76
+ python=3.12.3=h2628c8c_0_cpython
77
+ python-dateutil=2.9.0=pyhd8ed1ab_0
78
+ python_abi=3.12=4_cp312
79
+ pywin32=306=py312h53d5487_2
80
+ pyzmq=26.0.3=py312hd7027bb_0
81
+ reproc=14.2.4=hd77b12b_2
82
+ reproc-cpp=14.2.4=hd77b12b_2
83
+ requests=2.32.2=py312haa95532_0
84
+ ruamel.yaml=0.17.21=py312h2bbff1b_0
85
+ setuptools=69.5.1=py312haa95532_0
86
+ six=1.16.0=pyh6c4a22f_0
87
+ sqlite=3.45.3=h2bbff1b_0
88
+ stack_data=0.6.2=pyhd8ed1ab_0
89
+ tk=8.6.14=h0416ee5_0
90
+ tornado=6.4.1=py312h4389bb4_0
91
+ tqdm=4.66.4=py312hfc267ef_0
92
+ traitlets=5.14.3=pyhd8ed1ab_0
93
+ truststore=0.8.0=py312haa95532_0
94
+ typing_extensions=4.12.2=pyha770c72_0
95
+ tzdata=2024a=h04d1e81_0
96
+ ucrt=10.0.22621.0=h57928b3_0
97
+ urllib3=2.2.2=py312haa95532_0
98
+ vc=14.2=h2eaa2aa_1
99
+ vc14_runtime=14.40.33810=ha82c5b3_20
100
+ vs2015_runtime=14.40.33810=h3bf8584_20
101
+ wcwidth=0.2.13=pyhd8ed1ab_0
102
+ wheel=0.43.0=py312haa95532_0
103
+ win_inet_pton=1.1.0=py312haa95532_0
104
+ xz=5.4.6=h8cc25b3_1
105
+ yaml-cpp=0.8.0=hd77b12b_1
106
+ zeromq=4.3.5=he1f189c_4
107
+ zipp=3.19.2=pyhd8ed1ab_0
108
+ zlib=1.2.13=h2466b09_6
109
+ zstandard=0.22.0=py312h3469f8a_0
110
+ zstd=1.5.5=hd43e919_2