Spaces:
Sleeping
Sleeping
Upload 10 files
Browse files- .gitignore +174 -0
- Dockerfile +18 -0
- LICENSE +21 -0
- README.md +26 -11
- app.py +138 -0
- chainlit.md +14 -0
- combined_data.json +0 -0
- pyproject.toml +21 -0
- test_env.py +2 -0
- uv.lock +0 -0
.gitignore
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
# UV
|
| 98 |
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
| 99 |
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
| 100 |
+
# commonly ignored for libraries.
|
| 101 |
+
#uv.lock
|
| 102 |
+
|
| 103 |
+
# poetry
|
| 104 |
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
| 105 |
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
| 106 |
+
# commonly ignored for libraries.
|
| 107 |
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
| 108 |
+
#poetry.lock
|
| 109 |
+
|
| 110 |
+
# pdm
|
| 111 |
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
| 112 |
+
#pdm.lock
|
| 113 |
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
| 114 |
+
# in version control.
|
| 115 |
+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
| 116 |
+
.pdm.toml
|
| 117 |
+
.pdm-python
|
| 118 |
+
.pdm-build/
|
| 119 |
+
|
| 120 |
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
| 121 |
+
__pypackages__/
|
| 122 |
+
|
| 123 |
+
# Celery stuff
|
| 124 |
+
celerybeat-schedule
|
| 125 |
+
celerybeat.pid
|
| 126 |
+
|
| 127 |
+
# SageMath parsed files
|
| 128 |
+
*.sage.py
|
| 129 |
+
|
| 130 |
+
# Environments
|
| 131 |
+
.env
|
| 132 |
+
.venv
|
| 133 |
+
env/
|
| 134 |
+
venv/
|
| 135 |
+
ENV/
|
| 136 |
+
env.bak/
|
| 137 |
+
venv.bak/
|
| 138 |
+
|
| 139 |
+
# Spyder project settings
|
| 140 |
+
.spyderproject
|
| 141 |
+
.spyproject
|
| 142 |
+
|
| 143 |
+
# Rope project settings
|
| 144 |
+
.ropeproject
|
| 145 |
+
|
| 146 |
+
# mkdocs documentation
|
| 147 |
+
/site
|
| 148 |
+
|
| 149 |
+
# mypy
|
| 150 |
+
.mypy_cache/
|
| 151 |
+
.dmypy.json
|
| 152 |
+
dmypy.json
|
| 153 |
+
|
| 154 |
+
# Pyre type checker
|
| 155 |
+
.pyre/
|
| 156 |
+
|
| 157 |
+
# pytype static type analyzer
|
| 158 |
+
.pytype/
|
| 159 |
+
|
| 160 |
+
# Cython debug symbols
|
| 161 |
+
cython_debug/
|
| 162 |
+
|
| 163 |
+
# PyCharm
|
| 164 |
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
| 165 |
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
| 166 |
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
| 167 |
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
| 168 |
+
#.idea/
|
| 169 |
+
|
| 170 |
+
# Ruff stuff:
|
| 171 |
+
.ruff_cache/
|
| 172 |
+
|
| 173 |
+
# PyPI configuration file
|
| 174 |
+
.pypirc
|
Dockerfile
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim
|
| 2 |
+
|
| 3 |
+
RUN useradd -m -u 1000 user
|
| 4 |
+
USER user
|
| 5 |
+
|
| 6 |
+
ENV HOME=/home/user \
|
| 7 |
+
PATH=/home/user/.local/bin:$PATH \
|
| 8 |
+
UVICORN_WS_PROTOCOL=websockets
|
| 9 |
+
|
| 10 |
+
WORKDIR $HOME/app
|
| 11 |
+
|
| 12 |
+
COPY --chown=user . $HOME/app
|
| 13 |
+
|
| 14 |
+
RUN uv sync
|
| 15 |
+
|
| 16 |
+
EXPOSE 7860
|
| 17 |
+
|
| 18 |
+
CMD ["uv", "run", "chainlit", "run", "app.py", "--host", "0.0.0.0", "--port", "7860"]
|
LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2025 Aneeta Xavier
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
README.md
CHANGED
|
@@ -1,11 +1,26 @@
|
|
| 1 |
-
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
-
sdk: docker
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title : Pilates App Fine_Tuned
|
| 3 |
+
emoji: π
|
| 4 |
+
colorFrom: red
|
| 5 |
+
colorTo: red
|
| 6 |
+
sdk: docker
|
| 7 |
+
app_file: app.py
|
| 8 |
+
pinned: false
|
| 9 |
+
license: mit
|
| 10 |
+
short_description: Tool to provide users reformer exercises
|
| 11 |
+
startup_duration_timeout: 1h
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
# Pilates Reformer RAG App Fine_Tuned
|
| 15 |
+
|
| 16 |
+
This Chainlit app answers questions using Pilates reformer videos and textbooks. All data is preloaded from `combined_data.json`.
|
| 17 |
+
|
| 18 |
+
## Run Locally
|
| 19 |
+
|
| 20 |
+
```bash
|
| 21 |
+
uv run chainlit run app.py
|
| 22 |
+
```
|
| 23 |
+
|
| 24 |
+
## Or Deploy to Hugging Face Space with Docker
|
| 25 |
+
Just upload this directory and you're done.
|
| 26 |
+
|
app.py
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import json
|
| 3 |
+
from langchain_core.documents import Document
|
| 4 |
+
from langchain_text_splitters import RecursiveCharacterTextSplitter
|
| 5 |
+
from langchain_community.vectorstores import FAISS
|
| 6 |
+
from langchain_huggingface import HuggingFaceEmbeddings
|
| 7 |
+
from langchain_openai import ChatOpenAI
|
| 8 |
+
from langchain.chains import RetrievalQA
|
| 9 |
+
from langchain.prompts import PromptTemplate
|
| 10 |
+
import chainlit as cl
|
| 11 |
+
from openai import OpenAI
|
| 12 |
+
|
| 13 |
+
# Initialize OpenAI client
|
| 14 |
+
client = OpenAI()
|
| 15 |
+
|
| 16 |
+
# === Load and prepare data ===
|
| 17 |
+
with open("combined_data.json", "r") as f:
|
| 18 |
+
raw_data = json.load(f)
|
| 19 |
+
|
| 20 |
+
all_docs = [
|
| 21 |
+
Document(page_content=entry["content"], metadata=entry["metadata"])
|
| 22 |
+
for entry in raw_data
|
| 23 |
+
]
|
| 24 |
+
|
| 25 |
+
# === Split documents into chunks ===
|
| 26 |
+
splitter = RecursiveCharacterTextSplitter(chunk_size=800, chunk_overlap=50)
|
| 27 |
+
chunked_docs = splitter.split_documents(all_docs)
|
| 28 |
+
|
| 29 |
+
# === Use your fine-tuned Hugging Face embeddings ===
|
| 30 |
+
embedding_model = HuggingFaceEmbeddings(
|
| 31 |
+
model_name="bsmith3715/legal-ft-demo_final"
|
| 32 |
+
)
|
| 33 |
+
|
| 34 |
+
# === Set up FAISS vector store ===
|
| 35 |
+
vectorstore = FAISS.from_documents(chunked_docs, embedding_model)
|
| 36 |
+
retriever = vectorstore.as_retriever(search_kwargs={"k": 5})
|
| 37 |
+
|
| 38 |
+
# === Define prompt templates ===
|
| 39 |
+
RAG_PROMPT_TEMPLATE = """You are a helpful AI assistant specializing in reformer pilates. Use the following context to answer the user's question, provide a workout with the level of difficulty, length and focus provided, or a step by step description of the exercise provided. If you don't know the answer, just say that you don't know.
|
| 40 |
+
|
| 41 |
+
Context: {context}
|
| 42 |
+
|
| 43 |
+
Question: {question}
|
| 44 |
+
|
| 45 |
+
Answer:"""
|
| 46 |
+
|
| 47 |
+
IMAGE_PROMPT_TEMPLATE = """Create a detailed and professional image that represents the following reformer pilates exercise: {query}
|
| 48 |
+
|
| 49 |
+
The image should be:
|
| 50 |
+
- Professional and appropriate for a reformer pilates context
|
| 51 |
+
- Clear and easy to understand
|
| 52 |
+
- Visually appealing
|
| 53 |
+
- Suitable for use in professional settings and or presentations
|
| 54 |
+
- Provide a seperate visual for each step in the exercise with numbering of steps"""
|
| 55 |
+
|
| 56 |
+
# === Create prompt templates ===
|
| 57 |
+
rag_prompt = PromptTemplate(
|
| 58 |
+
template=RAG_PROMPT_TEMPLATE,
|
| 59 |
+
input_variables=["context", "question"]
|
| 60 |
+
)
|
| 61 |
+
|
| 62 |
+
image_prompt = PromptTemplate(
|
| 63 |
+
template=IMAGE_PROMPT_TEMPLATE,
|
| 64 |
+
input_variables=["query"]
|
| 65 |
+
)
|
| 66 |
+
|
| 67 |
+
# === Load LLM ===
|
| 68 |
+
llm = ChatOpenAI(model_name="gpt-4.1-mini", temperature=0)
|
| 69 |
+
qa_chain = RetrievalQA.from_chain_type(
|
| 70 |
+
llm=llm,
|
| 71 |
+
retriever=retriever,
|
| 72 |
+
chain_type_kwargs={"prompt": rag_prompt}
|
| 73 |
+
)
|
| 74 |
+
|
| 75 |
+
# === Chainlit start event ===
|
| 76 |
+
@cl.on_chat_start
|
| 77 |
+
async def start():
|
| 78 |
+
await cl.Message(content =
|
| 79 |
+
"""π Welcome to your Reformer Pilates AI!
|
| 80 |
+
|
| 81 |
+
Here's what you can do:
|
| 82 |
+
β’ Ask questions about Reformer Pilates
|
| 83 |
+
β’ Get individualized workouts based on your level, goals, and equipment
|
| 84 |
+
β’ Get instant exercise modifications based on injuries or limitations
|
| 85 |
+
|
| 86 |
+
Let's get started! π""").send()
|
| 87 |
+
cl.user_session.set("qa_chain", qa_chain)
|
| 88 |
+
|
| 89 |
+
# === Chainlit message handler ===
|
| 90 |
+
@cl.on_message
|
| 91 |
+
async def handle_message(message: cl.Message):
|
| 92 |
+
# Check if the message is requesting image generation
|
| 93 |
+
if message.content.lower().startswith("create an image"):
|
| 94 |
+
# Send loading message
|
| 95 |
+
msg = cl.Message(content="π¨ Creating your legal visualization...")
|
| 96 |
+
await msg.send()
|
| 97 |
+
|
| 98 |
+
try:
|
| 99 |
+
# Format the image prompt
|
| 100 |
+
formatted_prompt = image_prompt.format(query=message.content)
|
| 101 |
+
|
| 102 |
+
# Generate image using DALL-E
|
| 103 |
+
response = client.images.generate(
|
| 104 |
+
model="dall-e-3",
|
| 105 |
+
prompt=formatted_prompt,
|
| 106 |
+
size="1024x1024",
|
| 107 |
+
quality="standard",
|
| 108 |
+
n=1,
|
| 109 |
+
)
|
| 110 |
+
|
| 111 |
+
# Get the image URL
|
| 112 |
+
image_url = response.data[0].url
|
| 113 |
+
|
| 114 |
+
# Create and send the image message
|
| 115 |
+
await cl.Message(
|
| 116 |
+
content="Here's your generated image:",
|
| 117 |
+
elements=[cl.Image(url=image_url, name="generated_image")]
|
| 118 |
+
).send()
|
| 119 |
+
|
| 120 |
+
except Exception as e:
|
| 121 |
+
await cl.Message(content=f"β οΈ Error generating image: {str(e)}").send()
|
| 122 |
+
|
| 123 |
+
else:
|
| 124 |
+
# Handle regular QA queries with streaming
|
| 125 |
+
chain = cl.user_session.get("qa_chain")
|
| 126 |
+
if chain:
|
| 127 |
+
try:
|
| 128 |
+
# Create a message placeholder
|
| 129 |
+
msg = cl.Message(content="")
|
| 130 |
+
await msg.send()
|
| 131 |
+
|
| 132 |
+
# Stream the response
|
| 133 |
+
async for chunk in chain.astream({"query": message.content}):
|
| 134 |
+
if "result" in chunk:
|
| 135 |
+
await msg.stream_token(chunk["result"])
|
| 136 |
+
|
| 137 |
+
except Exception as e:
|
| 138 |
+
await cl.Message(content=f"β οΈ Error: {str(e)}").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.
|
combined_data.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
pyproject.toml
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[project]
|
| 2 |
+
name = "pilates_fine_tuned"
|
| 3 |
+
requires-python = ">=3.13"
|
| 4 |
+
version = "0.1.0"
|
| 5 |
+
description = "A fine-tuned pilates project."
|
| 6 |
+
dependencies = [
|
| 7 |
+
"langchain-huggingface>=0.0.6",
|
| 8 |
+
"chainlit>=2.5.5",
|
| 9 |
+
"faiss-cpu>=1.11.0",
|
| 10 |
+
"langchain>=0.3.25",
|
| 11 |
+
"langchain-community>=0.3.24",
|
| 12 |
+
"langchain-openai>=0.3.16",
|
| 13 |
+
"langchain-core>=0.0.1", # Added langchain-core
|
| 14 |
+
"pymupdf>=1.25.5",
|
| 15 |
+
"pytube>=15.0.0",
|
| 16 |
+
"unstructured>=0.17.2",
|
| 17 |
+
"youtube-transcript-api>=1.0.3",
|
| 18 |
+
"websockets==11.0.3",
|
| 19 |
+
"openai>=1.78.1",
|
| 20 |
+
]
|
| 21 |
+
|
test_env.py
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
print("OPENAI_API_KEY:", os.getenv("OPENAI_API_KEY"))
|
uv.lock
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|