Spaces:
Sleeping
Sleeping
Commit
Β·
5e20c77
1
Parent(s):
884ccb1
setting up chainlit
Browse files- .gitignore +4 -0
- app.py +27 -0
- chainlit.md +14 -0
- requirements.txt +4 -0
- src/utils.py +8 -0
.gitignore
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
venv/
|
2 |
+
**/__pycache__/
|
3 |
+
.chainlit/
|
4 |
+
.env
|
app.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
|
3 |
+
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
4 |
+
from langchain.embeddings.openai import OpenAIEmbeddings
|
5 |
+
import chainlit as cl
|
6 |
+
|
7 |
+
|
8 |
+
|
9 |
+
text_splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=100)
|
10 |
+
embeddings = OpenAIEmbeddings()
|
11 |
+
|
12 |
+
welcome_message = """ Upload your file here"""
|
13 |
+
|
14 |
+
@cl.on_chat_start
|
15 |
+
async def start():
|
16 |
+
await cl.Message("you are in ").send()
|
17 |
+
files = None
|
18 |
+
while files is None:
|
19 |
+
files = await cl.AskFileMessage(
|
20 |
+
content=welcome_message,
|
21 |
+
accept=["text/plain", "application/pdf"],
|
22 |
+
max_size_mb=10,
|
23 |
+
timeout=90
|
24 |
+
).send()
|
25 |
+
file = files[0]
|
26 |
+
msg = cl.Message(content=f"Processing `{type(files)}` {file.name}....")
|
27 |
+
await msg.send()
|
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/k73SQ3FyUh) 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,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
langchain
|
2 |
+
openai
|
3 |
+
python-dotenv
|
4 |
+
chainlit
|
src/utils.py
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from chainlit.types import AskFileResponse
|
2 |
+
from langchain.document_loaders import TextLoader
|
3 |
+
|
4 |
+
def process_file(file: AskFileResponse):
|
5 |
+
pass
|
6 |
+
|
7 |
+
def get_docSearch(file: AskFileResponse):
|
8 |
+
pass
|