Skip to content

Commit 4da34b2

Browse files
committed
refactor(api server)!: move to backend api server directory
1 parent cca67c1 commit 4da34b2

File tree

10 files changed

+22
-18
lines changed

10 files changed

+22
-18
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"dockerComposeFile": [
77
"../compose-dev.yaml"
88
],
9-
"service": "backend",
9+
"service": "api",
1010
"workspaceFolder": "/app",
1111
"customizations": {
1212
"vscode": {

backend/Dockerfile

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"module": "fastapi",
1212
"args": [
1313
"run",
14+
"api/main.py",
1415
"--reload"
1516
]
1617
}

backend/api/Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM ghcr.io/astral-sh/uv:python3.13-bookworm
2+
3+
WORKDIR /app
4+
COPY ./backend/api/uv.lock ./backend/api/pyproject.toml .
5+
RUN uv sync --frozen
6+
RUN apt-get update && apt-get install -y --no-install-recommends curl
7+
COPY ./envs/backend.env /opt/.env
8+
COPY ./backend/api /app/api
9+
COPY ./backend/shared_mcp /app/shared_mcp
10+
ENV PYTHONPATH /app:$PYTHONPATH
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class Settings(BaseSettings):
1010

1111
model: str = "gpt-4o-mini-2024-07-18"
1212
openai_api_key: str = ""
13+
mcp_server_port: int = 8050
1314

1415
pg_url: str = "postgres://postgres"
1516
pg_user: str = "postgres"
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
from typing import Annotated, Iterable
22

3+
from config import settings
34
from fastapi import Depends
45
from langchain_openai import ChatOpenAI
56

6-
from config import settings
7-
87

98
def llm_factory() -> ChatOpenAI:
109
llm = ChatOpenAI(
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from fastapi import FastAPI
44

5-
from app.routers import llms
5+
from api.routers import llms, mcps
66

77

88
@asynccontextmanager
@@ -14,3 +14,4 @@ async def lifespan(app: FastAPI):
1414
lifespan=lifespan, swagger_ui_parameters={"tryItOutEnabled": True}
1515
)
1616
app.include_router(llms.router, prefix="/v1")
17+
app.include_router(mcps.router, prefix="/v1")
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[project]
2-
name = "app"
2+
name = "api"
33
version = "0.1.0"
44
description = "Add your description here"
55
readme = "README.md"
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
from fastapi import APIRouter
22
from sse_starlette.sse import EventSourceResponse
33

4-
from app.dependencies import LLMDep
4+
from api.dependencies import LLMDep
55

6-
router = APIRouter()
6+
router = APIRouter(tags=["chat"])
77

88

99
async def stream(query: str, llm: LLMDep):
1010
async for chunk in llm.astream_events(query):
1111
yield dict(data=chunk)
1212

1313

14-
@router.get("/chat/completions", tags=["/chat"])
14+
@router.get("/chat/completions")
1515
async def completions(query: str, llm: LLMDep):
16+
"""Stream completions via Server Sent Events"""
1617
return EventSourceResponse(stream(query, llm))

backend/uv.lock renamed to backend/api/uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)