Open-source inference server and production cluster for all the models your agent needs.
Python bgecolbertdata-pipelinedeep-learningembeddingsinferenceinference-serverinformation-retrievalllmmlmlopsnatural-language-processingnlppythonrerankingretrievalretrieval-augmented-generationsemantic-searchspladevector-search
Remove unreachable /analyze-flavor-prompt endpoint
Filip Makradulid8b3ccd4f727
diff --git a/examples/wine-recommender/.env.example b/examples/wine-recommender/.env.exampleindex a9111a50a..495ed58ea 100644--- a/examples/wine-recommender/.env.example+++ b/examples/wine-recommender/.env.example@@ -36,10 +36,3 @@ CUSTOM_RERANK_NO_REVIEW_PENALTY=0.5# --- SIE runtime options ---SIE_GPU=l4-spotSIE_PROVISION_TIMEOUT_S=900--# --- OpenAI (optional) ----# Only required for the /analyze-flavor-prompt endpoint, which turns a-# natural-language wine description into structure and flavor weights.-# Get a key at https://platform.openai.com/api-keys.-# Leave this unset if you don't need the natural-language prompt feature.-OPENAI_API_KEY=your-openai-api-keydiff --git a/examples/wine-recommender/README.md b/examples/wine-recommender/README.mdindex 27cde4cc2..8a6c6919b 100644--- a/examples/wine-recommender/README.md+++ b/examples/wine-recommender/README.md@@ -90,10 +90,6 @@ Background on the SIE primitives this demo uses:- [`score`](https://sie.dev/docs/score) - cross-encoder reranking (used by the "standard" reranker)- [`extract`](https://sie.dev/docs/extract) - OCR-style extraction on wine label images-### Optional: OpenAI API key--The `/analyze-flavor-prompt` endpoint turns a natural-language wine description into structure and flavor weights using `gpt-4.1-mini`. This is optional - the rest of the demo works without it. Set `OPENAI_API_KEY` in your `.env` only if you want to use the natural-language prompt feature. Get a key at [platform.openai.com/api-keys](https://platform.openai.com/api-keys).-### Docker and Docker ComposeYou need Docker and Docker Compose v2 installed. The backend builds against `python:3.12-slim`, so no local Python setup is required.diff --git a/examples/wine-recommender/app.py b/examples/wine-recommender/app.pyindex c6325884f..38d938460 100644--- a/examples/wine-recommender/app.py+++ b/examples/wine-recommender/app.py@@ -9,10 +9,9 @@ from uuid import uuid4import pandas as pdimport uvicornfrom dotenv import load_dotenv-from fastapi import FastAPI, File, HTTPException, UploadFile+from fastapi import FastAPI, File, UploadFilefrom fastapi.encoders import jsonable_encoderfrom fastapi.middleware.cors import CORSMiddleware-from openai import OpenAIfrom pydantic import BaseModel, Fieldfrom wine_flavor import datasource, servicefrom wine_picture_detection import detect_wine_from_image_bytes@@ -104,10 +103,6 @@ class RecommendationRequest(BaseModel):top_k: int = Field(default=COSINE_TOP_K, ge=1, le=50)-class FlavorPromptRequest(BaseModel):- prompt: str = Field(min_length=1, max_length=500)--class DemoCatalog:def __init__(self):self._lock = Lock()@@ -379,41 +374,6 @@ def _build_flavor_tags(wines):]-def _prompt_flavor_adjustment(prompt: str, available_flavors: list[str]) -> dict:- api_key = os.getenv("OPENAI_API_KEY")- if not api_key:- raise ValueError("Missing required environment variable: OPENAI_API_KEY")-- client = OpenAI(api_key=api_key)- response = client.responses.create(- model="gpt-4.1-mini",- text={"format": {"type": "json_object"}},- input=[- {- "role": "system",- "content": (- "Return only JSON with keys structure and flavors. "- "Structure must contain acidity, fizziness, intensity, sweetness, tannin as integers from 0 to 100. "- "Flavors must be an array of up to 8 strings chosen only from the provided list."- ),- },- {- "role": "user",- "content": f"Prompt: {prompt}\nAvailable flavors: {', '.join(available_flavors[:250])}",- },- ],- )-- output_text = (response.output_text or "").strip()- if not output_text:- raise ValueError("OpenAI returned an empty response")-- try:- return json.loads(output_text)- except json.JSONDecodeError as exc:- raise ValueError(f"OpenAI returned invalid JSON: {output_text}") from exc--def _to_recommendation_record(record):score = float(record.get("rerank_score") or 0.0)return {@@ -507,41 +467,6 @@ def recommendations(payload: RecommendationRequest):)[email protected]("/analyze-flavor-prompt")-def analyze_flavor_prompt(payload: FlavorPromptRequest):- catalog.load()- available_flavors = sorted(set(catalog.unique_flavors or []))- available_flavors_set = set(available_flavors)-- try:- result = _prompt_flavor_adjustment(payload.prompt, available_flavors)- except ValueError as exc:- raise HTTPException(status_code=500, detail=str(exc)) from exc- except Exception as exc:- raise HTTPException(- status_code=502, detail=f"Prompt analysis failed: {exc}"- ) from exc-- structure = result.get("structure") or {}- flavors = [- flavor- for flavor in (result.get("flavors") or [])- if flavor in available_flavors_set- ]- return jsonable_encoder(- {- "structure": {- "acidity": max(0, min(100, int(structure.get("acidity", 50)))),- "fizziness": max(0, min(100, int(structure.get("fizziness", 0)))),- "intensity": max(0, min(100, int(structure.get("intensity", 50)))),- "sweetness": max(0, min(100, int(structure.get("sweetness", 10)))),- "tannin": max(0, min(100, int(structure.get("tannin", 50)))),- },- "flavors": flavors[:8],- }- )--@app.post("/detect-wine-image")async def detect_wine_image(file: UploadFile = File(...)):catalog.load()diff --git a/examples/wine-recommender/requirements.txt b/examples/wine-recommender/requirements.txtindex a8b784ebb..c745e6047 100644--- a/examples/wine-recommender/requirements.txt+++ b/examples/wine-recommender/requirements.txt@@ -26,7 +26,6 @@ msgpack-numpy==0.4.8multidict==6.7.1networkx==3.6.1numpy==2.2.6-openai==2.30.0opencv-python==4.12.0.88packaging==26.0pandas==3.0.1