File size: 7,791 Bytes
50d44e1
e97be0e
ded7ed5
75ac1c4
f3bf993
ded7ed5
f3bf993
 
 
75ac1c4
f6bffda
f3bf993
 
 
75ac1c4
f3bf993
 
ded7ed5
 
 
75ac1c4
f3bf993
ded7ed5
 
75ac1c4
03e159d
8ac47d4
 
 
 
03e159d
8ac47d4
03e159d
8ac47d4
 
03e159d
75ac1c4
f3bf993
 
 
 
 
 
 
8ac47d4
ded7ed5
 
75ac1c4
ded7ed5
 
 
 
 
75ac1c4
8ac47d4
ded7ed5
 
 
f6bffda
75ac1c4
f6bffda
 
 
 
 
 
 
ded7ed5
1538533
 
 
f6bffda
ded7ed5
 
f6bffda
 
ded7ed5
 
f6bffda
03e159d
 
 
f6bffda
 
 
 
 
 
 
 
 
 
75ac1c4
f6bffda
75ac1c4
 
 
f6bffda
75ac1c4
f6bffda
75ac1c4
f6bffda
e97be0e
75ac1c4
f6bffda
 
75ac1c4
 
f6bffda
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75ac1c4
e97be0e
 
 
 
 
 
 
 
 
 
8a5bedd
 
 
e97be0e
 
 
 
 
 
 
 
 
 
 
 
f6bffda
75ac1c4
f6bffda
 
 
75ac1c4
 
f6bffda
 
 
 
 
 
 
 
75ac1c4
 
f6bffda
 
 
75ac1c4
f6bffda
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e97be0e
f6bffda
 
 
 
 
 
e97be0e
f6bffda
8a5bedd
e97be0e
 
 
 
f6bffda
 
e97be0e
8a5bedd
e97be0e
8a5bedd
 
e97be0e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
from pydantic import BaseModel, Field
from typing import Any, List, Dict, Literal, Optional


# --------------------------------------- Document related endpoints ---------------------------------------

class GetMeetingsRequest(BaseModel):
    working_group: Literal["SA1", "SA2", "SA3", "SA4", "SA5", "SA6",
                           "CT1", "CT2", "CT3", "CT4", "CT5", "CT6", "RAN1", "RAN2"]


class GetMeetingsResponse(BaseModel):
    meetings: Dict[str, str] = Field(
        ..., description="Mapping of meetings with as key their display name and value the FTP meeting name.")


class GetMeetingDocsRequest(BaseModel):
    working_group: str
    meeting: str


class GetMeetingDocsResponse(BaseModel):
    data: List[Dict[Any, Any]]


class DocInfo(BaseModel):
    """
        Schema for describing a document to download.
    """
    # Document name
    document: str
    # Document URL
    url: str
    # Document type
    type: str


class DownloadDocsRequest(BaseModel):
    documents: List[DocInfo] = Field(
        description="List of documents to download")

# --------------------------------------


class ExtractRequirementsRequest(BaseModel):
    documents: List[DocInfo]


class DocRequirements(BaseModel):
    document: str
    context: str
    requirements: List[str]


class ExtractRequirementsResponse(BaseModel):
    requirements: List[DocRequirements]

# --------------------------------------


class RequirementInfo(BaseModel):
    req_id: int = Field(..., description="The ID of this requirement")
    context: str = Field(..., description="Context for the requirement.")
    requirement: str = Field(..., description="The requirement itself.")
    document: str = Field(...,
                          description="The document the requirement is extracted from.")


class ReqSearchLLMResponse(BaseModel):
    selected: List[int]


class ReqSearchRequest(BaseModel):
    query: str
    requirements: List[RequirementInfo]


class ReqSearchResponse(BaseModel):
    requirements: List[RequirementInfo]

# --------------------------------------


class ReqGroupingCategory(BaseModel):
    """Represents the category of requirements grouped together"""
    id: int = Field(..., description="ID of the grouping category")
    title: str = Field(..., description="Title given to the grouping category")
    requirements: List[RequirementInfo] = Field(
        ..., description="List of grouped requirements")


class SolutionModel(BaseModel):
    context: str = Field(...,
                         description="Full context provided for this category.")
    requirements: List[str] = Field(...,
                                    description="List of each requirement covered by the solution as a string.")
    problem_description: str = Field(...,
                                     description="Description of the problem being solved.")
    solution_description: str = Field(...,
                                      description="Detailed description of the solution.")
    references: list[dict] = Field(
        ..., description="References to documents used for the solution.")

    category_id: int = Field(
        ..., description="ID of the requirements category the solution is based on")

    # class Config:
    #     validate_by_name = True  # Enables alias handling on input/output


# ============================================================= Categorize requirements endpoint


class ReqGroupingRequest(BaseModel):
    """Request schema of a requirement grouping call."""
    requirements: list[RequirementInfo]
    max_n_categories: Optional[int] = Field(
        default=None, description="Max number of categories to construct. Defaults to None")


class ReqGroupingResponse(BaseModel):
    """Response of a requirement grouping call."""
    categories: List[ReqGroupingCategory]


# INFO: keep in sync with prompt
class _ReqGroupingCategory(BaseModel):
    title: str = Field(..., description="Title given to the grouping category")
    items: list[int] = Field(
        ..., description="List of the IDs of the requirements belonging to the category.")


class _ReqGroupingOutput(BaseModel):
    categories: list[_ReqGroupingCategory] = Field(
        ..., description="List of grouping categories")


# =================================================================== bootstrap solution response
# Helpers for integration with insights finder.

class InsightFinderConstraintItem(BaseModel):
    title: str
    description: str


class InsightFinderConstraintsList(BaseModel):
    constraints: list[InsightFinderConstraintItem]

# TODO: aller voir la doc, breakage API


class Technology(BaseModel):
    """Represents a single technology entry with its details."""
    title: str = Field(..., alias="name")
    purpose: str
    advantages: str
    limitations: str


class TechnologyData(BaseModel):
    """Represents the top-level object containing a list of technologies."""
    technologies: List[Technology]


class _SolutionBootstrapOutput(BaseModel):
    solution: SolutionModel


class _BootstrappedSolutionModel(BaseModel):
    """"Internal model used for solutions bootstrapped using """
    requirement_ids: List[int] = Field(...,
                                       description="List of each requirement ID addressed by the solution")
    problem_description: str = Field(...,
                                     description="Description of the problem being solved.")
    solution_description: str = Field(...,
                                      description="Detailed description of the solution.")


class SolutionBootstrapResponse(BaseModel):
    """Response model for solution bootstrapping"""
    solutions: list[SolutionModel]


class SolutionBootstrapRequest(BaseModel):
    categories: List[ReqGroupingCategory]
    user_constraints: Optional[str] = Field(
        default=None, description="Additional user constraints to respect when generating the solutions.")

# =========================================================== Criticize solution endpoint


class CriticizeSolutionsRequest(BaseModel):
    solutions: list[SolutionModel]


class _SolutionCriticism(BaseModel):
    technical_challenges: List[str] = Field(
        ..., description="Technical challenges encountered by the solution")
    weaknesses: List[str] = Field(...,
                                  description="Identified weaknesses of the solution")
    limitations: List[str] = Field(...,
                                   description="Identified limitations of the solution")


class _SolutionCriticismOutput(BaseModel):
    criticisms: List[_SolutionCriticism]


class SolutionCriticism(BaseModel):
    solution: SolutionModel
    criticism: _SolutionCriticism


class CritiqueResponse(BaseModel):
    critiques: List[SolutionCriticism]


# ==========================================================================

class _RefinedSolutionModel(BaseModel):
    """Internal model used for bootstrapped solution refining"""

    problem_description: str = Field(...,
                                     description="New description of the problem being solved.")
    solution_description: str = Field(...,
                                      description="New detailed description of the solution.")

# ===========================================================================


class PriorArtSearchRequest(BaseModel):
    topics: list[str] = Field(
        ..., description="The list of topics to search for to create an exhaustive prior art search for a problem draft.")
    mode: Literal['prior_art', 'fto'] = Field(default="fto", description="")


class PriorArtSearchResponse(BaseModel):
    # Final consolidation report contents
    content: str
    # Individual search topic contents
    topic_contents: list[dict]
    pass