Skip to content

Commit 1c8115b

Browse files
authored
Merge pull request #385 from topoteretes/feature/cog-920-implement-mock-summaryobject-for-codegraph
Feature/cog 920 implement mock summaryobject for codegraph
2 parents b3b8d8a + 4689e55 commit 1c8115b

File tree

3 files changed

+52
-5
lines changed

3 files changed

+52
-5
lines changed

cognee/modules/data/extraction/extract_summary.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
from typing import Type
2-
2+
import os
33
from pydantic import BaseModel
44

55
from cognee.infrastructure.llm.get_llm_client import get_llm_client
66
from cognee.infrastructure.llm.prompts import read_query_prompt
7-
from cognee.shared.data_models import SummarizedCode
7+
from cognee.shared.data_models import SummarizedCode, SummarizedClass, SummarizedFunction
8+
from cognee.tasks.summarization.mock_summary import get_mock_summarized_code
89

910

1011
async def extract_summary(content: str, response_model: Type[BaseModel]):
@@ -17,5 +18,14 @@ async def extract_summary(content: str, response_model: Type[BaseModel]):
1718
return llm_output
1819

1920
async def extract_code_summary(content: str):
20-
21-
return await extract_summary(content, response_model=SummarizedCode)
21+
enable_mocking = os.getenv("MOCK_CODE_SUMMARY", "false")
22+
if isinstance(enable_mocking, bool):
23+
enable_mocking = str(enable_mocking).lower()
24+
enable_mocking = enable_mocking in ("true", "1", "yes")
25+
26+
if enable_mocking:
27+
result = get_mock_summarized_code()
28+
return result
29+
else:
30+
result = await extract_summary(content, response_model=SummarizedCode)
31+
return result

cognee/tasks/repo_processor/get_repo_file_dependencies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ async def get_repo_file_dependencies(repo_path: str) -> AsyncGenerator[list, Non
7373

7474
yield repo
7575

76-
with ProcessPoolExecutor() as executor:
76+
with ProcessPoolExecutor(max_workers = 12) as executor:
7777
loop = asyncio.get_event_loop()
7878

7979
tasks = [
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from cognee.shared.data_models import SummarizedCode, SummarizedClass, SummarizedFunction
2+
3+
def get_mock_summarized_code() -> SummarizedCode:
4+
return SummarizedCode(
5+
file_name="mock_file.py",
6+
high_level_summary="This is a mock high-level summary.",
7+
key_features=["Mock feature 1", "Mock feature 2"],
8+
imports=["mock_import1", "mock_import2"],
9+
constants=["MOCK_CONSTANT = 'mock_value'"],
10+
classes=[
11+
SummarizedClass(
12+
name="MockClass",
13+
description="This is a mock description of the MockClass.",
14+
methods=[
15+
SummarizedFunction(
16+
name="mock_method",
17+
description="This is a description of the mock method.",
18+
docstring="This is a mock method.",
19+
inputs=["mock_input: str"],
20+
outputs=["mock_output: str"],
21+
decorators=None,
22+
)
23+
],
24+
)
25+
],
26+
functions=[
27+
SummarizedFunction(
28+
name="mock_function",
29+
description="This is a description of the mock function.",
30+
docstring="This is a mock function.",
31+
inputs=["mock_input: str"],
32+
outputs=["mock_output: str"],
33+
decorators=None,
34+
)
35+
],
36+
workflow_description="This is a mock workflow description.",
37+
)

0 commit comments

Comments
 (0)