Lucas ARRIESSE
commited on
Commit
·
f6bffda
1
Parent(s):
5ef0f8d
Merge all API endpoints into the app API
Browse files- api/docs.py +1 -1
- api/requirements.py +65 -5
- api/solutions.py +219 -0
- app.py +2 -0
- dependencies.py +24 -1
- index.html +0 -341
- prompts/classify.txt +21 -0
- prompts/criticize.txt +21 -0
- prompts/if/format_requirements.txt +23 -0
- prompts/if/synthesize_solution.txt +43 -0
- prompts/refine_solution.txt +45 -0
- prompts/search_solution.txt +23 -0
- prompts/search_solution_v2.txt +31 -0
- prompts/structure_solution.txt +12 -0
- requirements.txt +2 -1
- schemas.py +166 -8
- static/js/script.js +4 -4
api/docs.py
CHANGED
@@ -26,7 +26,7 @@ from litellm.router import Router
|
|
26 |
from schemas import DataRequest, DataResponse, DocRequirements, DownloadRequest, MeetingsRequest, MeetingsResponse, RequirementsRequest, RequirementsResponse
|
27 |
|
28 |
# API router for requirement extraction from docs / doc list retrieval / download
|
29 |
-
router = APIRouter()
|
30 |
|
31 |
# ==================================================== Utilities =================================================================
|
32 |
|
|
|
26 |
from schemas import DataRequest, DataResponse, DocRequirements, DownloadRequest, MeetingsRequest, MeetingsResponse, RequirementsRequest, RequirementsResponse
|
27 |
|
28 |
# API router for requirement extraction from docs / doc list retrieval / download
|
29 |
+
router = APIRouter(tags=["document extraction"])
|
30 |
|
31 |
# ==================================================== Utilities =================================================================
|
32 |
|
api/requirements.py
CHANGED
@@ -1,10 +1,11 @@
|
|
1 |
from fastapi import APIRouter, Depends, HTTPException
|
|
|
2 |
from litellm.router import Router
|
3 |
-
from dependencies import get_llm_router
|
4 |
-
from schemas import ReqSearchLLMResponse, ReqSearchRequest, ReqSearchResponse
|
5 |
|
6 |
-
# Router for
|
7 |
-
router = APIRouter()
|
8 |
|
9 |
|
10 |
@router.post("/get_reqs_from_query", response_model=ReqSearchResponse)
|
@@ -16,7 +17,6 @@ def find_requirements_from_problem_description(req: ReqSearchRequest, llm_router
|
|
16 |
|
17 |
requirements_text = "\n".join(
|
18 |
[f"[Selection ID: {r.req_id} | Document: {r.document} | Context: {r.context} | Requirement: {r.requirement}]" for r in requirements])
|
19 |
-
print("Called the LLM")
|
20 |
resp_ai = llm_router.completion(
|
21 |
model="gemini-v2",
|
22 |
messages=[{"role": "user", "content": f"Given all the requirements : \n {requirements_text} \n and the problem description \"{query}\", return a list of 'Selection ID' for the most relevant corresponding requirements that reference or best cover the problem. If none of the requirements covers the problem, simply return an empty list"}],
|
@@ -33,3 +33,63 @@ def find_requirements_from_problem_description(req: ReqSearchRequest, llm_router
|
|
33 |
status_code=500, detail="LLM error : Generated a wrong index, please try again.")
|
34 |
|
35 |
return ReqSearchResponse(requirements=[requirements[i] for i in out_llm])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
from fastapi import APIRouter, Depends, HTTPException
|
2 |
+
from jinja2 import Environment
|
3 |
from litellm.router import Router
|
4 |
+
from dependencies import get_llm_router, get_prompt_templates
|
5 |
+
from schemas import _ReqGroupingCategory, _ReqGroupingOutput, ReqGroupingCategory, ReqGroupingRequest, ReqGroupingResponse, ReqSearchLLMResponse, ReqSearchRequest, ReqSearchResponse
|
6 |
|
7 |
+
# Router for requirement processing
|
8 |
+
router = APIRouter(tags=["requirement processing"])
|
9 |
|
10 |
|
11 |
@router.post("/get_reqs_from_query", response_model=ReqSearchResponse)
|
|
|
17 |
|
18 |
requirements_text = "\n".join(
|
19 |
[f"[Selection ID: {r.req_id} | Document: {r.document} | Context: {r.context} | Requirement: {r.requirement}]" for r in requirements])
|
|
|
20 |
resp_ai = llm_router.completion(
|
21 |
model="gemini-v2",
|
22 |
messages=[{"role": "user", "content": f"Given all the requirements : \n {requirements_text} \n and the problem description \"{query}\", return a list of 'Selection ID' for the most relevant corresponding requirements that reference or best cover the problem. If none of the requirements covers the problem, simply return an empty list"}],
|
|
|
33 |
status_code=500, detail="LLM error : Generated a wrong index, please try again.")
|
34 |
|
35 |
return ReqSearchResponse(requirements=[requirements[i] for i in out_llm])
|
36 |
+
|
37 |
+
|
38 |
+
@router.post("/categorize_requirements")
|
39 |
+
async def categorize_reqs(params: ReqGroupingRequest, prompt_env: Environment = Depends(get_prompt_templates), llm_router: Router = Depends(get_llm_router)) -> ReqGroupingResponse:
|
40 |
+
"""Categorize the given service requirements into categories"""
|
41 |
+
|
42 |
+
MAX_ATTEMPTS = 5
|
43 |
+
|
44 |
+
categories: list[_ReqGroupingCategory] = []
|
45 |
+
messages = []
|
46 |
+
|
47 |
+
# categorize the requirements using their indices
|
48 |
+
req_prompt = await prompt_env.get_template("classify.txt").render_async(**{
|
49 |
+
"requirements": [rq.model_dump() for rq in params.requirements],
|
50 |
+
"max_n_categories": params.max_n_categories,
|
51 |
+
"response_schema": _ReqGroupingOutput.model_json_schema()})
|
52 |
+
|
53 |
+
# add system prompt with requirements
|
54 |
+
messages.append({"role": "user", "content": req_prompt})
|
55 |
+
|
56 |
+
# ensure all requirements items are processed
|
57 |
+
for attempt in range(MAX_ATTEMPTS):
|
58 |
+
req_completion = await llm_router.acompletion(model="gemini-v2", messages=messages, response_format=_ReqGroupingOutput)
|
59 |
+
output = _ReqGroupingOutput.model_validate_json(
|
60 |
+
req_completion.choices[0].message.content)
|
61 |
+
|
62 |
+
# quick check to ensure no requirement was left out by the LLM by checking all IDs are contained in at least a single category
|
63 |
+
valid_ids_universe = set(range(0, len(params.requirements)))
|
64 |
+
assigned_ids = {
|
65 |
+
req_id for cat in output.categories for req_id in cat.items}
|
66 |
+
|
67 |
+
# keep only non-hallucinated, valid assigned ids
|
68 |
+
valid_assigned_ids = assigned_ids.intersection(valid_ids_universe)
|
69 |
+
|
70 |
+
# check for remaining requirements assigned to none of the categories
|
71 |
+
unassigned_ids = valid_ids_universe - valid_assigned_ids
|
72 |
+
|
73 |
+
if len(unassigned_ids) == 0:
|
74 |
+
categories.extend(output.categories)
|
75 |
+
break
|
76 |
+
else:
|
77 |
+
messages.append(req_completion.choices[0].message)
|
78 |
+
messages.append(
|
79 |
+
{"role": "user", "content": f"You haven't categorized the following requirements in at least one category {unassigned_ids}. Please do so."})
|
80 |
+
|
81 |
+
if attempt == MAX_ATTEMPTS - 1:
|
82 |
+
raise Exception("Failed to classify all requirements")
|
83 |
+
|
84 |
+
# build the final category objects
|
85 |
+
# remove the invalid (likely hallucinated) requirement IDs
|
86 |
+
final_categories = []
|
87 |
+
for idx, cat in enumerate(output.categories):
|
88 |
+
final_categories.append(ReqGroupingCategory(
|
89 |
+
id=idx,
|
90 |
+
title=cat.title,
|
91 |
+
requirements=[params.requirements[i]
|
92 |
+
for i in cat.items if i < len(params.requirements)]
|
93 |
+
))
|
94 |
+
|
95 |
+
return ReqGroupingResponse(categories=final_categories)
|
api/solutions.py
ADDED
@@ -0,0 +1,219 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import asyncio
|
2 |
+
import json
|
3 |
+
import logging
|
4 |
+
from fastapi import APIRouter, Depends, HTTPException
|
5 |
+
from httpx import AsyncClient
|
6 |
+
from jinja2 import Environment
|
7 |
+
from litellm.router import Router
|
8 |
+
from dependencies import INSIGHT_FINDER_BASE_URL, get_http_client, get_llm_router, get_prompt_templates
|
9 |
+
from typing import Awaitable, Callable, TypeVar
|
10 |
+
from schemas import _RefinedSolutionModel, _ReqGroupingCategory, _ReqGroupingOutput, _SearchedSolutionModel, _SolutionCriticismOutput, CriticizeSolutionsRequest, CritiqueResponse, InsightFinderConstraintsList, ReqGroupingCategory, ReqGroupingRequest, ReqGroupingResponse, ReqSearchLLMResponse, ReqSearchRequest, ReqSearchResponse, SolutionCriticism, SolutionModel, SolutionSearchResponse, SolutionSearchV2Request, TechnologyData
|
11 |
+
|
12 |
+
# Router for solution generation and critique
|
13 |
+
router = APIRouter(tags=["solution generation and critique"])
|
14 |
+
|
15 |
+
|
16 |
+
# ============== utilities =======================
|
17 |
+
T = TypeVar("T")
|
18 |
+
A = TypeVar("A")
|
19 |
+
|
20 |
+
|
21 |
+
async def retry_until(
|
22 |
+
func: Callable[[A], Awaitable[T]],
|
23 |
+
arg: A,
|
24 |
+
predicate: Callable[[T], bool],
|
25 |
+
max_retries: int,
|
26 |
+
) -> T:
|
27 |
+
"""Retries the given async function until the passed in validation predicate returns true."""
|
28 |
+
last_value = await func(arg)
|
29 |
+
for _ in range(max_retries):
|
30 |
+
if predicate(last_value):
|
31 |
+
return last_value
|
32 |
+
last_value = await func(arg)
|
33 |
+
return last_value
|
34 |
+
|
35 |
+
# =================================================
|
36 |
+
|
37 |
+
|
38 |
+
@router.post("/search_solutions_gemini/v2", response_model=SolutionSearchResponse)
|
39 |
+
async def search_solutions(params: SolutionSearchV2Request, prompt_env: Environment = Depends(get_prompt_templates), llm_router: Router = Depends(get_llm_router)) -> SolutionSearchResponse:
|
40 |
+
"""Searches solutions solving the given grouping params and respecting the user constraints using Gemini and grounded on google search"""
|
41 |
+
|
42 |
+
logging.info(f"Searching solutions for categories: {params}")
|
43 |
+
|
44 |
+
async def _search_inner(cat: ReqGroupingCategory) -> SolutionModel:
|
45 |
+
# ================== generate the solution with web grounding
|
46 |
+
req_prompt = await prompt_env.get_template("search_solution_v2.txt").render_async(**{
|
47 |
+
"category": cat.model_dump(),
|
48 |
+
"user_constraints": params.user_constraints,
|
49 |
+
})
|
50 |
+
|
51 |
+
# generate the completion in non-structured mode.
|
52 |
+
# the googleSearch tool enables grounding gemini with google search
|
53 |
+
# this also forces gemini to perform a tool call
|
54 |
+
req_completion = await llm_router.acompletion(model="gemini-v2", messages=[
|
55 |
+
{"role": "user", "content": req_prompt}
|
56 |
+
], tools=[{"googleSearch": {}}], tool_choice="required")
|
57 |
+
|
58 |
+
# ==================== structure the solution as a json ===================================
|
59 |
+
|
60 |
+
structured_prompt = await prompt_env.get_template("structure_solution.txt").render_async(**{
|
61 |
+
"solution": req_completion.choices[0].message.content,
|
62 |
+
"response_schema": _SearchedSolutionModel.model_json_schema()
|
63 |
+
})
|
64 |
+
|
65 |
+
structured_completion = await llm_router.acompletion(model="gemini-v2", messages=[
|
66 |
+
{"role": "user", "content": structured_prompt}
|
67 |
+
], response_format=_SearchedSolutionModel)
|
68 |
+
solution_model = _SearchedSolutionModel.model_validate_json(
|
69 |
+
structured_completion.choices[0].message.content)
|
70 |
+
|
71 |
+
# ======================== build the final solution object ================================
|
72 |
+
|
73 |
+
sources_metadata = []
|
74 |
+
# extract the source metadata from the search items, if gemini actually called the tools to search .... and didn't hallucinated
|
75 |
+
try:
|
76 |
+
sources_metadata.extend([{"name": a["web"]["title"], "url": a["web"]["uri"]}
|
77 |
+
for a in req_completion["vertex_ai_grounding_metadata"][0]['groundingChunks']])
|
78 |
+
except KeyError as ke:
|
79 |
+
pass
|
80 |
+
|
81 |
+
final_sol = SolutionModel(
|
82 |
+
Context="",
|
83 |
+
Requirements=[
|
84 |
+
cat.requirements[i].requirement for i in solution_model.requirement_ids
|
85 |
+
],
|
86 |
+
Problem_Description=solution_model.problem_description,
|
87 |
+
Solution_Description=solution_model.solution_description,
|
88 |
+
References=sources_metadata,
|
89 |
+
Category_Id=cat.id,
|
90 |
+
)
|
91 |
+
return final_sol
|
92 |
+
|
93 |
+
solutions = await asyncio.gather(*[retry_until(_search_inner, cat, lambda v: len(v.References) > 0, 2) for cat in params.categories], return_exceptions=True)
|
94 |
+
logging.info(solutions)
|
95 |
+
final_solutions = [
|
96 |
+
sol for sol in solutions if not isinstance(sol, Exception)]
|
97 |
+
|
98 |
+
return SolutionSearchResponse(solutions=final_solutions)
|
99 |
+
|
100 |
+
|
101 |
+
@router.post("/criticize_solution", response_model=CritiqueResponse)
|
102 |
+
async def criticize_solution(params: CriticizeSolutionsRequest, prompt_env: Environment = Depends(get_prompt_templates), llm_router: Router = Depends(get_llm_router)) -> CritiqueResponse:
|
103 |
+
"""Criticize the challenges, weaknesses and limitations of the provided solutions."""
|
104 |
+
|
105 |
+
async def __criticize_single(solution: SolutionModel):
|
106 |
+
req_prompt = await prompt_env.get_template("criticize.txt").render_async(**{
|
107 |
+
"solutions": [solution.model_dump()],
|
108 |
+
"response_schema": _SolutionCriticismOutput.model_json_schema()
|
109 |
+
})
|
110 |
+
|
111 |
+
req_completion = await llm_router.acompletion(
|
112 |
+
model="gemini-v2",
|
113 |
+
messages=[{"role": "user", "content": req_prompt}],
|
114 |
+
response_format=_SolutionCriticismOutput
|
115 |
+
)
|
116 |
+
|
117 |
+
criticism_out = _SolutionCriticismOutput.model_validate_json(
|
118 |
+
req_completion.choices[0].message.content
|
119 |
+
)
|
120 |
+
|
121 |
+
return SolutionCriticism(solution=solution, criticism=criticism_out.criticisms[0])
|
122 |
+
|
123 |
+
critiques = await asyncio.gather(*[__criticize_single(sol) for sol in params.solutions], return_exceptions=False)
|
124 |
+
return CritiqueResponse(critiques=critiques)
|
125 |
+
|
126 |
+
|
127 |
+
# =================================================================== Refine solution ====================================
|
128 |
+
|
129 |
+
@router.post("/refine_solutions", response_model=SolutionSearchResponse)
|
130 |
+
async def refine_solutions(params: CritiqueResponse, prompt_env: Environment = Depends(get_prompt_templates), llm_router: Router = Depends(get_llm_router)) -> SolutionSearchResponse:
|
131 |
+
"""Refines the previously critiqued solutions."""
|
132 |
+
|
133 |
+
async def __refine_solution(crit: SolutionCriticism):
|
134 |
+
req_prompt = await prompt_env.get_template("refine_solution.txt").render_async(**{
|
135 |
+
"solution": crit.solution.model_dump(),
|
136 |
+
"criticism": crit.criticism,
|
137 |
+
"response_schema": _RefinedSolutionModel.model_json_schema(),
|
138 |
+
})
|
139 |
+
|
140 |
+
req_completion = await llm_router.acompletion(model="gemini-v2", messages=[
|
141 |
+
{"role": "user", "content": req_prompt}
|
142 |
+
], response_format=_RefinedSolutionModel)
|
143 |
+
|
144 |
+
req_model = _RefinedSolutionModel.model_validate_json(
|
145 |
+
req_completion.choices[0].message.content)
|
146 |
+
|
147 |
+
# copy previous solution model
|
148 |
+
refined_solution = crit.solution.model_copy(deep=True)
|
149 |
+
refined_solution.Problem_Description = req_model.problem_description
|
150 |
+
refined_solution.Solution_Description = req_model.solution_description
|
151 |
+
|
152 |
+
return refined_solution
|
153 |
+
|
154 |
+
refined_solutions = await asyncio.gather(*[__refine_solution(crit) for crit in params.critiques], return_exceptions=False)
|
155 |
+
|
156 |
+
return SolutionSearchResponse(solutions=refined_solutions)
|
157 |
+
|
158 |
+
# =============================================================== Search solutions =========================================
|
159 |
+
|
160 |
+
|
161 |
+
@router.post("/search_solutions_if")
|
162 |
+
async def search_solutions_if(req: SolutionSearchV2Request, prompt_env: Environment = Depends(get_prompt_templates), llm_router: Router = Depends(get_llm_router), http_client: AsyncClient = Depends(get_http_client)) -> SolutionSearchResponse:
|
163 |
+
|
164 |
+
async def _search_solution_inner(cat: ReqGroupingCategory):
|
165 |
+
# process requirements into insight finder format
|
166 |
+
fmt_completion = await llm_router.acompletion("gemini-v2", messages=[
|
167 |
+
{
|
168 |
+
"role": "user",
|
169 |
+
"content": await prompt_env.get_template("if/format_requirements.txt").render_async(**{
|
170 |
+
"category": cat.model_dump(),
|
171 |
+
"response_schema": InsightFinderConstraintsList.model_json_schema()
|
172 |
+
})
|
173 |
+
}], response_format=InsightFinderConstraintsList)
|
174 |
+
|
175 |
+
fmt_model = InsightFinderConstraintsList.model_validate_json(
|
176 |
+
fmt_completion.choices[0].message.content)
|
177 |
+
|
178 |
+
# translate from a structured output to a dict for insights finder
|
179 |
+
formatted_constraints = {'constraints': {
|
180 |
+
cons.title: cons.description for cons in fmt_model.constraints}}
|
181 |
+
|
182 |
+
# fetch technologies from insight finder
|
183 |
+
technologies_req = await http_client.post(INSIGHT_FINDER_BASE_URL + "process-constraints", content=json.dumps(formatted_constraints))
|
184 |
+
technologies = TechnologyData.model_validate(technologies_req.json())
|
185 |
+
|
186 |
+
# =============================================================== synthesize solution using LLM =========================================
|
187 |
+
|
188 |
+
format_solution = await llm_router.acompletion("gemini-v2", messages=[{
|
189 |
+
"role": "user",
|
190 |
+
"content": await prompt_env.get_template("if/synthesize_solution.txt").render_async(**{
|
191 |
+
"category": cat.model_dump(),
|
192 |
+
"technologies": technologies.model_dump()["technologies"],
|
193 |
+
"user_constraints": req.user_constraints,
|
194 |
+
"response_schema": _SearchedSolutionModel.model_json_schema()
|
195 |
+
})}
|
196 |
+
], response_format=_SearchedSolutionModel)
|
197 |
+
|
198 |
+
format_solution_model = _SearchedSolutionModel.model_validate_json(
|
199 |
+
format_solution.choices[0].message.content)
|
200 |
+
|
201 |
+
final_solution = SolutionModel(
|
202 |
+
Context="",
|
203 |
+
Requirements=[
|
204 |
+
cat.requirements[i].requirement for i in format_solution_model.requirement_ids
|
205 |
+
],
|
206 |
+
Problem_Description=format_solution_model.problem_description,
|
207 |
+
Solution_Description=format_solution_model.solution_description,
|
208 |
+
References=[],
|
209 |
+
Category_Id=cat.id,
|
210 |
+
)
|
211 |
+
|
212 |
+
# ========================================================================================================================================
|
213 |
+
|
214 |
+
return final_solution
|
215 |
+
|
216 |
+
tasks = await asyncio.gather(*[_search_solution_inner(cat) for cat in req.categories], return_exceptions=True)
|
217 |
+
final_solutions = [sol for sol in tasks if not isinstance(sol, Exception)]
|
218 |
+
|
219 |
+
return SolutionSearchResponse(solutions=final_solutions)
|
app.py
CHANGED
@@ -7,6 +7,7 @@ import warnings
|
|
7 |
import os
|
8 |
from fastapi import Depends, FastAPI, BackgroundTasks, HTTPException, Request
|
9 |
from fastapi.staticfiles import StaticFiles
|
|
|
10 |
from dependencies import get_llm_router, init_dependencies
|
11 |
import api.docs
|
12 |
import api.requirements
|
@@ -43,4 +44,5 @@ app.add_middleware(CORSMiddleware, allow_credentials=True, allow_headers=[
|
|
43 |
|
44 |
app.include_router(api.docs.router, prefix="/docs")
|
45 |
app.include_router(api.requirements.router, prefix="/requirements")
|
|
|
46 |
app.mount("/", StaticFiles(directory="static", html=True), name="static")
|
|
|
7 |
import os
|
8 |
from fastapi import Depends, FastAPI, BackgroundTasks, HTTPException, Request
|
9 |
from fastapi.staticfiles import StaticFiles
|
10 |
+
import api.solutions
|
11 |
from dependencies import get_llm_router, init_dependencies
|
12 |
import api.docs
|
13 |
import api.requirements
|
|
|
44 |
|
45 |
app.include_router(api.docs.router, prefix="/docs")
|
46 |
app.include_router(api.requirements.router, prefix="/requirements")
|
47 |
+
app.include_router(api.solutions.router, prefix="/solutions")
|
48 |
app.mount("/", StaticFiles(directory="static", html=True), name="static")
|
dependencies.py
CHANGED
@@ -1,15 +1,22 @@
|
|
1 |
import os
|
|
|
2 |
from litellm.router import Router
|
|
|
3 |
|
4 |
# Declare all global app dependencies here
|
5 |
# - Setup your dependency global inside init_dependencies()
|
6 |
# - Create a get_xxxx_() function to retrieve the dependency inside the FastAPI router
|
7 |
|
8 |
|
|
|
|
|
9 |
def init_dependencies():
|
10 |
"""Initialize the application global dependencies"""
|
11 |
|
12 |
global llm_router
|
|
|
|
|
|
|
13 |
llm_router = Router(model_list=[
|
14 |
{
|
15 |
"model_name": "gemini-v1",
|
@@ -27,7 +34,7 @@ def init_dependencies():
|
|
27 |
"model_name": "gemini-v2",
|
28 |
"litellm_params":
|
29 |
{
|
30 |
-
"model": "gemini/gemini-2.5-flash",
|
31 |
"api_key": os.environ.get("GEMINI"),
|
32 |
"max_retries": 5,
|
33 |
"rpm": 10,
|
@@ -36,7 +43,23 @@ def init_dependencies():
|
|
36 |
}
|
37 |
}], fallbacks=[{"gemini-v2": ["gemini-v1"]}], num_retries=10, retry_after=30)
|
38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
def get_llm_router() -> Router:
|
41 |
"""Retrieves the LLM router"""
|
42 |
return llm_router
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import os
|
2 |
+
from httpx import AsyncClient
|
3 |
from litellm.router import Router
|
4 |
+
from jinja2 import Environment, StrictUndefined, FileSystemLoader
|
5 |
|
6 |
# Declare all global app dependencies here
|
7 |
# - Setup your dependency global inside init_dependencies()
|
8 |
# - Create a get_xxxx_() function to retrieve the dependency inside the FastAPI router
|
9 |
|
10 |
|
11 |
+
INSIGHT_FINDER_BASE_URL = "https://organizedprogrammers-insight-finder.hf.space/"
|
12 |
+
|
13 |
def init_dependencies():
|
14 |
"""Initialize the application global dependencies"""
|
15 |
|
16 |
global llm_router
|
17 |
+
global prompt_templates
|
18 |
+
global http_client
|
19 |
+
|
20 |
llm_router = Router(model_list=[
|
21 |
{
|
22 |
"model_name": "gemini-v1",
|
|
|
34 |
"model_name": "gemini-v2",
|
35 |
"litellm_params":
|
36 |
{
|
37 |
+
"model": "gemini/gemini-2.5-flash-lite-preview-06-17",
|
38 |
"api_key": os.environ.get("GEMINI"),
|
39 |
"max_retries": 5,
|
40 |
"rpm": 10,
|
|
|
43 |
}
|
44 |
}], fallbacks=[{"gemini-v2": ["gemini-v1"]}], num_retries=10, retry_after=30)
|
45 |
|
46 |
+
prompt_templates = Environment(loader=FileSystemLoader(
|
47 |
+
"prompts"), enable_async=True, undefined=StrictUndefined)
|
48 |
+
|
49 |
+
http_client = AsyncClient(verify=os.environ.get(
|
50 |
+
"NO_SSL", "0") == "1", timeout=None)
|
51 |
+
|
52 |
|
53 |
def get_llm_router() -> Router:
|
54 |
"""Retrieves the LLM router"""
|
55 |
return llm_router
|
56 |
+
|
57 |
+
|
58 |
+
def get_prompt_templates() -> Environment:
|
59 |
+
"""Retrieves the Jinja2 prompt templates environment"""
|
60 |
+
return prompt_templates
|
61 |
+
|
62 |
+
|
63 |
+
def get_http_client() -> AsyncClient:
|
64 |
+
"""Retrieves the HTTP Client"""
|
65 |
+
return http_client
|
index.html
DELETED
@@ -1,341 +0,0 @@
|
|
1 |
-
<!DOCTYPE html>
|
2 |
-
<html lang="fr">
|
3 |
-
|
4 |
-
<head>
|
5 |
-
<meta charset="UTF-8">
|
6 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
7 |
-
<title>Requirements Extractor</title>
|
8 |
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/marked/16.0.0/lib/marked.umd.min.js"
|
9 |
-
integrity="sha512-ygzQGrI/8Bfkm9ToUkBEuSMrapUZcHUys05feZh4ScVrKCYEXJsCBYNeVWZ0ghpH+n3Sl7OYlRZ/1ko01pYUCQ=="
|
10 |
-
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
11 |
-
<link href="https://cdn.jsdelivr.net/npm/daisyui@5" rel="stylesheet" type="text/css" />
|
12 |
-
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
|
13 |
-
</head>
|
14 |
-
|
15 |
-
<body class="bg-gray-100 min-h-screen">
|
16 |
-
<!-- Loading Overlay -->
|
17 |
-
<div id="loading-overlay" class="fixed inset-0 bg-black/50 flex items-center justify-center z-50 hidden">
|
18 |
-
<div class="bg-white p-6 rounded-lg shadow-lg text-center">
|
19 |
-
<span class="loading loading-spinner loading-xl"></span>
|
20 |
-
<p id="progress-text" class="text-gray-700">Chargement en cours...</p>
|
21 |
-
</div>
|
22 |
-
</div>
|
23 |
-
|
24 |
-
<div class="container mx-auto p-6">
|
25 |
-
<h1 class="text-3xl font-bold text-center mb-8">Requirements Extractor</h1>
|
26 |
-
<div id="selection-container" class="mb-6">
|
27 |
-
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-4">
|
28 |
-
<!-- Working Group -->
|
29 |
-
<div>
|
30 |
-
<label for="working-group-select" class="block text-sm font-medium text-gray-700 mb-2">Working
|
31 |
-
Group</label>
|
32 |
-
<select id="working-group-select" class="w-full p-2 border border-gray-300 rounded-md">
|
33 |
-
<option value="" selected>Select a working group</option>
|
34 |
-
<option value="SA1">SA1</option>
|
35 |
-
<option value="SA2">SA2</option>
|
36 |
-
<option value="SA3">SA3</option>
|
37 |
-
<option value="SA4">SA4</option>
|
38 |
-
<option value="SA5">SA5</option>
|
39 |
-
<option value="SA6">SA6</option>
|
40 |
-
<option value="CT1">CT1</option>
|
41 |
-
<option value="CT2">CT2</option>
|
42 |
-
<option value="CT3">CT3</option>
|
43 |
-
<option value="CT4">CT4</option>
|
44 |
-
<option value="CT5">CT5</option>
|
45 |
-
<option value="CT6">CT6</option>
|
46 |
-
<option value="RAN1">RAN1</option>
|
47 |
-
<option value="RAN2">RAN2</option>
|
48 |
-
</select>
|
49 |
-
</div>
|
50 |
-
|
51 |
-
<!-- Meeting -->
|
52 |
-
<div>
|
53 |
-
<label for="meeting-select" class="block text-sm font-medium text-gray-700 mb-2">Meeting</label>
|
54 |
-
<select id="meeting-select" class="w-full p-2 border border-gray-300 rounded-md">
|
55 |
-
<option value="">Select a meeting</option>
|
56 |
-
</select>
|
57 |
-
</div>
|
58 |
-
</div>
|
59 |
-
|
60 |
-
<!-- Buttons -->
|
61 |
-
<div class="flex flex-col sm:flex-row gap-2">
|
62 |
-
<!-- <button id="get-meetings-btn" class="px-4 py-2 bg-blue-500 text-white rounded-md hover:bg-blue-600">
|
63 |
-
Get Meetings
|
64 |
-
</button> -->
|
65 |
-
<button id="get-tdocs-btn" class="px-4 py-2 bg-green-500 text-white rounded-md hover:bg-green-600">
|
66 |
-
Get TDocs
|
67 |
-
</button>
|
68 |
-
</div>
|
69 |
-
</div>
|
70 |
-
|
71 |
-
<!-- Add an horizontal separation -->
|
72 |
-
<hr>
|
73 |
-
<!-- Tab list for subsections -->
|
74 |
-
<div role="tablist" class="tabs tabs-border tabs-xl" id="tab-container">
|
75 |
-
<a role="tab" class="tab tab-active" id="doc-table-tab" onclick="switchTab('doc-table-tab')">📝
|
76 |
-
Documents</a>
|
77 |
-
<a role="tab" class="tab tab-disabled" id="requirements-tab" onclick="switchTab('requirements-tab')">
|
78 |
-
<div class="flex items-center gap-1">
|
79 |
-
<div class="badge badge-neutral badge-outline badge-xs" id="requirements-tab-badge">0</div>
|
80 |
-
<span>Requirements</span>
|
81 |
-
</div>
|
82 |
-
</a>
|
83 |
-
<a role="tab" class="tab tab-disabled" id="solutions-tab" onclick="switchTab('solutions-tab')">Group and
|
84 |
-
Solve</a>
|
85 |
-
<a role="tab" class="tab tab-disabled" id="query-tab" onclick="switchTab('query-tab')">🔎 Find relevant
|
86 |
-
requirements</a>
|
87 |
-
</div>
|
88 |
-
|
89 |
-
<div id="doc-table-tab-contents" class="hidden">
|
90 |
-
<!-- Filters -->
|
91 |
-
<div id="filters-container" class="mb-6 hidden pt-10">
|
92 |
-
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
|
93 |
-
<!-- Type Filter Dropdown -->
|
94 |
-
<div class="dropdown dropdown-bottom dropdown-center w-full mb-4">
|
95 |
-
<div tabindex="0" role="button" class="btn w-full justify-between" id="doc-type-filter-btn">
|
96 |
-
<span id="doc-type-filter-label">Type</span>
|
97 |
-
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 ml-2" fill="none" viewBox="0 0 24 24"
|
98 |
-
stroke="currentColor">
|
99 |
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
100 |
-
d="M19 9l-7 7-7-7" />
|
101 |
-
</svg>
|
102 |
-
</div>
|
103 |
-
<ul tabindex="0"
|
104 |
-
class="dropdown-content z-[1] menu p-2 shadow bg-base-100 rounded-box w-full min-w-[200px] max-h-60 overflow-y-auto"
|
105 |
-
id="doc-type-filter-menu">
|
106 |
-
<!-- Rempli par JS -->
|
107 |
-
</ul>
|
108 |
-
</div>
|
109 |
-
|
110 |
-
<!-- Status Filter Dropdown -->
|
111 |
-
<div class="dropdown dropdown-bottom dropdown-center w-full mb-4">
|
112 |
-
<div tabindex="0" role="button" class="btn w-full justify-between" id="status-dropdown-btn">
|
113 |
-
<span id="status-filter-label">Status (Tous)</span>
|
114 |
-
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 ml-2" fill="none" viewBox="0 0 24 24"
|
115 |
-
stroke="currentColor">
|
116 |
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
117 |
-
d="M19 9l-7 7-7-7" />
|
118 |
-
</svg>
|
119 |
-
</div>
|
120 |
-
<ul tabindex="0"
|
121 |
-
class="dropdown-content z-[1] p-2 shadow bg-base-100 rounded-box w-full max-h-60 overflow-y-auto">
|
122 |
-
<li class="border-b pb-2 mb-2">
|
123 |
-
<label class="flex items-center gap-2 cursor-pointer">
|
124 |
-
<input type="checkbox" class="status-checkbox" value="all" checked>
|
125 |
-
<span class="font-semibold">Tous</span>
|
126 |
-
</label>
|
127 |
-
</li>
|
128 |
-
<div id="status-options" class="flex flex-col gap-1"></div>
|
129 |
-
</ul>
|
130 |
-
</div>
|
131 |
-
|
132 |
-
<!-- Agenda Item Filter Dropdown -->
|
133 |
-
<div class="dropdown dropdown-bottom dropdown-center w-full mb-4">
|
134 |
-
<div tabindex="0" role="button" class="btn w-full justify-between" id="agenda-dropdown-btn">
|
135 |
-
<span id="agenda-filter-label">Agenda Item (Tous)</span>
|
136 |
-
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 ml-2" fill="none" viewBox="0 0 24 24"
|
137 |
-
stroke="currentColor">
|
138 |
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
139 |
-
d="M19 9l-7 7-7-7" />
|
140 |
-
</svg>
|
141 |
-
</div>
|
142 |
-
<ul tabindex="0"
|
143 |
-
class="dropdown-content z-[1] p-2 shadow bg-base-100 rounded-box w-full max-h-60 overflow-y-auto">
|
144 |
-
<li class="border-b pb-2 mb-2">
|
145 |
-
<label class="flex items-center gap-2 cursor-pointer">
|
146 |
-
<input type="checkbox" class="agenda-checkbox" value="all" checked>
|
147 |
-
<span class="font-semibold">Tous</span>
|
148 |
-
</label>
|
149 |
-
</li>
|
150 |
-
<div id="agenda-options" class="flex flex-col gap-1"></div>
|
151 |
-
</ul>
|
152 |
-
</div>
|
153 |
-
</div>
|
154 |
-
</div>
|
155 |
-
|
156 |
-
<!-- Data Table Informations -->
|
157 |
-
<div class="flex justify-between items-center mb-2 pt-5" id="data-table-info-container">
|
158 |
-
<!-- Left side: buttons -->
|
159 |
-
<div class="flex gap-2 items-center">
|
160 |
-
<div class="tooltip" data-tip="Extract requirements from selected documents">
|
161 |
-
<button id="extract-requirements-btn"
|
162 |
-
class="bg-orange-300 text-white text-sm rounded px-3 py-1 shadow hover:bg-orange-600">
|
163 |
-
<svg class="w-6 h-6 text-gray-800 dark:text-white" aria-hidden="true"
|
164 |
-
xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none"
|
165 |
-
viewBox="0 0 24 24">
|
166 |
-
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"
|
167 |
-
stroke-width="2"
|
168 |
-
d="M9 8h6m-6 4h6m-6 4h6M6 3v18l2-2 2 2 2-2 2 2 2-2 2 2V3l-2 2-2-2-2 2-2-2-2 2-2-2Z" />
|
169 |
-
</svg>Extract Requirements
|
170 |
-
</button>
|
171 |
-
</div>
|
172 |
-
<button id="download-tdocs-btn" class="text-sm rounded px-3 py-1 shadow cursor-pointer">
|
173 |
-
📦 Download Selected TDocs
|
174 |
-
</button>
|
175 |
-
</div>
|
176 |
-
|
177 |
-
<!-- Right side: document counts -->
|
178 |
-
<div class="flex gap-2 items-center">
|
179 |
-
<span id="displayed-count" class="text-sm text-gray-700 bg-white rounded px-3 py-1 shadow">
|
180 |
-
0 total documents
|
181 |
-
</span>
|
182 |
-
<span id="selected-count" class="text-sm text-blue-700 bg-blue-50 rounded px-3 py-1 shadow">
|
183 |
-
0 selected documents
|
184 |
-
</span>
|
185 |
-
</div>
|
186 |
-
</div>
|
187 |
-
|
188 |
-
|
189 |
-
<!-- Data Table -->
|
190 |
-
<div id="data-table-container" class="mb-6">
|
191 |
-
<table id="data-table" class="w-full bg-white rounded-lg shadow overflow-hidden">
|
192 |
-
<thead class="bg-gray-50">
|
193 |
-
<tr>
|
194 |
-
<th class="px-4 py-2 text-left">
|
195 |
-
<input type="checkbox" id="select-all-checkbox">
|
196 |
-
</th>
|
197 |
-
<th class="px-4 py-2 text-left">TDoc</th>
|
198 |
-
<th class="px-4 py-2 text-left">Title</th>
|
199 |
-
<th class="px-4 py-2 text-left">Type</th>
|
200 |
-
<th class="px-4 py-2 text-left">Status</th>
|
201 |
-
<th class="px-4 py-2 text-left">Agenda Item</th>
|
202 |
-
<th class="px-4 py-2 text-left">URL</th>
|
203 |
-
</tr>
|
204 |
-
</thead>
|
205 |
-
<tbody></tbody>
|
206 |
-
</table>
|
207 |
-
</div>
|
208 |
-
</div>
|
209 |
-
|
210 |
-
<div id="requirements-tab-contents" class="hidden pt-10">
|
211 |
-
<!-- Requirement list container -->
|
212 |
-
<div id="requirements-container" class="mb-6">
|
213 |
-
<div class="flex">
|
214 |
-
<h2 class="text-2xl font-bold mb-4">Extracted requirement list</h2>
|
215 |
-
<div class="justify-end pl-5">
|
216 |
-
<!--Copy ALL reqs button-->
|
217 |
-
<div class="tooltip" data-tip="Copy ALL requirements to clipboard">
|
218 |
-
<button class="btn btn-square" id="copy-all-reqs-btn" aria-label="Copy">
|
219 |
-
📋
|
220 |
-
</button>
|
221 |
-
</div>
|
222 |
-
</div>
|
223 |
-
</div>
|
224 |
-
<div id="requirements-list"></div>
|
225 |
-
</div>
|
226 |
-
</div>
|
227 |
-
|
228 |
-
|
229 |
-
<!-- Query Requirements -->
|
230 |
-
<div id="query-tab-contents" class="hidden pt-10">
|
231 |
-
<div id="query-requirements-container" class="mb-6">
|
232 |
-
<h2 class="text-2xl font-bold mb-4">Find relevant requirements for a query</h2>
|
233 |
-
<div class="flex gap-2">
|
234 |
-
<input type="text" id="query-input" class="flex-1 p-2 border border-gray-300 rounded-md"
|
235 |
-
placeholder="Enter your query...">
|
236 |
-
<button id="search-requirements-btn"
|
237 |
-
class="px-4 py-2 bg-blue-500 text-white rounded-md hover:bg-blue-600">
|
238 |
-
Search
|
239 |
-
</button>
|
240 |
-
</div>
|
241 |
-
<div id="query-results" class="mt-4"></div>
|
242 |
-
</div>
|
243 |
-
</div>
|
244 |
-
|
245 |
-
<!-- Solution tab -->
|
246 |
-
<div id="solutions-tab-contents" class="hidden pt-10">
|
247 |
-
<!--Header de catégorisation des requirements-->
|
248 |
-
<div class="w-full mx-auto mt-4 p-4 bg-base-100 rounded-box shadow-lg border border-base-200">
|
249 |
-
<!-- Séléction du nb de catégories / mode auto-->
|
250 |
-
<div class="flex flex-wrap justify-begin items-center gap-6">
|
251 |
-
<!-- Number input -->
|
252 |
-
<div class="form-control flex flex-col items-center justify-center">
|
253 |
-
<label class="label" for="category-count">
|
254 |
-
<span class="label-text text-base-content"># Categories</span>
|
255 |
-
</label>
|
256 |
-
<input id="category-count" type="number" class="input input-bordered w-24" min="1" value="3" />
|
257 |
-
</div>
|
258 |
-
|
259 |
-
<!-- Auto detect toggle -->
|
260 |
-
<div class="form-control flex flex-col items-center justify-center">
|
261 |
-
<label class="label">
|
262 |
-
<span class="label-text text-base-content">Number of categories</span>
|
263 |
-
</label>
|
264 |
-
<input type="checkbox" class="toggle toggle-primary" id="auto-detect-toggle" checked="true" />
|
265 |
-
<div class="text-xs mt-1 text-base-content">Manual | Auto detect</div>
|
266 |
-
</div>
|
267 |
-
|
268 |
-
<!-- Action Button -->
|
269 |
-
<button id="categorize-requirements-btn" class="btn btn-primary btn-l self-center">
|
270 |
-
Categorize
|
271 |
-
</button>
|
272 |
-
</div>
|
273 |
-
<div class="flex flex-wrap justify-end items-center gap-6">
|
274 |
-
<div class="tooltip" data-tip="Use Insight Finder's API to generate solutions">
|
275 |
-
<label class="label">
|
276 |
-
<span class="label-text text-base-content">Use insight finder solver</span>
|
277 |
-
</label>
|
278 |
-
<input type="checkbox" class="toggle toggle-primary" id="use-insight-finder-solver"
|
279 |
-
checked="false" />
|
280 |
-
</div>
|
281 |
-
</div>
|
282 |
-
</div>
|
283 |
-
<div id="categorized-requirements-container pt-10" class="mb-6">
|
284 |
-
<div class="flex mb-4 pt-10">
|
285 |
-
<div class="justify-begin">
|
286 |
-
<h2 class="text-2xl font-bold">Requirements categories list</h2>
|
287 |
-
</div>
|
288 |
-
<div class="justify-end pl-5">
|
289 |
-
<!--Copy reqs button-->
|
290 |
-
<div class="tooltip" data-tip="Copy selected requirements to clipboard">
|
291 |
-
<button class="btn btn-square" id="copy-reqs-btn" aria-label="Copy">
|
292 |
-
📋
|
293 |
-
</button>
|
294 |
-
</div>
|
295 |
-
</div>
|
296 |
-
</div>
|
297 |
-
<div id="categorized-requirements-list"></div>
|
298 |
-
</div>
|
299 |
-
|
300 |
-
<!-- Solutions Action Buttons -->
|
301 |
-
<div id="solutions-action-buttons-container" class="mb-6 hidden">
|
302 |
-
<div class="flex flex-wrap gap-2 justify-center items-center">
|
303 |
-
<div class="join">
|
304 |
-
<input id="solution-gen-nsteps" type="number" class="input join-item w-24" min="1" value="3" />
|
305 |
-
<button id="get-solutions-btn"
|
306 |
-
class="btn join-item px-4 py-2 bg-indigo-500 text-white rounded-md hover:bg-indigo-600">
|
307 |
-
Run multiple steps
|
308 |
-
</button>
|
309 |
-
</div>
|
310 |
-
<button id="get-solutions-step-btn"
|
311 |
-
class="px-4 py-2 bg-pink-500 text-white rounded-md hover:bg-pink-600">
|
312 |
-
Get Solutions (Step-by-step)
|
313 |
-
</button>
|
314 |
-
<div class="dropdown dropdown-center">
|
315 |
-
<div id="additional-gen-instr-btn" tabindex="0" role="button" class="btn m-1">🎨 Additional
|
316 |
-
generation constraints</div>
|
317 |
-
<div tabindex="0" class="dropdown-content card card-sm bg-base-100 z-1 w-256 shadow-md">
|
318 |
-
<div class="card-body">
|
319 |
-
<h3>Add additional constraints to follow when generating the solutions</h3>
|
320 |
-
<textarea id="additional-gen-instr"
|
321 |
-
class="textarea textarea-bordered w-full"></textarea>
|
322 |
-
</div>
|
323 |
-
</div>
|
324 |
-
</div>
|
325 |
-
</div>
|
326 |
-
|
327 |
-
</div>
|
328 |
-
|
329 |
-
<!-- Solutions Container -->
|
330 |
-
<div id="solutions-container" class="mb-6">
|
331 |
-
<h2 class="text-2xl font-bold mb-4">Solutions</h2>
|
332 |
-
<div id="solutions-list"></div>
|
333 |
-
</div>
|
334 |
-
</div>
|
335 |
-
|
336 |
-
<script src="/static/sse.js"></script>
|
337 |
-
<script src="/static/ui-utils.js"></script>
|
338 |
-
<script src="/static/script.js"></script>
|
339 |
-
</body>
|
340 |
-
|
341 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
prompts/classify.txt
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<role>You are an useful assistant who excels at categorizing technical extracted requirements</role>
|
2 |
+
<task>You are tasked with classifying each element of a list of technical requirements into categories which you may arbitrarily define.
|
3 |
+
For each category indicate which requirements belong in that category using their ID. An item may appear in multiple categories at a time.
|
4 |
+
</task>
|
5 |
+
{% if max_n_categories is none -%}
|
6 |
+
<number_of_categories>You may have at most as much categories as you think is needed</number_of_categories>
|
7 |
+
{% else -%}
|
8 |
+
<number_of_categories>You may have at most {{max_n_categories}} categories</number_of_categories>
|
9 |
+
{% endif-%}
|
10 |
+
|
11 |
+
Here are the requirements:
|
12 |
+
<requirements>
|
13 |
+
{% for req in requirements -%}
|
14 |
+
- {{ loop.index0 }}. {{ req["requirement"] }}
|
15 |
+
{% endfor -%}
|
16 |
+
</requirements>
|
17 |
+
|
18 |
+
<response_format>
|
19 |
+
Reply in JSON using the following schema:
|
20 |
+
{{response_schema}}
|
21 |
+
</response_format>
|
prompts/criticize.txt
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<role>You are an expert system designer</role>
|
2 |
+
<task>
|
3 |
+
You are tasked with criticizing multiple solutions solving a set of requirements on different points,
|
4 |
+
namely the technical challenges of the solutions, the weaknesses and limitations of the proposed solutions.
|
5 |
+
</task>
|
6 |
+
|
7 |
+
Here are the solutions:
|
8 |
+
<solutions>
|
9 |
+
{% for solution in solutions %}
|
10 |
+
## Solution
|
11 |
+
- Context: {{solution["Context"]}}
|
12 |
+
- Problem description: {{solution["Problem_Description"]}}
|
13 |
+
- Solution description: {{solution["Solution_Description"]}}
|
14 |
+
---
|
15 |
+
{% endfor -%}
|
16 |
+
</solutions>
|
17 |
+
|
18 |
+
<response_format>
|
19 |
+
Reply in JSON using the following schema:
|
20 |
+
{{response_schema}}
|
21 |
+
</response_format>
|
prompts/if/format_requirements.txt
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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>
|
9 |
+
Here is the category item and the associated requirements:
|
10 |
+
Category Title: {{category["title"]}}
|
11 |
+
Context: {{category["requirements"][0]["context"]}}
|
12 |
+
Requirements:
|
13 |
+
{% for req in category["requirements"] -%}
|
14 |
+
- {{loop.index0}} {{req["requirement"]}}
|
15 |
+
{% endfor -%}
|
16 |
+
</requirements>
|
17 |
+
|
18 |
+
<response_format>
|
19 |
+
Reply in JSON using the following schema:
|
20 |
+
{{response_schema}}
|
21 |
+
</response_format>
|
22 |
+
|
23 |
+
|
prompts/if/synthesize_solution.txt
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<role>You are an expert system designer</role>
|
2 |
+
<task>
|
3 |
+
Your task is to create a solution that should cover the maximum possible of requirements at once.
|
4 |
+
The solution should be composed of multiple mechanisms, that are defined as processes, methods, or sequences of steps using one or multiple technologies that explain how something works or achieves its requirements.
|
5 |
+
|
6 |
+
You may use the technologies listed below for the mechanisms of your solution.
|
7 |
+
|
8 |
+
You must aim for the following goals:
|
9 |
+
- The solution must aim to maximize requirement satisfaction while respecting the context.
|
10 |
+
- Provide a list of requirements addressed by the solution (provide the requirement IDs)
|
11 |
+
- Please also detail each mechanism and how they work in the final solution description.
|
12 |
+
- Please describe the solution description using markdown in a consistent format.
|
13 |
+
</task>
|
14 |
+
|
15 |
+
<requirements>
|
16 |
+
Here is the category item and the associated requirements:
|
17 |
+
Category Title: {{category["title"]}}
|
18 |
+
Context: {{category["requirements"][0]["context"]}}
|
19 |
+
Requirements:
|
20 |
+
{% for req in category["requirements"] -%}
|
21 |
+
- {{loop.index0}} {{req["requirement"]}}
|
22 |
+
{% endfor -%}
|
23 |
+
</requirements>
|
24 |
+
|
25 |
+
<available_technologies>
|
26 |
+
Here are the technologies you may use for the mechanisms that compose the solution:
|
27 |
+
{% for tech in technologies -%}
|
28 |
+
- {{tech["title"]}} : {{tech["purpose"]}}
|
29 |
+
* Key Components : {{tech["key_components"]}}
|
30 |
+
{% endfor %}
|
31 |
+
</available_technologies>
|
32 |
+
|
33 |
+
{% if user_constraints is not none %}
|
34 |
+
<user_constraints>
|
35 |
+
Here are additional user constraints the solution must respect:
|
36 |
+
{{user_constraints}}
|
37 |
+
</user_constraints>
|
38 |
+
{% endif %}
|
39 |
+
|
40 |
+
<response_format>
|
41 |
+
Reply in JSON using the following schema:
|
42 |
+
{{response_schema}}
|
43 |
+
</response_format>
|
prompts/refine_solution.txt
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<role>You are an expert system designer</role>
|
2 |
+
<task>
|
3 |
+
Your task is to refine a solution to account for the technical challenges, weaknesses and limitations that were critiqued.
|
4 |
+
No need to include that the solution is refined.
|
5 |
+
</task>
|
6 |
+
|
7 |
+
Here is the solution:
|
8 |
+
<solution>
|
9 |
+
# Solution Context:
|
10 |
+
{{solution['Context']}}
|
11 |
+
|
12 |
+
# Requirements solved by the solution
|
13 |
+
{% for req in solution['Requirements'] -%}
|
14 |
+
- {{req}}
|
15 |
+
{% endfor %}
|
16 |
+
|
17 |
+
# Problem description associated to the solution
|
18 |
+
{{solution['Problem_Description']}}
|
19 |
+
|
20 |
+
# Description of the solution
|
21 |
+
{{solution['Solution_Description']}}
|
22 |
+
</solution>
|
23 |
+
|
24 |
+
Here is the criticism:
|
25 |
+
<criticism>
|
26 |
+
# Technical Challenges
|
27 |
+
{% for challenge in criticism['technical_challenges'] -%}
|
28 |
+
- {{challenge}}
|
29 |
+
{% endfor %}
|
30 |
+
|
31 |
+
# Weaknesses
|
32 |
+
{% for weakness in criticism['weaknesses'] -%}
|
33 |
+
- {{weakness}}
|
34 |
+
{% endfor %}
|
35 |
+
|
36 |
+
# Limitations
|
37 |
+
{% for limitation in criticism['limitations'] -%}
|
38 |
+
- {{limitation}}
|
39 |
+
{% endfor %}
|
40 |
+
</criticism>
|
41 |
+
|
42 |
+
<response_format>
|
43 |
+
Reply in JSON using the following response schema:
|
44 |
+
{{response_schema}}
|
45 |
+
</response_format>
|
prompts/search_solution.txt
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<role>You are an expert system designer</role>
|
2 |
+
<task>
|
3 |
+
Your task is to create a solution that should cover the maximum possible of requirements at once.
|
4 |
+
The solution should be composed of multiple mechanisms, that are defined as processes, methods, or sequences of steps using a technology that explain how something works or achieves its requirements.
|
5 |
+
You may for that search mechanisms for the different requirements.
|
6 |
+
**Please actually make searches and do not simulate them.**
|
7 |
+
|
8 |
+
You must aim for the following goals:
|
9 |
+
- The solution must aim to maximize requirement satisfaction while respecting the context.
|
10 |
+
- Provide a list of requirements addressed by the solution (provide only the requirement IDs)
|
11 |
+
- Please also detail each mechanism and how they work in the final solution description.
|
12 |
+
- Please describe the solution description using markdown in a consistent format.
|
13 |
+
</task>
|
14 |
+
|
15 |
+
Here is the category item and the associated requirements:
|
16 |
+
<requirements>
|
17 |
+
Category Title: {{category["title"]}}
|
18 |
+
Context: {{category["requirements"][0]["context"]}}
|
19 |
+
Requirements:
|
20 |
+
{% for req in category["requirements"] -%}
|
21 |
+
- {{loop.index0}} {{req["requirement"]}}
|
22 |
+
{% endfor -%}
|
23 |
+
</requirements>
|
prompts/search_solution_v2.txt
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<role>You are an expert system designer</role>
|
2 |
+
<task>
|
3 |
+
Your task is to create a solution that should cover the maximum possible of requirements at once.
|
4 |
+
The solution should be composed of multiple mechanisms, that are defined as processes, methods, or sequences of steps using a technology that explain how something works or achieves its requirements.
|
5 |
+
You may for that search mechanisms for the different requirements.
|
6 |
+
|
7 |
+
**Please actually make searches and do not simulate them.**
|
8 |
+
|
9 |
+
You must aim for the following goals:
|
10 |
+
- The solution must aim to maximize requirement satisfaction while respecting the context.
|
11 |
+
- Provide a list of requirements addressed by the solution (provide only the requirement IDs)
|
12 |
+
- Please also detail each mechanism and how they work in the final solution description.
|
13 |
+
- Please describe the solution description using markdown in a consistent format.
|
14 |
+
</task>
|
15 |
+
|
16 |
+
Here is the category item and the associated requirements:
|
17 |
+
<requirements>
|
18 |
+
Category Title: {{category["title"]}}
|
19 |
+
Context: {{category["requirements"][0]["context"]}}
|
20 |
+
Requirements:
|
21 |
+
{% for req in category["requirements"] -%}
|
22 |
+
- {{loop.index0}} {{req["requirement"]}}
|
23 |
+
{% endfor -%}
|
24 |
+
</requirements>
|
25 |
+
|
26 |
+
{% if user_constraints is not none %}
|
27 |
+
Here are additional user constraints the solution must respect:
|
28 |
+
<user_constraints>
|
29 |
+
{{user_constraints}}
|
30 |
+
</user_constraints>
|
31 |
+
{% endif %}
|
prompts/structure_solution.txt
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<role>You are an expert system designer</role>
|
2 |
+
<task>Your task is to take a solution you've created previously and structure it into a JSON object.</task>
|
3 |
+
|
4 |
+
Here is the solution
|
5 |
+
<solution>
|
6 |
+
{{solution}}
|
7 |
+
</solution>
|
8 |
+
|
9 |
+
<response_format>
|
10 |
+
Reply in JSON using the following schema:
|
11 |
+
{{response_schema}}
|
12 |
+
</response_format>
|
requirements.txt
CHANGED
@@ -10,4 +10,5 @@ openpyxl
|
|
10 |
beautifulsoup4
|
11 |
aiolimiter
|
12 |
nltk
|
13 |
-
httpx
|
|
|
|
10 |
beautifulsoup4
|
11 |
aiolimiter
|
12 |
nltk
|
13 |
+
httpx
|
14 |
+
Jinja2
|
schemas.py
CHANGED
@@ -7,6 +7,7 @@ class MeetingsRequest(BaseModel):
|
|
7 |
class MeetingsResponse(BaseModel):
|
8 |
meetings: Dict[str, str]
|
9 |
# --------------------------------------
|
|
|
10 |
class DataRequest(BaseModel):
|
11 |
working_group: str
|
12 |
meeting: str
|
@@ -32,23 +33,180 @@ class RequirementsResponse(BaseModel):
|
|
32 |
requirements: List[DocRequirements]
|
33 |
|
34 |
# --------------------------------------
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
context: str
|
39 |
-
requirement: str
|
|
|
|
|
|
|
40 |
|
41 |
class ReqSearchLLMResponse(BaseModel):
|
42 |
selected: List[int]
|
43 |
|
|
|
44 |
class ReqSearchRequest(BaseModel):
|
45 |
query: str
|
46 |
-
requirements: List[
|
|
|
47 |
|
48 |
class ReqSearchResponse(BaseModel):
|
49 |
-
requirements: List[
|
50 |
|
51 |
# --------------------------------------
|
52 |
|
|
|
53 |
class DownloadRequest(BaseModel):
|
54 |
-
documents: List[str] = Field(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
class MeetingsResponse(BaseModel):
|
8 |
meetings: Dict[str, str]
|
9 |
# --------------------------------------
|
10 |
+
|
11 |
class DataRequest(BaseModel):
|
12 |
working_group: str
|
13 |
meeting: str
|
|
|
33 |
requirements: List[DocRequirements]
|
34 |
|
35 |
# --------------------------------------
|
36 |
+
|
37 |
+
class RequirementInfo(BaseModel):
|
38 |
+
req_id: int = Field(..., description="The ID of this requirement")
|
39 |
+
context: str = Field(..., description="Context for the requirement.")
|
40 |
+
requirement: str = Field(..., description="The requirement itself.")
|
41 |
+
document: str = Field(...,
|
42 |
+
description="The document the requirement is extracted from.")
|
43 |
+
|
44 |
|
45 |
class ReqSearchLLMResponse(BaseModel):
|
46 |
selected: List[int]
|
47 |
|
48 |
+
|
49 |
class ReqSearchRequest(BaseModel):
|
50 |
query: str
|
51 |
+
requirements: List[RequirementInfo]
|
52 |
+
|
53 |
|
54 |
class ReqSearchResponse(BaseModel):
|
55 |
+
requirements: List[RequirementInfo]
|
56 |
|
57 |
# --------------------------------------
|
58 |
|
59 |
+
|
60 |
class DownloadRequest(BaseModel):
|
61 |
+
documents: List[str] = Field(
|
62 |
+
description="List of document IDs to download")
|
63 |
+
|
64 |
+
|
65 |
+
class ReqGroupingCategory(BaseModel):
|
66 |
+
"""Represents the category of requirements grouped together"""
|
67 |
+
id: int = Field(..., description="ID of the grouping category")
|
68 |
+
title: str = Field(..., description="Title given to the grouping category")
|
69 |
+
requirements: List[RequirementInfo] = Field(
|
70 |
+
..., description="List of grouped requirements")
|
71 |
+
|
72 |
+
|
73 |
+
class SolutionModel(BaseModel):
|
74 |
+
Context: str = Field(...,
|
75 |
+
description="Full context provided for this category.")
|
76 |
+
Requirements: List[str] = Field(...,
|
77 |
+
description="List of each requirement as string.")
|
78 |
+
Problem_Description: str = Field(..., alias="Problem Description",
|
79 |
+
description="Description of the problem being solved.")
|
80 |
+
Solution_Description: str = Field(..., alias="Solution Description",
|
81 |
+
description="Detailed description of the solution.")
|
82 |
+
References: list[dict] = Field(
|
83 |
+
..., description="References to documents used for the solution.")
|
84 |
+
Category_Id: int = Field(
|
85 |
+
..., description="ID of the requirements category the solution is based on")
|
86 |
+
|
87 |
+
class Config:
|
88 |
+
validate_by_name = True # Enables alias handling on input/output
|
89 |
+
|
90 |
+
|
91 |
+
# ============================================================= Categorize requirements endpoint
|
92 |
+
|
93 |
+
|
94 |
+
class ReqGroupingRequest(BaseModel):
|
95 |
+
"""Request schema of a requirement grouping call."""
|
96 |
+
requirements: list[RequirementInfo]
|
97 |
+
max_n_categories: Optional[int] = Field(
|
98 |
+
default=None, description="Max number of categories to construct. Defaults to None")
|
99 |
+
|
100 |
+
|
101 |
+
class ReqGroupingResponse(BaseModel):
|
102 |
+
"""Response of a requirement grouping call."""
|
103 |
+
categories: List[ReqGroupingCategory]
|
104 |
+
|
105 |
+
|
106 |
+
# INFO: keep in sync with prompt
|
107 |
+
class _ReqGroupingCategory(BaseModel):
|
108 |
+
title: str = Field(..., description="Title given to the grouping category")
|
109 |
+
items: list[int] = Field(
|
110 |
+
..., description="List of the IDs of the requirements belonging to the category.")
|
111 |
+
|
112 |
+
|
113 |
+
class _ReqGroupingOutput(BaseModel):
|
114 |
+
categories: list[_ReqGroupingCategory] = Field(
|
115 |
+
..., description="List of grouping categories")
|
116 |
+
|
117 |
+
|
118 |
+
# =================================================================== search solution response endpoint
|
119 |
+
|
120 |
+
class _SolutionSearchOutput(BaseModel):
|
121 |
+
solution: SolutionModel
|
122 |
+
|
123 |
+
|
124 |
+
class _SearchedSolutionModel(BaseModel):
|
125 |
+
""""Internal model used for solutions searched using gemini"""
|
126 |
+
requirement_ids: List[int] = Field(...,
|
127 |
+
description="List of each requirement ID addressed by the solution")
|
128 |
+
problem_description: str = Field(...,
|
129 |
+
description="Description of the problem being solved.")
|
130 |
+
solution_description: str = Field(...,
|
131 |
+
description="Detailed description of the solution.")
|
132 |
+
|
133 |
+
|
134 |
+
class SolutionSearchResponse(BaseModel):
|
135 |
+
"""Response model for solution search"""
|
136 |
+
solutions: list[SolutionModel]
|
137 |
+
|
138 |
+
|
139 |
+
class SolutionSearchV2Request(BaseModel):
|
140 |
+
"""Response of a requirement grouping call."""
|
141 |
+
categories: List[ReqGroupingCategory]
|
142 |
+
user_constraints: Optional[str] = Field(
|
143 |
+
default=None, description="Additional user constraints to respect when generating the solutions.")
|
144 |
+
|
145 |
+
# =========================================================== Criticize solution endpoint
|
146 |
+
|
147 |
+
|
148 |
+
class CriticizeSolutionsRequest(BaseModel):
|
149 |
+
solutions: list[SolutionModel]
|
150 |
+
|
151 |
+
|
152 |
+
class _SolutionCriticism(BaseModel):
|
153 |
+
technical_challenges: List[str] = Field(
|
154 |
+
..., description="Technical challenges encountered by the solution")
|
155 |
+
weaknesses: List[str] = Field(...,
|
156 |
+
description="Identified weaknesses of the solution")
|
157 |
+
limitations: List[str] = Field(...,
|
158 |
+
description="Identified limitations of the solution")
|
159 |
+
|
160 |
+
|
161 |
+
class _SolutionCriticismOutput(BaseModel):
|
162 |
+
criticisms: List[_SolutionCriticism]
|
163 |
+
|
164 |
+
|
165 |
+
class SolutionCriticism(BaseModel):
|
166 |
+
solution: SolutionModel
|
167 |
+
criticism: _SolutionCriticism
|
168 |
+
|
169 |
+
|
170 |
+
class CritiqueResponse(BaseModel):
|
171 |
+
critiques: List[SolutionCriticism]
|
172 |
+
|
173 |
+
|
174 |
+
# ==========================================================================
|
175 |
+
|
176 |
+
class _RefinedSolutionModel(BaseModel):
|
177 |
+
"""Internal model used for solution refining"""
|
178 |
+
|
179 |
+
problem_description: str = Field(...,
|
180 |
+
description="New description of the problem being solved.")
|
181 |
+
solution_description: str = Field(...,
|
182 |
+
description="New detailed description of the solution.")
|
183 |
+
|
184 |
+
|
185 |
+
# ================================================================= search solutions using insight finder endpoints
|
186 |
+
|
187 |
+
# Helpers to extract constraints for Insights Finder
|
188 |
+
|
189 |
+
class InsightFinderConstraintItem(BaseModel):
|
190 |
+
title: str
|
191 |
+
description: str
|
192 |
+
|
193 |
+
|
194 |
+
class InsightFinderConstraintsList(BaseModel):
|
195 |
+
constraints: list[InsightFinderConstraintItem]
|
196 |
+
|
197 |
+
# =================================================
|
198 |
+
|
199 |
+
|
200 |
+
class Technology(BaseModel):
|
201 |
+
"""Represents a single technology entry with its details."""
|
202 |
+
title: str
|
203 |
+
purpose: str
|
204 |
+
key_components: str
|
205 |
+
advantages: str
|
206 |
+
limitations: str
|
207 |
+
id: int
|
208 |
+
|
209 |
+
|
210 |
+
class TechnologyData(BaseModel):
|
211 |
+
"""Represents the top-level object containing a list of technologies."""
|
212 |
+
technologies: List[Technology]
|
static/js/script.js
CHANGED
@@ -417,7 +417,7 @@ async function categorizeRequirements(max_categories) {
|
|
417 |
toggleElementsEnabled(['categorize-requirements-btn'], false);
|
418 |
|
419 |
try {
|
420 |
-
const response = await fetch('
|
421 |
method: 'POST',
|
422 |
headers: { 'Content-Type': 'application/json' },
|
423 |
body: JSON.stringify({ requirements: formattedRequirements, "max_n_categories": max_categories })
|
@@ -1054,7 +1054,7 @@ async function generateSolutionsV1(selected_categories, user_constraints = null,
|
|
1054 |
input_req.user_constraints = user_constraints;
|
1055 |
console.log(useIFSolver);
|
1056 |
|
1057 |
-
const base_url = useIFSolver ? "
|
1058 |
|
1059 |
let response = await fetch(base_url, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(input_req) })
|
1060 |
let responseObj = await response.json()
|
@@ -1062,13 +1062,13 @@ async function generateSolutionsV1(selected_categories, user_constraints = null,
|
|
1062 |
}
|
1063 |
|
1064 |
async function generateCriticismsV1(solutions) {
|
1065 |
-
let response = await fetch('
|
1066 |
let responseObj = await response.json()
|
1067 |
solutionsCriticizedVersions.push(responseObj)
|
1068 |
}
|
1069 |
|
1070 |
async function refineSolutionsV1(critiques) {
|
1071 |
-
let response = await fetch('
|
1072 |
let responseObj = await response.json()
|
1073 |
await generateCriticismsV1(responseObj)
|
1074 |
}
|
|
|
417 |
toggleElementsEnabled(['categorize-requirements-btn'], false);
|
418 |
|
419 |
try {
|
420 |
+
const response = await fetch('/requirements/categorize_requirements', {
|
421 |
method: 'POST',
|
422 |
headers: { 'Content-Type': 'application/json' },
|
423 |
body: JSON.stringify({ requirements: formattedRequirements, "max_n_categories": max_categories })
|
|
|
1054 |
input_req.user_constraints = user_constraints;
|
1055 |
console.log(useIFSolver);
|
1056 |
|
1057 |
+
const base_url = useIFSolver ? "/solutions/search_solutions_if" : "/solutions/search_solutions_gemini/v2"
|
1058 |
|
1059 |
let response = await fetch(base_url, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(input_req) })
|
1060 |
let responseObj = await response.json()
|
|
|
1062 |
}
|
1063 |
|
1064 |
async function generateCriticismsV1(solutions) {
|
1065 |
+
let response = await fetch('/solutions/criticize_solution', { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(solutions) })
|
1066 |
let responseObj = await response.json()
|
1067 |
solutionsCriticizedVersions.push(responseObj)
|
1068 |
}
|
1069 |
|
1070 |
async function refineSolutionsV1(critiques) {
|
1071 |
+
let response = await fetch('/solutions/refine_solutions', { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(critiques) })
|
1072 |
let responseObj = await response.json()
|
1073 |
await generateCriticismsV1(responseObj)
|
1074 |
}
|