Spaces:
Runtime error
Runtime error
Rohit Rajpoot
commited on
Commit
·
ea24308
1
Parent(s):
392b494
Deploy: copy app, Dockerfile, requirements, and assist to Space
Browse files- Dockerfile +16 -0
- app.py +13 -0
- assist/__init__.py +1 -0
- assist/__pycache__/__init__.cpython-312.pyc +0 -0
- assist/__pycache__/chat.cpython-312.pyc +0 -0
- assist/__pycache__/heatmap.cpython-312.pyc +0 -0
- assist/__pycache__/main.cpython-312.pyc +0 -0
- assist/chat.py +9 -0
- assist/heatmap.py +14 -0
- assist/main.py +29 -0
- assist/requirements.txt +43 -0
Dockerfile
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use a small Python base image
|
| 2 |
+
FROM python:3.12-slim
|
| 3 |
+
|
| 4 |
+
WORKDIR /app
|
| 5 |
+
|
| 6 |
+
# Copy and install dependencies
|
| 7 |
+
COPY requirements.txt .
|
| 8 |
+
RUN pip install --upgrade pip && \
|
| 9 |
+
pip install -r requirements.txt
|
| 10 |
+
|
| 11 |
+
# Copy all project files
|
| 12 |
+
COPY . .
|
| 13 |
+
|
| 14 |
+
# Expose Streamlit port and run
|
| 15 |
+
EXPOSE 8501
|
| 16 |
+
CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]
|
app.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from assist.chat import chat as chat_plugin
|
| 3 |
+
|
| 4 |
+
st.title("RepoSage Chatbot Demo")
|
| 5 |
+
|
| 6 |
+
# 1) Change the label to make it obvious we're asking a question
|
| 7 |
+
question = st.text_input("Ask RepoSage a question:", "")
|
| 8 |
+
|
| 9 |
+
# 2) Only run when clicked
|
| 10 |
+
if st.button("Ask RepoSage"):
|
| 11 |
+
# 3) Pass that question into your stub
|
| 12 |
+
response = chat_plugin(question)
|
| 13 |
+
st.write(response)
|
assist/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
|
assist/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (150 Bytes). View file
|
|
|
assist/__pycache__/chat.cpython-312.pyc
ADDED
|
Binary file (498 Bytes). View file
|
|
|
assist/__pycache__/heatmap.cpython-312.pyc
ADDED
|
Binary file (866 Bytes). View file
|
|
|
assist/__pycache__/main.cpython-312.pyc
ADDED
|
Binary file (1.34 kB). View file
|
|
|
assist/chat.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# assist/chat.py
|
| 2 |
+
|
| 3 |
+
def chat(question: str) -> str:
|
| 4 |
+
"""
|
| 5 |
+
Chat plugin stub: echoes back what you asked.
|
| 6 |
+
"""
|
| 7 |
+
if not question.strip():
|
| 8 |
+
return "Please enter a question above."
|
| 9 |
+
return f"Chat plugin stub received: “{question}”"
|
assist/heatmap.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
import matplotlib.pyplot as plt
|
| 3 |
+
from sklearn.metrics.pairwise import cosine_similarity
|
| 4 |
+
|
| 5 |
+
def show_heatmap(tensor_path="tensor.pt"):
|
| 6 |
+
# Load embeddings
|
| 7 |
+
weights = torch.load(tensor_path).numpy()
|
| 8 |
+
# Compute similarity
|
| 9 |
+
sim = cosine_similarity(weights)
|
| 10 |
+
# Plot
|
| 11 |
+
plt.imshow(sim, cmap="viridis")
|
| 12 |
+
plt.colorbar()
|
| 13 |
+
plt.title("Token Similarity Heatmap")
|
| 14 |
+
plt.show()
|
assist/main.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import typer
|
| 2 |
+
from rich import print
|
| 3 |
+
from pathlib import Path
|
| 4 |
+
|
| 5 |
+
# Import and alias the stub so it doesn't collide with our CLI function
|
| 6 |
+
from .chat import chat as chat_plugin
|
| 7 |
+
from .heatmap import show_heatmap
|
| 8 |
+
|
| 9 |
+
app = typer.Typer(help="RepoSage Synth CLI")
|
| 10 |
+
|
| 11 |
+
@app.command()
|
| 12 |
+
def hello(name: str = "world"):
|
| 13 |
+
"""Warm-up command: prints Hello, {name}!"""
|
| 14 |
+
print(f"[bold green]Hello, {name}![/]")
|
| 15 |
+
|
| 16 |
+
@app.command()
|
| 17 |
+
def heatmap():
|
| 18 |
+
"""Show token-similarity heatmap from tensor.pt."""
|
| 19 |
+
show_heatmap()
|
| 20 |
+
|
| 21 |
+
@app.command()
|
| 22 |
+
def chat(repo: Path = Path(".")):
|
| 23 |
+
"""Invoke the chat plugin stub."""
|
| 24 |
+
# Call the aliased stub, not this function
|
| 25 |
+
response = chat_plugin(repo)
|
| 26 |
+
print(response)
|
| 27 |
+
|
| 28 |
+
if __name__ == "__main__":
|
| 29 |
+
app()
|
assist/requirements.txt
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
certifi==2025.6.15
|
| 2 |
+
charset-normalizer==3.4.2
|
| 3 |
+
click==8.2.1
|
| 4 |
+
contourpy==1.3.2
|
| 5 |
+
cycler==0.12.1
|
| 6 |
+
filelock==3.18.0
|
| 7 |
+
fonttools==4.58.4
|
| 8 |
+
fsspec==2025.5.1
|
| 9 |
+
gitdb==4.0.12
|
| 10 |
+
GitPython==3.1.44
|
| 11 |
+
idna==3.10
|
| 12 |
+
Jinja2==3.1.6
|
| 13 |
+
joblib==1.5.1
|
| 14 |
+
kiwisolver==1.4.8
|
| 15 |
+
markdown-it-py==3.0.0
|
| 16 |
+
MarkupSafe==3.0.2
|
| 17 |
+
matplotlib==3.10.3
|
| 18 |
+
mdurl==0.1.2
|
| 19 |
+
mpmath==1.3.0
|
| 20 |
+
networkx==3.5
|
| 21 |
+
nltk==3.9.1
|
| 22 |
+
numpy==2.3.0
|
| 23 |
+
packaging==25.0
|
| 24 |
+
pillow==11.2.1
|
| 25 |
+
Pygments==2.19.1
|
| 26 |
+
pyparsing==3.2.3
|
| 27 |
+
python-dateutil==2.9.0.post0
|
| 28 |
+
regex==2024.11.6
|
| 29 |
+
requests==2.32.4
|
| 30 |
+
rich==14.0.0
|
| 31 |
+
scikit-learn==1.7.0
|
| 32 |
+
scipy==1.15.3
|
| 33 |
+
setuptools==80.9.0
|
| 34 |
+
shellingham==1.5.4
|
| 35 |
+
six==1.17.0
|
| 36 |
+
smmap==5.0.2
|
| 37 |
+
sympy==1.14.0
|
| 38 |
+
threadpoolctl==3.6.0
|
| 39 |
+
torch==2.7.1
|
| 40 |
+
tqdm==4.67.1
|
| 41 |
+
typer==0.16.0
|
| 42 |
+
typing_extensions==4.14.0
|
| 43 |
+
urllib3==2.4.0
|