nexusbert commited on
Commit
4b0eec9
·
1 Parent(s): a5e847c
app/gemini_client.py CHANGED
@@ -78,7 +78,7 @@ def gemini_generate_text(
78
  system_instruction: str,
79
  user_text: str,
80
  temperature: float = 0.0,
81
- max_output_tokens: int = 4096, # 1. Provide plenty of output space
82
  response_schema: Any | None = None,
83
  ) -> str:
84
  from google.genai import types # type: ignore[import-untyped]
@@ -93,7 +93,7 @@ def gemini_generate_text(
93
  max_output_tokens=max_output_tokens,
94
  response_mime_type="application/json",
95
  response_schema=response_schema,
96
- # 2. Allocate thinking depth specifically for high-throughput structures
97
  thinking_config=types.ThinkingConfig(
98
  thinking_level="minimal" # Options: 'minimal' or 'low' to free up response tokens
99
  )
 
78
  system_instruction: str,
79
  user_text: str,
80
  temperature: float = 0.0,
81
+ max_output_tokens: int = 4096,
82
  response_schema: Any | None = None,
83
  ) -> str:
84
  from google.genai import types # type: ignore[import-untyped]
 
93
  max_output_tokens=max_output_tokens,
94
  response_mime_type="application/json",
95
  response_schema=response_schema,
96
+
97
  thinking_config=types.ThinkingConfig(
98
  thinking_level="minimal" # Options: 'minimal' or 'low' to free up response tokens
99
  )
app/main.py CHANGED
@@ -147,7 +147,7 @@ class RecommendationRequest(BaseModel):
147
  "city": None,
148
  "state": None,
149
  "chat_history": [],
150
- "top_k_retrieval": 6,
151
  "top_n_final": 5,
152
  }
153
  ]
 
147
  "city": None,
148
  "state": None,
149
  "chat_history": [],
150
+ "top_k_retrieval": 30,
151
  "top_n_final": 5,
152
  }
153
  ]
app/recommendation_pipeline.py CHANGED
@@ -15,9 +15,7 @@ from app.shared_models import embedding_model_name_task_b, get_embedder
15
 
16
  logger = logging.getLogger(__name__)
17
 
18
- # =========================================================
19
- # COMPETITION-READY STRUCTURED SCHEMA
20
- # =========================================================
21
  class RecommendationItem(BaseModel):
22
  business_id: str = Field(description="The unique identifier string of the recommended business.")
23
  rationale: str = Field(
@@ -34,9 +32,7 @@ class AgentRecommendationOutput(BaseModel):
34
  )
35
 
36
 
37
- # =========================================================
38
- # UTILS & VECTORRETRIEVAL (Maintained for Baseline Retrieval)
39
- # =========================================================
40
  def _resolve_catalog_path(raw: str) -> Path:
41
  p = Path(raw)
42
  if p.is_absolute():
@@ -186,7 +182,7 @@ Candidate Data Pools:
186
  ]
187
 
188
  results = []
189
- # Build final schema objects up to your pipeline boundary parameters
190
  for i, item in enumerate(recommendation_items[:top_n]):
191
  results.append({
192
  "business_id": item.get("business_id"),
@@ -224,7 +220,7 @@ class RecommendationService:
224
  city: str | None = None,
225
  state: str | None = None,
226
  chat_history: list[dict[str, str]] | None = None,
227
- top_k_retrieval: int = 6,
228
  top_n_final: int = 5,
229
  ) -> dict[str, Any]:
230
 
@@ -234,10 +230,10 @@ class RecommendationService:
234
  qtext = build_query_text(persona, chat_history)
235
  query_emb = embed_query_text(qtext)
236
 
237
- # Execution Step 1: Initial Contextual Candidate Retrieval (Vector Base)
238
  candidates = self.index.retrieve(query_emb, top_k_retrieval, city, state)
239
 
240
- # Execution Step 2: Agentic Personalization Reranking via Gemini
241
  ranked = chat_rank_gemini(
242
  persona=persona,
243
  chat_history=chat_history,
 
15
 
16
  logger = logging.getLogger(__name__)
17
 
18
+
 
 
19
  class RecommendationItem(BaseModel):
20
  business_id: str = Field(description="The unique identifier string of the recommended business.")
21
  rationale: str = Field(
 
32
  )
33
 
34
 
35
+
 
 
36
  def _resolve_catalog_path(raw: str) -> Path:
37
  p = Path(raw)
38
  if p.is_absolute():
 
182
  ]
183
 
184
  results = []
185
+
186
  for i, item in enumerate(recommendation_items[:top_n]):
187
  results.append({
188
  "business_id": item.get("business_id"),
 
220
  city: str | None = None,
221
  state: str | None = None,
222
  chat_history: list[dict[str, str]] | None = None,
223
+ top_k_retrieval: int = 30,
224
  top_n_final: int = 5,
225
  ) -> dict[str, Any]:
226
 
 
230
  qtext = build_query_text(persona, chat_history)
231
  query_emb = embed_query_text(qtext)
232
 
233
+
234
  candidates = self.index.retrieve(query_emb, top_k_retrieval, city, state)
235
 
236
+
237
  ranked = chat_rank_gemini(
238
  persona=persona,
239
  chat_history=chat_history,