Lucas ARRIESSE
commited on
Commit
·
d4b51a7
1
Parent(s):
103c3d9
wip
Browse files- app.py +8 -2
- prompts/if/format_requirements.txt +3 -3
- schemas.py +10 -5
app.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import asyncio
|
|
|
2 |
import logging
|
3 |
import os
|
4 |
import sys
|
@@ -330,8 +331,13 @@ async def search_solutions_if(req: SolutionSearchV2Request) -> SolutionSearchRes
|
|
330 |
fmt_model = InsightFinderConstraintsList.model_validate_json(
|
331 |
fmt_completion.choices[0].message.content)
|
332 |
|
|
|
|
|
|
|
|
|
333 |
# fetch technologies from insight finder
|
334 |
-
|
|
|
335 |
technologies = TechnologyData.model_validate(technologies_req.json())
|
336 |
|
337 |
# =============================================================== synthesize solution using LLM =========================================
|
@@ -364,7 +370,7 @@ async def search_solutions_if(req: SolutionSearchV2Request) -> SolutionSearchRes
|
|
364 |
|
365 |
return final_solution
|
366 |
|
367 |
-
tasks = await asyncio.gather(*[_search_solution_inner(cat) for cat in req.categories])
|
368 |
final_solutions = [sol for sol in tasks if not isinstance(sol, Exception)]
|
369 |
|
370 |
return SolutionSearchResponse(solutions=final_solutions)
|
|
|
1 |
import asyncio
|
2 |
+
import json
|
3 |
import logging
|
4 |
import os
|
5 |
import sys
|
|
|
331 |
fmt_model = InsightFinderConstraintsList.model_validate_json(
|
332 |
fmt_completion.choices[0].message.content)
|
333 |
|
334 |
+
out = {'constraints': {
|
335 |
+
cons.title: cons.description for cons in fmt_model.constraints}}
|
336 |
+
# logging.info(out)
|
337 |
+
|
338 |
# fetch technologies from insight finder
|
339 |
+
# translate from a structured output to a dict for insights finder
|
340 |
+
technologies_req = await http_client.post(INSIGHT_FINDER_BASE_URL + "process-constraints", content=json.dumps(out))
|
341 |
technologies = TechnologyData.model_validate(technologies_req.json())
|
342 |
|
343 |
# =============================================================== synthesize solution using LLM =========================================
|
|
|
370 |
|
371 |
return final_solution
|
372 |
|
373 |
+
tasks = await asyncio.gather(*[_search_solution_inner(cat) for cat in req.categories], return_exceptions=True)
|
374 |
final_solutions = [sol for sol in tasks if not isinstance(sol, Exception)]
|
375 |
|
376 |
return SolutionSearchResponse(solutions=final_solutions)
|
prompts/if/format_requirements.txt
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
<role>You are an expert system designer</role>
|
2 |
<task>
|
3 |
-
Your task is to
|
4 |
-
Give the
|
5 |
-
Give at most the 10
|
6 |
</task>
|
7 |
|
8 |
<requirements>
|
|
|
1 |
<role>You are an expert system designer</role>
|
2 |
<task>
|
3 |
+
Your task is to extract from a category of requirements the top most technical constraints that must be solved.
|
4 |
+
Give the most important constraints that must be solved to address the general problem of the category.
|
5 |
+
Give at most the 10 constraints.
|
6 |
</task>
|
7 |
|
8 |
<requirements>
|
schemas.py
CHANGED
@@ -138,9 +138,17 @@ class _RefinedSolutionModel(BaseModel):
|
|
138 |
|
139 |
# ================================================================= search solutions using insight finder endpoints
|
140 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
class InsightFinderConstraintsList(BaseModel):
|
142 |
-
constraints:
|
143 |
-
|
|
|
144 |
|
145 |
|
146 |
class Technology(BaseModel):
|
@@ -152,9 +160,6 @@ class Technology(BaseModel):
|
|
152 |
limitations: str
|
153 |
id: int
|
154 |
|
155 |
-
# This schema defines the root structure of the JSON
|
156 |
-
|
157 |
-
|
158 |
class TechnologyData(BaseModel):
|
159 |
"""Represents the top-level object containing a list of technologies."""
|
160 |
technologies: List[Technology]
|
|
|
138 |
|
139 |
# ================================================================= search solutions using insight finder endpoints
|
140 |
|
141 |
+
# Helpers to extract constraints for Insights Finder
|
142 |
+
|
143 |
+
class InsightFinderConstraintItem(BaseModel):
|
144 |
+
title: str
|
145 |
+
description: str
|
146 |
+
|
147 |
+
|
148 |
class InsightFinderConstraintsList(BaseModel):
|
149 |
+
constraints: list[InsightFinderConstraintItem]
|
150 |
+
|
151 |
+
# =================================================
|
152 |
|
153 |
|
154 |
class Technology(BaseModel):
|
|
|
160 |
limitations: str
|
161 |
id: int
|
162 |
|
|
|
|
|
|
|
163 |
class TechnologyData(BaseModel):
|
164 |
"""Represents the top-level object containing a list of technologies."""
|
165 |
technologies: List[Technology]
|