Skip to content

Commit 290a306

Browse files
authored
Merge pull request #14 from BrunoV21/hf-space-demo
Hf space demo
2 parents f72733d + 7a00d1a commit 290a306

File tree

7 files changed

+747
-15
lines changed

7 files changed

+747
-15
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,3 +183,5 @@ config/
183183
codetide/agents/tide/ui/assets/
184184
examples/hf_demo_space/.chainlit/*
185185
examples/hf_demo_space/chainlit.md
186+
187+
examples/hf_demo_space/public/

codetide/agents/tide/ui/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ async def loadAgentTideUi()->AgentTideUi:
146146
agent_tide_ui = AgentTideUi(
147147
os.getenv("AGENT_TIDE_PROJECT_PATH", "./"),
148148
history=cl.user_session.get("chat_history"),
149-
llm_config=cl.user_session.get("settings")
149+
llm_config=cl.user_session.get("settings") or None
150150
)
151151
await agent_tide_ui.load()
152152

examples/hf_demo_space/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ RUN pip install --upgrade pip && \
2828

2929
EXPOSE 7860
3030

31-
CMD python -m chainlit run app.py --host 0.0.0.0 --port 7860
31+
CMD uvicorn api:app --host 0.0.0.0 --port 7860

examples/hf_demo_space/api.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
from fastapi.responses import HTMLResponse, FileResponse
2+
from fastapi.templating import Jinja2Templates
3+
from fastapi.staticfiles import StaticFiles
4+
from fastapi import FastAPI, Request
5+
from chainlit.utils import mount_chainlit
6+
from pathlib import Path
7+
import os
8+
9+
ROOT_PATH = os.getenv("API_ROOT_PATH", "./")
10+
app = FastAPI(title="AgentTide", description="Precision-Driven Software Engineering Agent")
11+
12+
# Mount static files directory for assets (logo, CSS, JS, etc.)
13+
app.mount("/static", StaticFiles(directory=F"{ROOT_PATH}/public"), name="static")
14+
15+
templates = Jinja2Templates(directory=F"{ROOT_PATH}/static")
16+
17+
@app.get("/", response_class=HTMLResponse)
18+
async def landing_page(request: Request):
19+
"""Serve the AgentTide landing page"""
20+
return templates.TemplateResponse("landing_page.html", {"request": request})
21+
22+
@app.get("/health")
23+
async def health_check():
24+
"""Health check endpoint"""
25+
return {"status": "healthy", "service": "AgentTide"}
26+
27+
@app.get("/favicon.ico", include_in_schema=False)
28+
async def favicon():
29+
"""Serve favicon"""
30+
favicon_path = Path(F"{ROOT_PATH}/public/favicon.ico")
31+
if favicon_path.exists():
32+
return FileResponse(favicon_path)
33+
else:
34+
# Return 204 No Content if favicon doesn't exist
35+
return HTMLResponse(status_code=204)
36+
37+
@app.get("/logo_dark.png", include_in_schema=False)
38+
async def logo_dark():
39+
"""Serve favicon"""
40+
favicon_path = Path(F"{ROOT_PATH}/public/logo_dark.png")
41+
if favicon_path.exists():
42+
return FileResponse(favicon_path)
43+
else:
44+
# Return 204 No Content if favicon doesn't exist
45+
return HTMLResponse(status_code=204)
46+
47+
mount_chainlit(app=app, target=F"{ROOT_PATH}/app.py", path="/tide")
48+
49+
if __name__ == "__main__":
50+
from dotenv import load_dotenv
51+
import uvicorn
52+
53+
load_dotenv()
54+
uvicorn.run(app, host="0.0.0.0", port=7860)

examples/hf_demo_space/app.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,7 @@ async def start_chatr():
4040
cl.user_session.set("session_id", session_id)
4141
await cl.context.emitter.set_commands(AgentTideUi.commands)
4242
cl.user_session.set("chat_history", [])
43-
44-
await cl.Message(
45-
content="",
46-
elements=[
47-
cl.Image(
48-
path=os.getenv("AGENT_TIDE_LOGO_PATH"),
49-
size="large"
50-
)
51-
]
52-
).send()
53-
43+
5444
exception = True
5545
while exception:
5646
try:
@@ -113,7 +103,7 @@ async def start_chatr():
113103
agent_tide_ui = AgentTideUi(
114104
DEFAULT_SESSIONS_WORKSPACE / session_id,
115105
history=cl.user_session.get("chat_history"),
116-
llm_config=cl.user_session.get("settings"),
106+
llm_config=cl.user_session.get("settings") or None,
117107
session_id=session_id
118108
)
119109
await agent_tide_ui.load()
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
codetide @ git+https://github.com/BrunoV21/codetide.git#egg=codetide[agents-ui]
1+
codetide @ git+https://github.com/BrunoV21/codetide.git#egg=codetide[agents-ui]
2+
fastapi==0.115.7

0 commit comments

Comments
 (0)