ai-assist / dto /release_notes.py
rahgadda's picture
Initial Draft
c5f8f0a
raw
history blame
1.83 kB
from langchain_core.pydantic_v1 import BaseModel, Field
from typing import List
from datetime import datetime
class Enhancement(BaseModel):
"""Release Enhancement Pydantic Schema"""
title: str = Field(description="Provide enhancement title")
description: str = Field(description="Provide enhancement description")
benefits: str = Field(description="The benefit or impact on the user or system as a result of the enhancement")
reason: str = Field(description="The reason for implementing the change.")
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 ReleaseNotes(BaseModel):
"""Release Notes Pydantic Schema"""
release_date: str = Field(description="Provide release date",default=datetime.now().strftime('%d-%b-%Y').upper(), const=True)
product_name: str = Field(description="Provide product name",default="Oracle Banking Retail Lending", const=True)
summary: str = Field(description="A brief introduction highlighting the key focus of this release")
enhancements: List[Enhancement] = Field(description="List of enhancements in this release")
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)