Spaces:
Sleeping
Sleeping
Initial commit
Browse files- .gitignore +6 -0
- .gitmodules +3 -0
- .python-version +1 -0
- DEVELOPER.md +50 -0
- Dockerfile +31 -0
- README.md +23 -0
- app.py +12 -0
- chainlit.md +14 -0
- data +1 -0
- pyproject.toml +50 -0
- requirements.txt +1 -0
- uv.lock +0 -0
.gitignore
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
__pycache__/
|
2 |
+
.chainlit/
|
3 |
+
.venv/
|
4 |
+
.env
|
5 |
+
.chainlit/
|
6 |
+
.files/
|
.gitmodules
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
[submodule "data"]
|
2 |
+
path = data
|
3 |
+
url = [email protected]:mbudisic/PsTuts-VQA-Dataset.git
|
.python-version
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
3.13
|
DEVELOPER.md
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# π οΈ Developer Documentation
|
2 |
+
|
3 |
+
## π¦ Project Structure
|
4 |
+
|
5 |
+
```
|
6 |
+
.
|
7 |
+
βββ app.py # Main Chainlit application
|
8 |
+
βββ requirements.txt # Project dependencies
|
9 |
+
βββ README.md # User documentation
|
10 |
+
```
|
11 |
+
|
12 |
+
## π§ Technical Details
|
13 |
+
|
14 |
+
The application uses Chainlit (v0.7.700+) to create a simple chat interface. The main functionality is implemented in `app.py` using the `@cl.on_message` decorator to handle incoming messages.
|
15 |
+
|
16 |
+
### Key Components
|
17 |
+
|
18 |
+
- `@cl.on_message`: Decorator that handles incoming messages from the chat interface
|
19 |
+
- `cl.Message`: Class for creating and sending messages back to the user
|
20 |
+
- Async/await pattern for handling message processing
|
21 |
+
|
22 |
+
## π Running Locally
|
23 |
+
|
24 |
+
1. Create a virtual environment (recommended):
|
25 |
+
```bash
|
26 |
+
python -m venv venv
|
27 |
+
source venv/bin/activate # On Windows: venv\Scripts\activate
|
28 |
+
```
|
29 |
+
|
30 |
+
2. Install dependencies:
|
31 |
+
```bash
|
32 |
+
pip install -r requirements.txt
|
33 |
+
```
|
34 |
+
|
35 |
+
3. Run the development server:
|
36 |
+
```bash
|
37 |
+
chainlit run app.py
|
38 |
+
```
|
39 |
+
|
40 |
+
## π Debugging
|
41 |
+
|
42 |
+
- Chainlit provides a built-in debug mode. Run with:
|
43 |
+
```bash
|
44 |
+
chainlit run app.py --debug
|
45 |
+
```
|
46 |
+
|
47 |
+
## π Resources
|
48 |
+
|
49 |
+
- [Chainlit Documentation](https://docs.chainlit.io)
|
50 |
+
- [Chainlit GitHub Repository](https://github.com/Chainlit/chainlit)
|
Dockerfile
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
# Get a distribution that has uv already installed
|
3 |
+
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim
|
4 |
+
|
5 |
+
# Add user - this is the user that will run the app
|
6 |
+
# If you do not set user, the app will run as root (undesirable)
|
7 |
+
RUN useradd -m -u 1000 user
|
8 |
+
USER user
|
9 |
+
|
10 |
+
# Set the home directory and path
|
11 |
+
ENV HOME=/home/user \
|
12 |
+
PATH=/home/user/.local/bin:$PATH
|
13 |
+
|
14 |
+
ENV UVICORN_WS_PROTOCOL=websockets
|
15 |
+
|
16 |
+
|
17 |
+
# Set the working directory
|
18 |
+
WORKDIR $HOME/app
|
19 |
+
|
20 |
+
# Copy the app to the container
|
21 |
+
COPY --chown=user . $HOME/app
|
22 |
+
|
23 |
+
# Install the dependencies
|
24 |
+
# RUN uv sync --frozen
|
25 |
+
RUN uv sync
|
26 |
+
|
27 |
+
# Expose the port
|
28 |
+
EXPOSE 7860
|
29 |
+
|
30 |
+
# Run the app
|
31 |
+
CMD ["uv", "run", "chainlit", "run", "app.py", "--host", "0.0.0.0", "--port", "7860"]
|
README.md
CHANGED
@@ -10,3 +10,26 @@ short_description: Agentic RAG that interrogates the PsTuts dataset.
|
|
10 |
---
|
11 |
|
12 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
---
|
11 |
|
12 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
13 |
+
|
14 |
+
# π€ Chainlit Hello World App
|
15 |
+
|
16 |
+
A minimal Chainlit application that demonstrates basic chat functionality.
|
17 |
+
|
18 |
+
## π Getting Started
|
19 |
+
|
20 |
+
1. Install dependencies:
|
21 |
+
```bash
|
22 |
+
pip install -r requirements.txt
|
23 |
+
```
|
24 |
+
|
25 |
+
2. Run the app:
|
26 |
+
```bash
|
27 |
+
chainlit run app.py
|
28 |
+
```
|
29 |
+
|
30 |
+
3. Open your browser and navigate to `http://localhost:8000`
|
31 |
+
|
32 |
+
## π‘ Features
|
33 |
+
|
34 |
+
- Simple chat interface
|
35 |
+
- Echo functionality that repeats back your messages
|
app.py
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import chainlit as cl
|
2 |
+
|
3 |
+
@cl.on_message
|
4 |
+
async def main(message: cl.Message):
|
5 |
+
# Send a response back to the user
|
6 |
+
await cl.Message(
|
7 |
+
content=f"Hello! You said: {message.content}"
|
8 |
+
).send()
|
9 |
+
|
10 |
+
|
11 |
+
if __name__ == "__main__":
|
12 |
+
main()
|
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.
|
data
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
Subproject commit ae4b7cc721ad86ef2fe97e1a72a7fd7edb0703b7
|
pyproject.toml
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[project]
|
2 |
+
name = "pstuts-rag"
|
3 |
+
version = "2025.05.12"
|
4 |
+
description = "Agentic RAG system for PsTuts dataset"
|
5 |
+
readme = "README.md"
|
6 |
+
requires-python = ">=3.13"
|
7 |
+
dependencies = [
|
8 |
+
"aiohttp>=3.8.0",
|
9 |
+
"chainlit==2.0.4",
|
10 |
+
"dotenv>=0.9.9",
|
11 |
+
"easyocr>=1.7.2",
|
12 |
+
"fastapi>=0.115.3,<0.116",
|
13 |
+
"httpx==0.27.0",
|
14 |
+
"ipykernel>=6.29.5",
|
15 |
+
"ipywidgets>=8.1.7",
|
16 |
+
"jq>=1.8.0",
|
17 |
+
"jupyter>=1.1.1",
|
18 |
+
"langchain-community>=0.3.23",
|
19 |
+
"langchain-experimental>=0.3.4",
|
20 |
+
"langchain-openai",
|
21 |
+
"langchain-qdrant>=0.2.0",
|
22 |
+
"langchain>=0.3.25",
|
23 |
+
"langgraph>=0.4.3",
|
24 |
+
"numpy==2.2.2",
|
25 |
+
"openai==1.59.9",
|
26 |
+
"pip>=25.0.1",
|
27 |
+
"pydantic==2.10.1",
|
28 |
+
"pypdf2==3.0.1",
|
29 |
+
"python-multipart>=0.0.18,<0.0.19",
|
30 |
+
"ragas>=0.2.15",
|
31 |
+
"requests>=2.31.0",
|
32 |
+
"tavily-python>=0.7.2",
|
33 |
+
"tqdm",
|
34 |
+
"typing-extensions>=4.0.0",
|
35 |
+
"unstructured>=0.17.2",
|
36 |
+
"uvicorn>=0.25.0,<0.26.0",
|
37 |
+
"websockets==14.2",
|
38 |
+
|
39 |
+
]
|
40 |
+
authors = [
|
41 |
+
{ name="Marko Budisic", email="[email protected]" }
|
42 |
+
]
|
43 |
+
license = "MIT"
|
44 |
+
|
45 |
+
[build-system]
|
46 |
+
requires = ["hatchling >= 1.26"]
|
47 |
+
build-backend = "hatchling.build"
|
48 |
+
|
49 |
+
[tool.hatch.build.targets.wheel]
|
50 |
+
packages = ["pstuts-rag/pstuts-rag"]
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
chainlit>=0.7.700
|
uv.lock
ADDED
The diff for this file is too large to render.
See raw diff
|
|