diff --git a/.gitignore b/.gitignore index d8a521a..77e0be4 100755 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,5 @@ unoplat-code-confluence/nodeparser/tests/__pycache__ unoplat-code-confluence/settings/__pycache__ unoplat-code-confluence/utility/__pycache__ unoplat-code-confluence/data_models/dspy/__pycache__ +unoplat-code-confluence/__pycache__ +unoplat-code-confluence/summary_parser/__pycache__ diff --git a/unoplat-code-confluence/data_models/dspy/dspy_unoplat_codebase_summary.py b/unoplat-code-confluence/data_models/dspy/dspy_unoplat_codebase_summary.py index 371f2b1..55ee405 100644 --- a/unoplat-code-confluence/data_models/dspy/dspy_unoplat_codebase_summary.py +++ b/unoplat-code-confluence/data_models/dspy/dspy_unoplat_codebase_summary.py @@ -1,5 +1,8 @@ from pydantic import BaseModel,Field +from data_models.dspy.dspy_unoplat_package_summary import DspyUnoplatPackageSummary + class DspyUnoplatCodebaseSummary(BaseModel): codebase_summary: str = Field( description="A summary of the codebase") - codebase_name: str = Field( description="The file id of the codebase summary") \ No newline at end of file + codebase_name: str = Field( description="The file id of the codebase summary") + codebase_package: DspyUnoplatPackageSummary = Field( description="A summary of the codebase package") \ No newline at end of file diff --git a/unoplat-code-confluence/data_models/dspy/dspy_unoplat_fs_node_subset.py b/unoplat-code-confluence/data_models/dspy/dspy_unoplat_fs_node_subset.py index 5080c00..92e5a07 100644 --- a/unoplat-code-confluence/data_models/dspy/dspy_unoplat_fs_node_subset.py +++ b/unoplat-code-confluence/data_models/dspy/dspy_unoplat_fs_node_subset.py @@ -14,4 +14,4 @@ class DspyUnoplatNodeSubset(BaseModel): extend: Optional[str] = Field(default=None, alias="Extend", description="This includes class inheritance") imports: Optional[List[Import]] = Field(default_factory=List, alias="Imports", description="This includes class imports which can be used to infer types of fields") annotations: Optional[List[DspyUnoplatAnnotationSubset]] = Field(default_factory=list, alias="Annotations") - functions: List[DspyUnoplatFunctionSubset] = Field(default_factory=list, alias="Functions") + functions: List[DspyUnoplatFunctionSubset] = Field(default_factory=list, alias="Functions",exclude=True) diff --git a/unoplat-code-confluence/data_models/dspy/dspy_unoplat_node_summary.py b/unoplat-code-confluence/data_models/dspy/dspy_unoplat_node_summary.py index 1a43d79..e7f7ae4 100644 --- a/unoplat-code-confluence/data_models/dspy/dspy_unoplat_node_summary.py +++ b/unoplat-code-confluence/data_models/dspy/dspy_unoplat_node_summary.py @@ -1,5 +1,9 @@ +from typing import List from pydantic import BaseModel,Field +from data_models.dspy.dspy_unoplat_function_summary import DspyUnoplatFunctionSummary + class DspyUnoplatNodeSummary(BaseModel): node_name: str = Field( description="The name of the class") - node_summary: str = Field( description="A summary of the class") \ No newline at end of file + node_summary: str = Field( description="A summary of the class") + functions_summary: List[DspyUnoplatFunctionSummary] = Field( description="A list of functions in the class") \ No newline at end of file diff --git a/unoplat-code-confluence/data_models/dspy/dspy_unoplat_package_summary.py b/unoplat-code-confluence/data_models/dspy/dspy_unoplat_package_summary.py index de3f019..f5448b8 100644 --- a/unoplat-code-confluence/data_models/dspy/dspy_unoplat_package_summary.py +++ b/unoplat-code-confluence/data_models/dspy/dspy_unoplat_package_summary.py @@ -1,7 +1,16 @@ -from typing import Dict +from typing import Dict, List from pydantic import BaseModel,Field +from data_models.dspy.dspy_unoplat_node_summary import DspyUnoplatNodeSummary + + + + +class DspyUnoplatPackageNodeSummary(BaseModel): + package_name: str = Field( description="The name of the package") + class_summary: List[DspyUnoplatNodeSummary] = Field( description="List of the class summaries for the package") + class DspyUnoplatPackageSummary(BaseModel): - package_summary_dict: Dict[str, str] = Field( description="Dict to hold the summary of packages") + package_summary_dict: Dict[str, DspyUnoplatPackageNodeSummary] = Field( description="Dict to hold the summary of packages") diff --git a/unoplat-code-confluence/summary_parser/codebase_summary.py b/unoplat-code-confluence/summary_parser/codebase_summary.py index 8961210..ba37961 100644 --- a/unoplat-code-confluence/summary_parser/codebase_summary.py +++ b/unoplat-code-confluence/summary_parser/codebase_summary.py @@ -2,6 +2,7 @@ from data_models.chapi_unoplat_codebase import UnoplatCodebase from data_models.chapi_unoplat_package import UnoplatPackage from data_models.dspy.dspy_unoplat_function_summary import DspyUnoplatFunctionSummary +from data_models.dspy.dspy_unoplat_node_summary import DspyUnoplatNodeSummary from dspy_function_summary import CodeConfluenceFunctionModule @@ -13,11 +14,14 @@ def __init__(self, codebase: UnoplatCodebase, dspy_pipeline_function: CodeConflu def parse_codebase(self): unoplat_packages :UnoplatPackage = self.codebase.packages for node_name, node_subset in unoplat_packages.package_dict.items(): + class_summaries: List[DspyUnoplatNodeSummary] = [] for node in node_subset: function_summaries :List[DspyUnoplatFunctionSummary] = [] for function in node.functions: function_summary = self.dspy_pipeline_function(function_metadata=function,class_metadata=node) dspyUnoplatFunctionSummary: DspyUnoplatFunctionSummary = DspyUnoplatFunctionSummary(FunctionName=function.name,FunctionSummary=function_summary) function_summaries.append(dspyUnoplatFunctionSummary) + # TODO: do class summary based on function_summaries' objectives + \ No newline at end of file