Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ config.py
.aider*
repomix-output.xml
.codegraph/
init.py
init.py
saved_runtime.txt
23 changes: 23 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
)

from fastapi.responses import (
FileResponse,
HTMLResponse,
Response,
)

from fastapi.staticfiles import (
Expand All @@ -19,6 +21,7 @@

import asyncio
import httpx
from pathlib import Path

from config_loader import (
config,
Expand Down Expand Up @@ -106,6 +109,26 @@ async def lifespan(application: FastAPI):
)


@app.get(
"/saved_runtime.txt",
)
async def saved_runtime_file():

saved_runtime_path = Path(
"saved_runtime.txt"
)

if not saved_runtime_path.is_file():
return Response(
status_code=404
)

return FileResponse(
saved_runtime_path,
media_type="text/plain; charset=utf-8",
)


# ---------------------------------------------------------
# INDEX PAGE
# ---------------------------------------------------------
Expand Down
30 changes: 30 additions & 0 deletions app_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,20 @@ class AppSettings:

CHAT_ENDPOINT: str
MODELS_ENDPOINT: str
NATIVE_MODELS_ENDPOINT: str

USE_SERVICE_AS_BRAIN: bool

SERVICE_API_BASE: str
SERVICE_MODEL_UID: str
SERVICE_CONTEXT_WINDOW: int
SERVICE_MAX_TOKENS: int
SERVICE_REQUEST_TIMEOUT: float

BRAIN_API_BASE: str
BRAIN_MODEL_UID: str
BRAIN_CONTEXT_WINDOW: int
BRAIN_MAX_TOKENS: int
BRAIN_REQUEST_TIMEOUT: float

TRANSLATOR_API_BASE: str
Expand All @@ -31,6 +34,10 @@ class AppSettings:
TRANSLATION_MIN_TOKENS: int
TRANSLATION_MAX_TOKENS: int

RUNTIME_OUTPUT_TOKEN_RESERVE: int
RUNTIME_CONTEXT_WINDOW_FALLBACK_TO_SERVER: bool
RUNTIME_MAX_TOKENS_FALLBACK_TO_SERVER: bool

SEARCH_PROVIDER: str
SEARCH_SERPER_API_KEY: str
SEARCH_MAX_RESULTS: int
Expand All @@ -41,17 +48,24 @@ class AppSettings:

CHAT_ENDPOINT=config.CHAT_ENDPOINT,
MODELS_ENDPOINT=config.MODELS_ENDPOINT,
NATIVE_MODELS_ENDPOINT=getattr(
config,
"NATIVE_MODELS_ENDPOINT",
"/api/v0/models",
),

USE_SERVICE_AS_BRAIN=config.USE_SERVICE_AS_BRAIN,

SERVICE_API_BASE=config.SERVICE_API_BASE,
SERVICE_MODEL_UID=config.SERVICE_MODEL_UID,
SERVICE_CONTEXT_WINDOW=config.SERVICE_CONTEXT_WINDOW,
SERVICE_MAX_TOKENS=config.SERVICE_MAX_TOKENS,
SERVICE_REQUEST_TIMEOUT=config.SERVICE_REQUEST_TIMEOUT,

BRAIN_API_BASE=config.BRAIN_API_BASE,
BRAIN_MODEL_UID=config.BRAIN_MODEL_UID,
BRAIN_CONTEXT_WINDOW=config.BRAIN_CONTEXT_WINDOW,
BRAIN_MAX_TOKENS=config.BRAIN_MAX_TOKENS,
BRAIN_REQUEST_TIMEOUT=config.BRAIN_REQUEST_TIMEOUT,

TRANSLATOR_API_BASE=config.TRANSLATOR_API_BASE,
Expand All @@ -62,6 +76,22 @@ class AppSettings:
TRANSLATION_MIN_TOKENS=config.TRANSLATION_MIN_TOKENS,
TRANSLATION_MAX_TOKENS=config.TRANSLATION_MAX_TOKENS,

RUNTIME_OUTPUT_TOKEN_RESERVE=getattr(
config,
"RUNTIME_OUTPUT_TOKEN_RESERVE",
512,
),
RUNTIME_CONTEXT_WINDOW_FALLBACK_TO_SERVER=getattr(
config,
"RUNTIME_CONTEXT_WINDOW_FALLBACK_TO_SERVER",
True,
),
RUNTIME_MAX_TOKENS_FALLBACK_TO_SERVER=getattr(
config,
"RUNTIME_MAX_TOKENS_FALLBACK_TO_SERVER",
True,
),

SEARCH_PROVIDER=getattr(
config,
"SEARCH_PROVIDER",
Expand Down
Loading