File size: 2,117 Bytes
b925097
 
 
 
 
 
 
 
 
 
 
 
 
c5f8f0a
 
 
 
 
 
 
 
 
 
b925097
 
 
 
c5f8f0a
 
 
 
 
 
 
 
 
 
 
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
from langchain_core.pydantic_v1 import BaseModel, Field
from typing import List

class RequirementGathering(BaseModel):
    """Requirement Gathering Pydantic Schema"""

    overview: str = Field(description="Provide short overview of requirement")
    description: str = Field(description="Provide requirement description. Ensure each requirement is explicitly stated as per the document.")
    benefits: str = Field(description="The benefit or impact on the user or system as a result of the requirement. Ground it in the context of the document. Consider only for banking applications as product domain.")
    reason: str = Field(description="The reason for implementing the requirement.")
    priority: str = Field(description="The priority of the requirement. Return only one from list of values [High, Medium and Low]. Ground result based on the document.")
    tags: List[str] = Field(description="List of tags for the requirement to identify into relevant categories(e.g., Product Specifications, Validations and Quality Standards)")

    def get_json_template(model: BaseModel):
        """helper function to get the json schema from the pydantic model"""
        
        schema = model.model_json_schema()
        json_schema = json.dumps(schema)
        json_schema = Template(json_schema).substitute(
            {"defs": "definitions", "ref": "$ref"}
        )
        return json.loads(json_schema)

class RequirementGatheringDetails(BaseModel):
    """Requirement Gathering Details Pydantic Schema"""

    header: str = Field(description="Provide the header of the document.")
    requirements: List[RequirementGathering] = Field(description="List of requirements gathered from the document.")

    def get_json_template(model: BaseModel):
        """helper function to get the json schema from the pydantic model"""
        
        schema = model.model_json_schema()
        json_schema = json.dumps(schema)
        json_schema = Template(json_schema).substitute(
            {"defs": "definitions", "ref": "$ref"}
        )
        return json.loads(json_schema)