singhjagpreet commited on
Commit
5e20c77
β€’
1 Parent(s): 884ccb1

setting up chainlit

Browse files
Files changed (5) hide show
  1. .gitignore +4 -0
  2. app.py +27 -0
  3. chainlit.md +14 -0
  4. requirements.txt +4 -0
  5. 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