Spaces:
Runtime error
Runtime error
briankchan
commited on
Commit
•
8733154
1
Parent(s):
17fa72f
Add app
Browse files- .chainlit/config.toml +63 -0
- .gitignore +285 -0
- Dockerfile +9 -0
- app.py +33 -0
- chain.py +69 -0
- chainlit.md +14 -0
- requirements.txt +1 -0
.chainlit/config.toml
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[project]
|
2 |
+
# If true (default), the app will be available to anonymous users.
|
3 |
+
# If false, users will need to authenticate and be part of the project to use the app.
|
4 |
+
public = true
|
5 |
+
|
6 |
+
# The project ID (found on https://cloud.chainlit.io).
|
7 |
+
# The project ID is required when public is set to false or when using the cloud database.
|
8 |
+
#id = ""
|
9 |
+
|
10 |
+
# Uncomment if you want to persist the chats.
|
11 |
+
# local will create a database in your .chainlit directory (requires node.js installed).
|
12 |
+
# cloud will use the Chainlit cloud database.
|
13 |
+
# custom will load use your custom client.
|
14 |
+
database = "local"
|
15 |
+
|
16 |
+
# Whether to enable telemetry (default: true). No personal data is collected.
|
17 |
+
enable_telemetry = true
|
18 |
+
|
19 |
+
# List of environment variables to be provided by each user to use the app.
|
20 |
+
user_env = []
|
21 |
+
|
22 |
+
# Duration (in seconds) during which the session is saved when the connection is lost
|
23 |
+
session_timeout = 3600
|
24 |
+
|
25 |
+
[UI]
|
26 |
+
# Name of the app and chatbot.
|
27 |
+
name = "Chatbot"
|
28 |
+
|
29 |
+
# Description of the app and chatbot. This is used for HTML tags.
|
30 |
+
# description = ""
|
31 |
+
|
32 |
+
# The default value for the expand messages settings.
|
33 |
+
default_expand_messages = false
|
34 |
+
|
35 |
+
# Hide the chain of thought details from the user in the UI.
|
36 |
+
hide_cot = false
|
37 |
+
|
38 |
+
# Link to your github repo. This will add a github button in the UI's header.
|
39 |
+
# github = ""
|
40 |
+
|
41 |
+
# Override default MUI light theme. (Check theme.ts)
|
42 |
+
[UI.theme.light]
|
43 |
+
#background = "#FAFAFA"
|
44 |
+
#paper = "#FFFFFF"
|
45 |
+
|
46 |
+
[UI.theme.light.primary]
|
47 |
+
#main = "#F80061"
|
48 |
+
#dark = "#980039"
|
49 |
+
#light = "#FFE7EB"
|
50 |
+
|
51 |
+
# Override default MUI dark theme. (Check theme.ts)
|
52 |
+
[UI.theme.dark]
|
53 |
+
#background = "#FAFAFA"
|
54 |
+
#paper = "#FFFFFF"
|
55 |
+
|
56 |
+
[UI.theme.dark.primary]
|
57 |
+
#main = "#F80061"
|
58 |
+
#dark = "#980039"
|
59 |
+
#light = "#FFE7EB"
|
60 |
+
|
61 |
+
|
62 |
+
[meta]
|
63 |
+
generated_by = "0.6.2"
|
.gitignore
ADDED
@@ -0,0 +1,285 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.chainlit/chat.db
|
2 |
+
|
3 |
+
# Created by https://www.toptal.com/developers/gitignore/api/python,intellij+all,visualstudiocode
|
4 |
+
# Edit at https://www.toptal.com/developers/gitignore?templates=python,intellij+all,visualstudiocode
|
5 |
+
|
6 |
+
### Intellij+all ###
|
7 |
+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
8 |
+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
9 |
+
|
10 |
+
# User-specific stuff
|
11 |
+
.idea/**/workspace.xml
|
12 |
+
.idea/**/tasks.xml
|
13 |
+
.idea/**/usage.statistics.xml
|
14 |
+
.idea/**/dictionaries
|
15 |
+
.idea/**/shelf
|
16 |
+
|
17 |
+
# AWS User-specific
|
18 |
+
.idea/**/aws.xml
|
19 |
+
|
20 |
+
# Generated files
|
21 |
+
.idea/**/contentModel.xml
|
22 |
+
|
23 |
+
# Sensitive or high-churn files
|
24 |
+
.idea/**/dataSources/
|
25 |
+
.idea/**/dataSources.ids
|
26 |
+
.idea/**/dataSources.local.xml
|
27 |
+
.idea/**/sqlDataSources.xml
|
28 |
+
.idea/**/dynamic.xml
|
29 |
+
.idea/**/uiDesigner.xml
|
30 |
+
.idea/**/dbnavigator.xml
|
31 |
+
|
32 |
+
# Gradle
|
33 |
+
.idea/**/gradle.xml
|
34 |
+
.idea/**/libraries
|
35 |
+
|
36 |
+
# Gradle and Maven with auto-import
|
37 |
+
# When using Gradle or Maven with auto-import, you should exclude module files,
|
38 |
+
# since they will be recreated, and may cause churn. Uncomment if using
|
39 |
+
# auto-import.
|
40 |
+
# .idea/artifacts
|
41 |
+
# .idea/compiler.xml
|
42 |
+
# .idea/jarRepositories.xml
|
43 |
+
# .idea/modules.xml
|
44 |
+
# .idea/*.iml
|
45 |
+
# .idea/modules
|
46 |
+
# *.iml
|
47 |
+
# *.ipr
|
48 |
+
|
49 |
+
# CMake
|
50 |
+
cmake-build-*/
|
51 |
+
|
52 |
+
# Mongo Explorer plugin
|
53 |
+
.idea/**/mongoSettings.xml
|
54 |
+
|
55 |
+
# File-based project format
|
56 |
+
*.iws
|
57 |
+
|
58 |
+
# IntelliJ
|
59 |
+
out/
|
60 |
+
|
61 |
+
# mpeltonen/sbt-idea plugin
|
62 |
+
.idea_modules/
|
63 |
+
|
64 |
+
# JIRA plugin
|
65 |
+
atlassian-ide-plugin.xml
|
66 |
+
|
67 |
+
# Cursive Clojure plugin
|
68 |
+
.idea/replstate.xml
|
69 |
+
|
70 |
+
# SonarLint plugin
|
71 |
+
.idea/sonarlint/
|
72 |
+
|
73 |
+
# Crashlytics plugin (for Android Studio and IntelliJ)
|
74 |
+
com_crashlytics_export_strings.xml
|
75 |
+
crashlytics.properties
|
76 |
+
crashlytics-build.properties
|
77 |
+
fabric.properties
|
78 |
+
|
79 |
+
# Editor-based Rest Client
|
80 |
+
.idea/httpRequests
|
81 |
+
|
82 |
+
# Android studio 3.1+ serialized cache file
|
83 |
+
.idea/caches/build_file_checksums.ser
|
84 |
+
|
85 |
+
### Intellij+all Patch ###
|
86 |
+
# Ignore everything but code style settings and run configurations
|
87 |
+
# that are supposed to be shared within teams.
|
88 |
+
|
89 |
+
.idea/*
|
90 |
+
|
91 |
+
!.idea/codeStyles
|
92 |
+
!.idea/runConfigurations
|
93 |
+
|
94 |
+
### Python ###
|
95 |
+
# Byte-compiled / optimized / DLL files
|
96 |
+
__pycache__/
|
97 |
+
*.py[cod]
|
98 |
+
*$py.class
|
99 |
+
|
100 |
+
# C extensions
|
101 |
+
*.so
|
102 |
+
|
103 |
+
# Distribution / packaging
|
104 |
+
.Python
|
105 |
+
build/
|
106 |
+
develop-eggs/
|
107 |
+
dist/
|
108 |
+
downloads/
|
109 |
+
eggs/
|
110 |
+
.eggs/
|
111 |
+
lib/
|
112 |
+
lib64/
|
113 |
+
parts/
|
114 |
+
sdist/
|
115 |
+
var/
|
116 |
+
wheels/
|
117 |
+
share/python-wheels/
|
118 |
+
*.egg-info/
|
119 |
+
.installed.cfg
|
120 |
+
*.egg
|
121 |
+
MANIFEST
|
122 |
+
|
123 |
+
# PyInstaller
|
124 |
+
# Usually these files are written by a python script from a template
|
125 |
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
126 |
+
*.manifest
|
127 |
+
*.spec
|
128 |
+
|
129 |
+
# Installer logs
|
130 |
+
pip-log.txt
|
131 |
+
pip-delete-this-directory.txt
|
132 |
+
|
133 |
+
# Unit test / coverage reports
|
134 |
+
htmlcov/
|
135 |
+
.tox/
|
136 |
+
.nox/
|
137 |
+
.coverage
|
138 |
+
.coverage.*
|
139 |
+
.cache
|
140 |
+
nosetests.xml
|
141 |
+
coverage.xml
|
142 |
+
*.cover
|
143 |
+
*.py,cover
|
144 |
+
.hypothesis/
|
145 |
+
.pytest_cache/
|
146 |
+
cover/
|
147 |
+
|
148 |
+
# Translations
|
149 |
+
*.mo
|
150 |
+
*.pot
|
151 |
+
|
152 |
+
# Django stuff:
|
153 |
+
*.log
|
154 |
+
local_settings.py
|
155 |
+
db.sqlite3
|
156 |
+
db.sqlite3-journal
|
157 |
+
|
158 |
+
# Flask stuff:
|
159 |
+
instance/
|
160 |
+
.webassets-cache
|
161 |
+
|
162 |
+
# Scrapy stuff:
|
163 |
+
.scrapy
|
164 |
+
|
165 |
+
# Sphinx documentation
|
166 |
+
docs/_build/
|
167 |
+
|
168 |
+
# PyBuilder
|
169 |
+
.pybuilder/
|
170 |
+
target/
|
171 |
+
|
172 |
+
# Jupyter Notebook
|
173 |
+
.ipynb_checkpoints
|
174 |
+
|
175 |
+
# IPython
|
176 |
+
profile_default/
|
177 |
+
ipython_config.py
|
178 |
+
|
179 |
+
# pyenv
|
180 |
+
# For a library or package, you might want to ignore these files since the code is
|
181 |
+
# intended to run in multiple environments; otherwise, check them in:
|
182 |
+
# .python-version
|
183 |
+
|
184 |
+
# pipenv
|
185 |
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
186 |
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
187 |
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
188 |
+
# install all needed dependencies.
|
189 |
+
#Pipfile.lock
|
190 |
+
|
191 |
+
# poetry
|
192 |
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
193 |
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
194 |
+
# commonly ignored for libraries.
|
195 |
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
196 |
+
#poetry.lock
|
197 |
+
|
198 |
+
# pdm
|
199 |
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
200 |
+
#pdm.lock
|
201 |
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
202 |
+
# in version control.
|
203 |
+
# https://pdm.fming.dev/#use-with-ide
|
204 |
+
.pdm.toml
|
205 |
+
|
206 |
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
207 |
+
__pypackages__/
|
208 |
+
|
209 |
+
# Celery stuff
|
210 |
+
celerybeat-schedule
|
211 |
+
celerybeat.pid
|
212 |
+
|
213 |
+
# SageMath parsed files
|
214 |
+
*.sage.py
|
215 |
+
|
216 |
+
# Environments
|
217 |
+
.env
|
218 |
+
.venv
|
219 |
+
env/
|
220 |
+
venv/
|
221 |
+
ENV/
|
222 |
+
env.bak/
|
223 |
+
venv.bak/
|
224 |
+
|
225 |
+
# Spyder project settings
|
226 |
+
.spyderproject
|
227 |
+
.spyproject
|
228 |
+
|
229 |
+
# Rope project settings
|
230 |
+
.ropeproject
|
231 |
+
|
232 |
+
# mkdocs documentation
|
233 |
+
/site
|
234 |
+
|
235 |
+
# mypy
|
236 |
+
.mypy_cache/
|
237 |
+
.dmypy.json
|
238 |
+
dmypy.json
|
239 |
+
|
240 |
+
# Pyre type checker
|
241 |
+
.pyre/
|
242 |
+
|
243 |
+
# pytype static type analyzer
|
244 |
+
.pytype/
|
245 |
+
|
246 |
+
# Cython debug symbols
|
247 |
+
cython_debug/
|
248 |
+
|
249 |
+
# PyCharm
|
250 |
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
251 |
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
252 |
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
253 |
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
254 |
+
#.idea/
|
255 |
+
|
256 |
+
### Python Patch ###
|
257 |
+
# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
|
258 |
+
poetry.toml
|
259 |
+
|
260 |
+
# ruff
|
261 |
+
.ruff_cache/
|
262 |
+
|
263 |
+
# LSP config files
|
264 |
+
pyrightconfig.json
|
265 |
+
|
266 |
+
### VisualStudioCode ###
|
267 |
+
.vscode/*
|
268 |
+
!.vscode/settings.json
|
269 |
+
!.vscode/tasks.json
|
270 |
+
!.vscode/launch.json
|
271 |
+
!.vscode/extensions.json
|
272 |
+
!.vscode/*.code-snippets
|
273 |
+
|
274 |
+
# Local History for Visual Studio Code
|
275 |
+
.history/
|
276 |
+
|
277 |
+
# Built Visual Studio Code Extensions
|
278 |
+
*.vsix
|
279 |
+
|
280 |
+
### VisualStudioCode Patch ###
|
281 |
+
# Ignore all local history of files
|
282 |
+
.history
|
283 |
+
.ionide
|
284 |
+
|
285 |
+
# End of https://www.toptal.com/developers/gitignore/api/python,intellij+all,visualstudiocode
|
Dockerfile
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.11
|
2 |
+
RUN useradd -m -u 1000 user
|
3 |
+
USER user
|
4 |
+
ENV HOME=/home/user \
|
5 |
+
PATH=/home/user/.local/bin:$PATH
|
6 |
+
WORKDIR $HOME/app
|
7 |
+
COPY --chown=user . .
|
8 |
+
RUN pip install -r requirements.txt
|
9 |
+
CMD ["chainlit", "run", "app.py", "--port", "7860"]
|
app.py
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import asyncio
|
2 |
+
|
3 |
+
import chainlit as cl
|
4 |
+
|
5 |
+
from chain import Chain
|
6 |
+
|
7 |
+
|
8 |
+
@cl.on_chat_start
|
9 |
+
async def start_chat():
|
10 |
+
chain = Chain(None)
|
11 |
+
await chain.text("I will count to 5. How many concurrent times should I count?")
|
12 |
+
|
13 |
+
|
14 |
+
@cl.on_message
|
15 |
+
async def on_message(message: str, message_id: str):
|
16 |
+
chain = Chain(message_id)
|
17 |
+
|
18 |
+
try:
|
19 |
+
num = int(message)
|
20 |
+
except ValueError:
|
21 |
+
await chain.text_stream("Sorry, that doesn't look like an integer to me.", final=True)
|
22 |
+
return
|
23 |
+
|
24 |
+
if num > 10:
|
25 |
+
await chain.text_stream("Whoa, let's try a smaller number. (Max 10.)", final=True)
|
26 |
+
return
|
27 |
+
|
28 |
+
await chain.text("Alright, here we go:")
|
29 |
+
coroutines = []
|
30 |
+
for i in range(num):
|
31 |
+
coroutines.append(chain.text_stream("1 2 3 4 5", delay=1, name=f"Counter {i + 1}"))
|
32 |
+
await asyncio.gather(*coroutines)
|
33 |
+
await chain.text_stream("Okay, I'm done counting now.", final=True)
|
chain.py
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import asyncio
|
2 |
+
import os
|
3 |
+
import re
|
4 |
+
|
5 |
+
import chainlit as cl
|
6 |
+
import openai
|
7 |
+
from chainlit import LLMSettings
|
8 |
+
from chainlit.config import config
|
9 |
+
|
10 |
+
|
11 |
+
# TODO each chain should be able to make a child chain?
|
12 |
+
# root = Chain()
|
13 |
+
# first = root.child("something")
|
14 |
+
# first.llm('foo')
|
15 |
+
class Chain:
|
16 |
+
def __init__(self, message_id: str | None, llm_settings: LLMSettings | None = None):
|
17 |
+
self.llm_settings = llm_settings
|
18 |
+
self.root_id = message_id
|
19 |
+
|
20 |
+
def make_message(self, name, final, **kwargs) -> cl.Message:
|
21 |
+
if not name:
|
22 |
+
name = config.ui.name if final else "Child Chain"
|
23 |
+
return cl.Message(
|
24 |
+
author=name,
|
25 |
+
parent_id=None if final else self.root_id,
|
26 |
+
**kwargs,
|
27 |
+
)
|
28 |
+
|
29 |
+
async def text(self, text, final=False, name=None):
|
30 |
+
message = self.make_message(content=text, final=final, name=name)
|
31 |
+
await message.send()
|
32 |
+
|
33 |
+
async def text_stream(self, text: str, delay=.1, name=None, final=False):
|
34 |
+
message = self.make_message(content='', final=final, name=name)
|
35 |
+
tokens = text.split(" ")
|
36 |
+
first = True
|
37 |
+
for token in tokens:
|
38 |
+
if not first:
|
39 |
+
token = " " + token
|
40 |
+
await message.stream_token(token)
|
41 |
+
await asyncio.sleep(delay)
|
42 |
+
first = False
|
43 |
+
await message.send()
|
44 |
+
|
45 |
+
async def llm(self, template, *args, name=None, final=False, **kwargs) -> str:
|
46 |
+
variables = re.findall(r'\{(.*?)}', template)
|
47 |
+
if len(args) > 1:
|
48 |
+
raise RuntimeError("If there is more than one argument, use kwargs")
|
49 |
+
if len(args) > 0 and len(kwargs) > 0:
|
50 |
+
raise RuntimeError("Cannot combine args and kwargs")
|
51 |
+
if len(args) > 0:
|
52 |
+
if len(variables) > 1:
|
53 |
+
raise RuntimeError("This chain expects more than one argument. Use kwargs instead.")
|
54 |
+
variable_dict = {variables[0]: args[0]}
|
55 |
+
else:
|
56 |
+
variable_dict = kwargs
|
57 |
+
|
58 |
+
prompt = template.format(**variable_dict)
|
59 |
+
message = self.make_message(content='', name=name, prompt=prompt, llm_settings=self.llm_settings, final=final)
|
60 |
+
|
61 |
+
async for response in await openai.ChatCompletion.acreate(
|
62 |
+
**self.llm_settings.to_settings_dict(), api_key=os.environ.get('OPENAI_API_KEY'), stream=True,
|
63 |
+
messages=[{'role': 'user', 'content': prompt}]
|
64 |
+
):
|
65 |
+
token = response.choices[0]["delta"].get("content", "")
|
66 |
+
await message.stream_token(token)
|
67 |
+
|
68 |
+
await message.send()
|
69 |
+
return message.content
|
chainlit.md
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Welcome to Chainlit! 🚀🤖
|
2 |
+
|
3 |
+
Hi there, Developer! 👋 We're excited to have you on board. Chainlit is a powerful tool designed to help you prototype, debug and share applications built on top of LLMs.
|
4 |
+
|
5 |
+
## Useful Links 🔗
|
6 |
+
|
7 |
+
- **Documentation:** Get started with our comprehensive [Chainlit Documentation](https://docs.chainlit.io) 📚
|
8 |
+
- **Discord Community:** Join our friendly [Chainlit Discord](https://discord.gg/ZThrUxbAYw) to ask questions, share your projects, and connect with other developers! 💬
|
9 |
+
|
10 |
+
We can't wait to see what you create with Chainlit! Happy coding! 💻😊
|
11 |
+
|
12 |
+
## Welcome screen
|
13 |
+
|
14 |
+
To modify the welcome screen, edit the `chainlit.md` file at the root of your project. If you do not want a welcome screen, just leave this file empty.
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
chainlit==0.6.2
|