Skip to content

Commit

Permalink
feat: improvement in models
Browse files Browse the repository at this point in the history
  • Loading branch information
JayGhiya committed Jun 25, 2024
1 parent 80782d5 commit e83f3e7
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Original file line number Diff line number Diff line change
@@ -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")
codebase_name: str = Field( description="The file id of the codebase summary")
codebase_package: DspyUnoplatPackageSummary = Field( description="A summary of the codebase package")
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Original file line number Diff line number Diff line change
@@ -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")
node_summary: str = Field( description="A summary of the class")
functions_summary: List[DspyUnoplatFunctionSummary] = Field( description="A list of functions in the class")
Original file line number Diff line number Diff line change
@@ -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")

4 changes: 4 additions & 0 deletions unoplat-code-confluence/summary_parser/codebase_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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



0 comments on commit e83f3e7

Please sign in to comment.