Lucas ARRIESSE
commited on
Commit
·
8cc6fe4
1
Parent(s):
be1521a
Fix references extraction
Browse files- app.py +4 -2
- schemas.py +1 -1
app.py
CHANGED
@@ -111,6 +111,7 @@ async def categorize_reqs(params: ReqGroupingRequest) -> ReqGroupingResponse:
|
|
111 |
|
112 |
# ========================================================= Solution Endpoints ===========================================================
|
113 |
|
|
|
114 |
@solution_router.post("/search_solutions_gemini", response_model=SolutionSearchResponse)
|
115 |
async def search_solutions(params: ReqGroupingResponse) -> SolutionSearchResponse:
|
116 |
"""Searches solutions using Gemini and grounded on google search"""
|
@@ -144,8 +145,8 @@ async def search_solutions(params: ReqGroupingResponse) -> SolutionSearchRespons
|
|
144 |
# ======================== build the final solution object ================================
|
145 |
|
146 |
# extract the source metadata from the search items
|
147 |
-
sources_metadata = [
|
148 |
-
|
149 |
|
150 |
final_sol = SolutionModel(
|
151 |
Context="",
|
@@ -166,6 +167,7 @@ async def search_solutions(params: ReqGroupingResponse) -> SolutionSearchRespons
|
|
166 |
|
167 |
return SolutionSearchResponse(solutions=final_solutions)
|
168 |
|
|
|
169 |
@solution_router.post("/criticize_solution", response_model=CritiqueResponse)
|
170 |
async def criticize_solution(params: CriticizeSolutionsRequest) -> CritiqueResponse:
|
171 |
"""Criticize the challenges, weaknesses and limitations of the provided solutions."""
|
|
|
111 |
|
112 |
# ========================================================= Solution Endpoints ===========================================================
|
113 |
|
114 |
+
|
115 |
@solution_router.post("/search_solutions_gemini", response_model=SolutionSearchResponse)
|
116 |
async def search_solutions(params: ReqGroupingResponse) -> SolutionSearchResponse:
|
117 |
"""Searches solutions using Gemini and grounded on google search"""
|
|
|
145 |
# ======================== build the final solution object ================================
|
146 |
|
147 |
# extract the source metadata from the search items
|
148 |
+
sources_metadata = [{"name": a["web"]["title"], "url": a["web"]["uri"]}
|
149 |
+
for a in req_completion["vertex_ai_grounding_metadata"][0]['groundingChunks']]
|
150 |
|
151 |
final_sol = SolutionModel(
|
152 |
Context="",
|
|
|
167 |
|
168 |
return SolutionSearchResponse(solutions=final_solutions)
|
169 |
|
170 |
+
|
171 |
@solution_router.post("/criticize_solution", response_model=CritiqueResponse)
|
172 |
async def criticize_solution(params: CriticizeSolutionsRequest) -> CritiqueResponse:
|
173 |
"""Criticize the challenges, weaknesses and limitations of the provided solutions."""
|
schemas.py
CHANGED
@@ -29,7 +29,7 @@ class SolutionModel(BaseModel):
|
|
29 |
description="Description of the problem being solved.")
|
30 |
Solution_Description: str = Field(..., alias="Solution Description",
|
31 |
description="Detailed description of the solution.")
|
32 |
-
References: list[
|
33 |
..., description="References to documents used for the solution.")
|
34 |
Category_Id: int = Field(
|
35 |
..., description="ID of the requirements category the solution is based on")
|
|
|
29 |
description="Description of the problem being solved.")
|
30 |
Solution_Description: str = Field(..., alias="Solution Description",
|
31 |
description="Detailed description of the solution.")
|
32 |
+
References: list[dict] = Field(
|
33 |
..., description="References to documents used for the solution.")
|
34 |
Category_Id: int = Field(
|
35 |
..., description="ID of the requirements category the solution is based on")
|