Skip to content

Commit 9b964bc

Browse files
authored
feat: OTel (#200)
1 parent 3a3821d commit 9b964bc

12 files changed

Lines changed: 3099 additions & 1992 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,5 @@ junit.xml
4242

4343
# Project-Specific
4444
/lettuce/tests/log
45-
/lettuce/log
45+
/lettuce/log
46+
lettuce-ui/search-results.csv

lettuce-ui/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Lettuce UI
2+
3+
A user interface for Lettuce, built with marimo.
4+
5+
To start the UI:
6+
```bash
7+
uv run lettuce-ui
8+
```
9+

lettuce/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ENV UV_CACHE_DIR=/tmp/uv_cache \
66

77
WORKDIR /src
88
COPY pyproject.toml ./
9-
RUN uv sync --no-dev --extra llama-cpu \
9+
RUN uv sync --no-dev --extra azure\
1010
&& rm -rf /tmp/uv_cache ~/.cache/pip \
1111
&& uv pip uninstall torch \
1212
&& uv pip install torch==2.7.1+cpu --index-url https://download.pytorch.org/whl/cpu

lettuce/api.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
import os
12
import secrets
23
import hashlib
34
from typing import Set
5+
46
from fastapi import FastAPI, Depends, HTTPException, status
57
from fastapi.middleware.cors import CORSMiddleware
68
from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
9+
from opentelemetry.instrumentation.fastapi import FastAPIInstrumentor
10+
711
from routers import search_routes
812
from options.base_options import BaseOptions
913
import importlib.metadata
@@ -12,6 +16,9 @@
1216

1317
security = HTTPBearer()
1418

19+
if os.getenv("APPLICATIONINSIGHTS_CONNECTION_STRING"):
20+
from azure.monitor.opentelemetry import configure_azure_monitor
21+
configure_azure_monitor()
1522

1623
def hash_api_key(api_key: str):
1724
"""Hash an API key for secure storage comparison."""
@@ -77,6 +84,8 @@ def verify_api_key(credentials: HTTPAuthorizationCredentials = Depends(security)
7784
dependencies=[Depends(verify_api_key)]
7885
)
7986

87+
FastAPIInstrumentor.instrument_app(app)
88+
8089
@app.get("/health")
8190
def healthcheck() -> dict[str, str]:
8291
"""

lettuce/components/models.py

Lines changed: 0 additions & 266 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from .connect import get_model, connect_to_ollama, connect_to_openai
2+
from .local_models import get_local_weights, download_model_from_huggingface
3+
4+
__all__ = [
5+
"get_model",
6+
"connect_to_openai",
7+
"connect_to_ollama",
8+
"get_local_weights",
9+
"download_model_from_huggingface"
10+
]

0 commit comments

Comments
 (0)