bioguider 0.2.7__tar.gz → 0.2.8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of bioguider might be problematic. Click here for more details.
- {bioguider-0.2.7 → bioguider-0.2.8}/PKG-INFO +1 -1
- {bioguider-0.2.7 → bioguider-0.2.8}/bioguider/agents/agent_tools.py +13 -5
- {bioguider-0.2.7 → bioguider-0.2.8}/bioguider/agents/agent_utils.py +27 -5
- {bioguider-0.2.7 → bioguider-0.2.8}/bioguider/agents/collection_execute_step.py +2 -0
- {bioguider-0.2.7 → bioguider-0.2.8}/bioguider/agents/collection_task.py +42 -22
- {bioguider-0.2.7 → bioguider-0.2.8}/bioguider/agents/evaluation_installation_task.py +1 -0
- {bioguider-0.2.7 → bioguider-0.2.8}/bioguider/agents/identification_execute_step.py +2 -0
- {bioguider-0.2.7 → bioguider-0.2.8}/bioguider/agents/identification_task.py +32 -17
- {bioguider-0.2.7 → bioguider-0.2.8}/bioguider/database/summarized_file_db.py +10 -7
- {bioguider-0.2.7 → bioguider-0.2.8}/pyproject.toml +1 -1
- {bioguider-0.2.7 → bioguider-0.2.8}/LICENSE +0 -0
- {bioguider-0.2.7 → bioguider-0.2.8}/README.md +0 -0
- {bioguider-0.2.7 → bioguider-0.2.8}/bioguider/__init__.py +0 -0
- {bioguider-0.2.7 → bioguider-0.2.8}/bioguider/agents/__init__.py +0 -0
- {bioguider-0.2.7 → bioguider-0.2.8}/bioguider/agents/agent_task.py +0 -0
- {bioguider-0.2.7 → bioguider-0.2.8}/bioguider/agents/collection_observe_step.py +0 -0
- {bioguider-0.2.7 → bioguider-0.2.8}/bioguider/agents/collection_plan_step.py +0 -0
- {bioguider-0.2.7 → bioguider-0.2.8}/bioguider/agents/collection_task_utils.py +0 -0
- {bioguider-0.2.7 → bioguider-0.2.8}/bioguider/agents/common_agent.py +0 -0
- {bioguider-0.2.7 → bioguider-0.2.8}/bioguider/agents/common_agent_2step.py +0 -0
- {bioguider-0.2.7 → bioguider-0.2.8}/bioguider/agents/common_step.py +0 -0
- {bioguider-0.2.7 → bioguider-0.2.8}/bioguider/agents/dockergeneration_execute_step.py +0 -0
- {bioguider-0.2.7 → bioguider-0.2.8}/bioguider/agents/dockergeneration_observe_step.py +0 -0
- {bioguider-0.2.7 → bioguider-0.2.8}/bioguider/agents/dockergeneration_plan_step.py +0 -0
- {bioguider-0.2.7 → bioguider-0.2.8}/bioguider/agents/dockergeneration_task.py +0 -0
- {bioguider-0.2.7 → bioguider-0.2.8}/bioguider/agents/dockergeneration_task_utils.py +0 -0
- {bioguider-0.2.7 → bioguider-0.2.8}/bioguider/agents/evaluation_task.py +0 -0
- {bioguider-0.2.7 → bioguider-0.2.8}/bioguider/agents/identification_observe_step.py +0 -0
- {bioguider-0.2.7 → bioguider-0.2.8}/bioguider/agents/identification_plan_step.py +0 -0
- {bioguider-0.2.7 → bioguider-0.2.8}/bioguider/agents/identification_task_utils.py +0 -0
- {bioguider-0.2.7 → bioguider-0.2.8}/bioguider/agents/peo_common_step.py +0 -0
- {bioguider-0.2.7 → bioguider-0.2.8}/bioguider/agents/prompt_utils.py +0 -0
- {bioguider-0.2.7 → bioguider-0.2.8}/bioguider/agents/python_ast_repl_tool.py +0 -0
- {bioguider-0.2.7 → bioguider-0.2.8}/bioguider/agents/rag_collection_task.py +0 -0
- {bioguider-0.2.7 → bioguider-0.2.8}/bioguider/conversation.py +0 -0
- {bioguider-0.2.7 → bioguider-0.2.8}/bioguider/managers/evaluation_manager.py +0 -0
- {bioguider-0.2.7 → bioguider-0.2.8}/bioguider/rag/__init__.py +0 -0
- {bioguider-0.2.7 → bioguider-0.2.8}/bioguider/rag/config.py +0 -0
- {bioguider-0.2.7 → bioguider-0.2.8}/bioguider/rag/data_pipeline.py +0 -0
- {bioguider-0.2.7 → bioguider-0.2.8}/bioguider/rag/embedder.py +0 -0
- {bioguider-0.2.7 → bioguider-0.2.8}/bioguider/rag/rag.py +0 -0
- {bioguider-0.2.7 → bioguider-0.2.8}/bioguider/settings.py +0 -0
- {bioguider-0.2.7 → bioguider-0.2.8}/bioguider/utils/constants.py +0 -0
- {bioguider-0.2.7 → bioguider-0.2.8}/bioguider/utils/default.gitignore +0 -0
- {bioguider-0.2.7 → bioguider-0.2.8}/bioguider/utils/file_utils.py +0 -0
- {bioguider-0.2.7 → bioguider-0.2.8}/bioguider/utils/gitignore_checker.py +0 -0
- {bioguider-0.2.7 → bioguider-0.2.8}/bioguider/utils/pyphen_utils.py +0 -0
- {bioguider-0.2.7 → bioguider-0.2.8}/bioguider/utils/utils.py +0 -0
|
@@ -53,7 +53,8 @@ Returns:
|
|
|
53
53
|
class summarize_file_tool(agent_tool):
|
|
54
54
|
""" read and summarize the file
|
|
55
55
|
Args:
|
|
56
|
-
file_path str: file path
|
|
56
|
+
file_path str [required]: the file path
|
|
57
|
+
summarize_prompt str [required]: a prompt to guide how to summarize the file, if no prompt needed, please set "N/A"
|
|
57
58
|
Returns:
|
|
58
59
|
A string of summarized file content, if the file does not exist, return None.
|
|
59
60
|
"""
|
|
@@ -75,27 +76,31 @@ Returns:
|
|
|
75
76
|
self.summary_file_db = db
|
|
76
77
|
self.summarize_instruction = summaize_instruction
|
|
77
78
|
|
|
78
|
-
def _retrive_from_summary_file_db(self, file_path: str) -> str | None:
|
|
79
|
+
def _retrive_from_summary_file_db(self, file_path: str, prompt: str = "N/A") -> str | None:
|
|
79
80
|
if self.summary_file_db is None:
|
|
80
81
|
return None
|
|
81
82
|
return self.summary_file_db.select_summarized_text(
|
|
82
83
|
file_path=file_path,
|
|
83
84
|
instruction=self.summarize_instruction,
|
|
84
85
|
summarize_level=self.detailed_level,
|
|
86
|
+
summarize_prompt=prompt,
|
|
85
87
|
)
|
|
86
|
-
def _save_to_summary_file_db(self, file_path: str, summarized_text: str, token_usage: dict):
|
|
88
|
+
def _save_to_summary_file_db(self, file_path: str, prompt: str, summarized_text: str, token_usage: dict):
|
|
87
89
|
if self.summary_file_db is None:
|
|
88
90
|
return
|
|
89
91
|
self.summary_file_db.upsert_summarized_file(
|
|
90
92
|
file_path=file_path,
|
|
91
93
|
instruction=self.summarize_instruction,
|
|
92
94
|
summarize_level=self.detailed_level,
|
|
95
|
+
summarize_prompt=prompt,
|
|
93
96
|
summarized_text=summarized_text,
|
|
94
97
|
token_usage=token_usage,
|
|
95
98
|
)
|
|
96
|
-
def run(self, file_path: str) -> str | None:
|
|
99
|
+
def run(self, file_path: str, summarize_prompt: str) -> str | None:
|
|
97
100
|
if file_path is None:
|
|
98
101
|
return None
|
|
102
|
+
if summarize_prompt is None or len(summarize_prompt) == 0:
|
|
103
|
+
summarize_prompt = "N/A"
|
|
99
104
|
|
|
100
105
|
file_path = file_path.strip()
|
|
101
106
|
abs_file_path = file_path
|
|
@@ -104,7 +109,8 @@ Returns:
|
|
|
104
109
|
if not os.path.isfile(abs_file_path):
|
|
105
110
|
return f"{file_path} is not a file."
|
|
106
111
|
summarized_content = self._retrive_from_summary_file_db(
|
|
107
|
-
file_path=file_path
|
|
112
|
+
file_path=file_path,
|
|
113
|
+
prompt=summarize_prompt,
|
|
108
114
|
)
|
|
109
115
|
if summarized_content is not None:
|
|
110
116
|
return f"summarized content of file {file_path}: " + summarized_content
|
|
@@ -114,9 +120,11 @@ Returns:
|
|
|
114
120
|
summarized_content, token_usage = summarize_file(
|
|
115
121
|
self.llm, abs_file_path, file_content, self.detailed_level,
|
|
116
122
|
summary_instructions=self.summarize_instruction,
|
|
123
|
+
summarize_prompt=summarize_prompt,
|
|
117
124
|
)
|
|
118
125
|
self._save_to_summary_file_db(
|
|
119
126
|
file_path=file_path,
|
|
127
|
+
prompt=summarize_prompt,
|
|
120
128
|
summarized_text=summarized_content,
|
|
121
129
|
token_usage=token_usage,
|
|
122
130
|
)
|
|
@@ -153,13 +153,28 @@ def read_directory(
|
|
|
153
153
|
|
|
154
154
|
|
|
155
155
|
EVALUATION_SUMMARIZE_FILE_PROMPT = ChatPromptTemplate.from_template("""
|
|
156
|
-
You
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
156
|
+
You will be provided with the content of the file **{file_name}**:
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
160
|
### **Summary Instructions**
|
|
161
161
|
{summary_instructions}
|
|
162
162
|
The content is lengthy. Please generate a concise summary ({sentence_num1}-{sentence_num2} sentences).
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
### **Important Instructions**
|
|
167
|
+
{summarize_prompt}
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
### **File Content**
|
|
172
|
+
Here is the file content:
|
|
173
|
+
{file_content}
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
Now, let's start to summarize.
|
|
163
178
|
""")
|
|
164
179
|
|
|
165
180
|
MAX_FILE_LENGTH=20 *1024 # 20K
|
|
@@ -170,6 +185,7 @@ def summarize_file(
|
|
|
170
185
|
content: str | None = None,
|
|
171
186
|
level: int = 3,
|
|
172
187
|
summary_instructions: str | None = None,
|
|
188
|
+
summarize_prompt: str = "N/A",
|
|
173
189
|
db: SummarizedFilesDb | None = None,
|
|
174
190
|
) -> Tuple[str, dict]:
|
|
175
191
|
if content is None:
|
|
@@ -198,6 +214,7 @@ def summarize_file(
|
|
|
198
214
|
summary_instructions=summary_instructions \
|
|
199
215
|
if summary_instructions is not None and len(summary_instructions) > 0 \
|
|
200
216
|
else "N/A",
|
|
217
|
+
summarize_prompt=summarize_prompt,
|
|
201
218
|
)
|
|
202
219
|
|
|
203
220
|
config = {"recursion_limit": 500}
|
|
@@ -210,7 +227,12 @@ def summarize_file(
|
|
|
210
227
|
}
|
|
211
228
|
if db is not None:
|
|
212
229
|
db.upsert_summarized_file(
|
|
213
|
-
name,
|
|
230
|
+
file_path=name,
|
|
231
|
+
instruction=summary_instructions,
|
|
232
|
+
summarize_level=level,
|
|
233
|
+
summarize_prompt=summarize_prompt,
|
|
234
|
+
summarized_text=out,
|
|
235
|
+
token_usage=token_usage,
|
|
214
236
|
)
|
|
215
237
|
|
|
216
238
|
return out, token_usage
|
|
@@ -62,11 +62,13 @@ Action Observation: {{Observation2}}
|
|
|
62
62
|
```
|
|
63
63
|
Action: summarize_file_tool
|
|
64
64
|
Action Input: README.md
|
|
65
|
+
Action Input: "Please extract license information in summarized file content."
|
|
65
66
|
Observation: # BioGuider\nBioGuider is a Python package for bioinformatics.\n...
|
|
66
67
|
...
|
|
67
68
|
Final Answer:
|
|
68
69
|
Action: summarize_file_tool
|
|
69
70
|
Action Input: README.md
|
|
71
|
+
Action Input: "N/A"
|
|
70
72
|
Action Observation: # BioGuider\nBioGuider is a Python package for bioinformatics.\n...
|
|
71
73
|
---
|
|
72
74
|
Action: check_file_related_tool
|
|
@@ -61,6 +61,46 @@ class CollectionTask(AgentTask):
|
|
|
61
61
|
self.tools: list[any] | None = None
|
|
62
62
|
self.custom_tools: list[Tool] | None = None
|
|
63
63
|
|
|
64
|
+
def _prepare_tools(self, related_file_goal_item_desc):
|
|
65
|
+
tool_rd = read_directory_tool(repo_path=self.repo_path)
|
|
66
|
+
tool_sum = summarize_file_tool(
|
|
67
|
+
llm=self.llm,
|
|
68
|
+
repo_path=self.repo_path,
|
|
69
|
+
output_callback=self.step_callback,
|
|
70
|
+
db=self.summary_file_db,
|
|
71
|
+
)
|
|
72
|
+
tool_rf = read_file_tool(repo_path=self.repo_path)
|
|
73
|
+
tool_cf = check_file_related_tool(
|
|
74
|
+
llm=self.llm,
|
|
75
|
+
repo_path=self.repo_path,
|
|
76
|
+
goal_item_desc=related_file_goal_item_desc,
|
|
77
|
+
output_callback=self.step_callback,
|
|
78
|
+
)
|
|
79
|
+
self.tools = [tool_rd, tool_sum, tool_rf, tool_cf]
|
|
80
|
+
self.custom_tools = [
|
|
81
|
+
Tool(
|
|
82
|
+
name = tool_rd.__class__.__name__,
|
|
83
|
+
func = tool_rd.run,
|
|
84
|
+
description=tool_rd.__class__.__doc__,
|
|
85
|
+
),
|
|
86
|
+
StructuredTool.from_function(
|
|
87
|
+
tool_sum.run,
|
|
88
|
+
description=tool_sum.__class__.__doc__,
|
|
89
|
+
name=tool_sum.__class__.__name__,
|
|
90
|
+
),
|
|
91
|
+
Tool(
|
|
92
|
+
name = tool_rf.__class__.__name__,
|
|
93
|
+
func = tool_rf.run,
|
|
94
|
+
description=tool_rf.__class__.__doc__,
|
|
95
|
+
),
|
|
96
|
+
Tool(
|
|
97
|
+
name = tool_cf.__class__.__name__,
|
|
98
|
+
func = tool_cf.run,
|
|
99
|
+
description=tool_cf.__class__.__doc__,
|
|
100
|
+
),
|
|
101
|
+
]
|
|
102
|
+
self.custom_tools.append(CustomPythonAstREPLTool())
|
|
103
|
+
|
|
64
104
|
def _initialize(self):
|
|
65
105
|
# initialize the 2-level file structure of the repo
|
|
66
106
|
if not os.path.exists(self.repo_path):
|
|
@@ -76,28 +116,8 @@ class CollectionTask(AgentTask):
|
|
|
76
116
|
goal_item=collection_item["goal_item"],
|
|
77
117
|
related_file_description=collection_item["related_file_description"],
|
|
78
118
|
)
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
summarize_file_tool(
|
|
82
|
-
llm=self.llm,
|
|
83
|
-
repo_path=self.repo_path,
|
|
84
|
-
output_callback=self.step_callback,
|
|
85
|
-
db=self.summary_file_db,
|
|
86
|
-
),
|
|
87
|
-
read_file_tool(repo_path=self.repo_path),
|
|
88
|
-
check_file_related_tool(
|
|
89
|
-
llm=self.llm,
|
|
90
|
-
repo_path=self.repo_path,
|
|
91
|
-
goal_item_desc=related_file_goal_item_desc,
|
|
92
|
-
output_callback=self.step_callback,
|
|
93
|
-
),
|
|
94
|
-
]
|
|
95
|
-
self.custom_tools = [Tool(
|
|
96
|
-
name=tool.__class__.__name__,
|
|
97
|
-
func=tool.run,
|
|
98
|
-
description=tool.__class__.__doc__,
|
|
99
|
-
) for tool in self.tools]
|
|
100
|
-
self.custom_tools.append(CustomPythonAstREPLTool())
|
|
119
|
+
|
|
120
|
+
self._prepare_tools(related_file_goal_item_desc)
|
|
101
121
|
self.steps = [
|
|
102
122
|
CollectionPlanStep(
|
|
103
123
|
llm=self.llm,
|
|
@@ -118,6 +118,7 @@ class EvaluationInstallationTask(EvaluationTask):
|
|
|
118
118
|
step_callback = None,
|
|
119
119
|
):
|
|
120
120
|
super().__init__(llm, repo_path, gitignore_path, meta_data, step_callback)
|
|
121
|
+
self.evaluation_name = "Installation Evaluation"
|
|
121
122
|
|
|
122
123
|
def _evaluate(self, files: list[str] | None = None):
|
|
123
124
|
if files is None or len(files) == 0:
|
|
@@ -60,11 +60,13 @@ Action Observation: {{Observation2}}
|
|
|
60
60
|
```
|
|
61
61
|
Action: summarize_file_tool
|
|
62
62
|
Action Input: README.md
|
|
63
|
+
Action Input: "Please extract license information in summarized file content."
|
|
63
64
|
Observation: # BioGuider\nBioGuider is a Python package for bioinformatics.\n...
|
|
64
65
|
...
|
|
65
66
|
Final Answer:
|
|
66
67
|
Action: summarize_file_tool
|
|
67
68
|
Action Input: README.md
|
|
69
|
+
Action Input: "N/A"
|
|
68
70
|
Action Observation: # BioGuider\nBioGuider is a Python package for bioinformatics.\n...
|
|
69
71
|
---
|
|
70
72
|
Action: check_file_related_tool
|
|
@@ -6,7 +6,7 @@ from enum import Enum
|
|
|
6
6
|
from typing import Callable
|
|
7
7
|
from pydantic import BaseModel, Field
|
|
8
8
|
from langchain_openai.chat_models.base import BaseChatOpenAI
|
|
9
|
-
from langchain.tools import Tool
|
|
9
|
+
from langchain.tools import Tool, StructuredTool
|
|
10
10
|
from langgraph.graph import StateGraph, START, END
|
|
11
11
|
|
|
12
12
|
from bioguider.utils.constants import PrimaryLanguageEnum, ProjectTypeEnum
|
|
@@ -72,6 +72,36 @@ class IdentificationTask(AgentTask):
|
|
|
72
72
|
self.custom_tools = []
|
|
73
73
|
self.steps: list[PEOCommonStep] = []
|
|
74
74
|
|
|
75
|
+
def _prepare_tools(self):
|
|
76
|
+
tool_rd = read_directory_tool(repo_path=self.repo_path)
|
|
77
|
+
tool_sum = summarize_file_tool(
|
|
78
|
+
llm=self.llm,
|
|
79
|
+
repo_path=self.repo_path,
|
|
80
|
+
output_callback=self.step_callback,
|
|
81
|
+
db=self.summary_file_db,
|
|
82
|
+
)
|
|
83
|
+
tool_rf = read_file_tool(repo_path=self.repo_path)
|
|
84
|
+
|
|
85
|
+
self.tools = [tool_rd, tool_sum, tool_rf,]
|
|
86
|
+
self.custom_tools = [
|
|
87
|
+
Tool(
|
|
88
|
+
name = tool_rd.__class__.__name__,
|
|
89
|
+
func = tool_rd.run,
|
|
90
|
+
description=tool_rd.__class__.__doc__,
|
|
91
|
+
),
|
|
92
|
+
StructuredTool.from_function(
|
|
93
|
+
tool_sum.run,
|
|
94
|
+
description=tool_sum.__class__.__doc__,
|
|
95
|
+
name=tool_sum.__class__.__name__,
|
|
96
|
+
),
|
|
97
|
+
Tool(
|
|
98
|
+
name = tool_rf.__class__.__name__,
|
|
99
|
+
func = tool_rf.run,
|
|
100
|
+
description=tool_rf.__class__.__doc__,
|
|
101
|
+
),
|
|
102
|
+
]
|
|
103
|
+
self.custom_tools.append(CustomPythonAstREPLTool())
|
|
104
|
+
|
|
75
105
|
def _initialize(self):
|
|
76
106
|
if not os.path.exists(self.repo_path):
|
|
77
107
|
raise ValueError(f"Repository path {self.repo_path} does not exist.")
|
|
@@ -81,22 +111,7 @@ class IdentificationTask(AgentTask):
|
|
|
81
111
|
for f, f_type in file_pairs:
|
|
82
112
|
self.repo_structure += f"{f} - {f_type}\n"
|
|
83
113
|
|
|
84
|
-
self.
|
|
85
|
-
summarize_file_tool(
|
|
86
|
-
llm=self.llm,
|
|
87
|
-
repo_path=self.repo_path,
|
|
88
|
-
output_callback=self._print_step,
|
|
89
|
-
db=self.summary_file_db,
|
|
90
|
-
),
|
|
91
|
-
read_directory_tool(repo_path=self.repo_path, gitignore_path=self.gitignore_path),
|
|
92
|
-
read_file_tool(repo_path=self.repo_path),
|
|
93
|
-
]
|
|
94
|
-
self.custom_tools = [Tool(
|
|
95
|
-
name=tool.__class__.__name__,
|
|
96
|
-
func=tool.run,
|
|
97
|
-
description=tool.__class__.__doc__,
|
|
98
|
-
) for tool in self.tools]
|
|
99
|
-
self.custom_tools.append(CustomPythonAstREPLTool())
|
|
114
|
+
self._prepare_tools()
|
|
100
115
|
self.steps = [
|
|
101
116
|
IdentificationPlanStep(
|
|
102
117
|
llm=self.llm,
|
|
@@ -18,22 +18,23 @@ summarized_files_create_table_query = f"""
|
|
|
18
18
|
CREATE TABLE IF NOT EXISTS {SUMMARIZED_FILES_TABLE_NAME} (
|
|
19
19
|
file_path VARCHAR(512),
|
|
20
20
|
instruction TEXT,
|
|
21
|
+
summarize_prompt TEXT,
|
|
21
22
|
summarize_level INTEGER,
|
|
22
23
|
summarized_text TEXT,
|
|
23
24
|
token_usage VARCHAR(512),
|
|
24
25
|
datetime TEXT NOT NULL DEFAULT (strftime('%Y-%m-%d %H:%M:%f', 'now')),
|
|
25
|
-
UNIQUE (file_path, instruction, summarize_level)
|
|
26
|
+
UNIQUE (file_path, instruction, summarize_level, summarize_prompt)
|
|
26
27
|
);
|
|
27
28
|
"""
|
|
28
29
|
summarized_files_upsert_query = f"""
|
|
29
|
-
INSERT INTO {SUMMARIZED_FILES_TABLE_NAME}(file_path, instruction, summarize_level, summarized_text, token_usage, datetime)
|
|
30
|
-
VALUES (?, ?, ?, ?, ?, strftime('%Y-%m-%d %H:%M:%f', 'now'))
|
|
31
|
-
ON CONFLICT(file_path, instruction, summarize_level) DO UPDATE SET summarized_text=excluded.summarized_text,
|
|
30
|
+
INSERT INTO {SUMMARIZED_FILES_TABLE_NAME}(file_path, instruction, summarize_level, summarize_prompt, summarized_text, token_usage, datetime)
|
|
31
|
+
VALUES (?, ?, ?, ?, ?, ?, strftime('%Y-%m-%d %H:%M:%f', 'now'))
|
|
32
|
+
ON CONFLICT(file_path, instruction, summarize_level, summarize_prompt) DO UPDATE SET summarized_text=excluded.summarized_text,
|
|
32
33
|
datetime=strftime('%Y-%m-%d %H:%M:%f', 'now');
|
|
33
34
|
"""
|
|
34
35
|
summarized_files_select_query = f"""
|
|
35
36
|
SELECT summarized_text, datetime FROM {SUMMARIZED_FILES_TABLE_NAME}
|
|
36
|
-
where file_path = ? and instruction = ? and summarize_level =
|
|
37
|
+
where file_path = ? and instruction = ? and summarize_level = ? and summarize_prompt=?;
|
|
37
38
|
"""
|
|
38
39
|
|
|
39
40
|
class SummarizedFilesDb:
|
|
@@ -83,6 +84,7 @@ class SummarizedFilesDb:
|
|
|
83
84
|
file_path: str,
|
|
84
85
|
instruction: str,
|
|
85
86
|
summarize_level: int,
|
|
87
|
+
summarize_prompt: str,
|
|
86
88
|
summarized_text: str,
|
|
87
89
|
token_usage: dict | None = None
|
|
88
90
|
):
|
|
@@ -96,7 +98,7 @@ class SummarizedFilesDb:
|
|
|
96
98
|
cursor = self.connection.cursor()
|
|
97
99
|
cursor.execute(
|
|
98
100
|
summarized_files_upsert_query,
|
|
99
|
-
(file_path, instruction, summarize_level, summarized_text, token_usage, )
|
|
101
|
+
(file_path, instruction, summarize_level, summarize_prompt, summarized_text, token_usage, )
|
|
100
102
|
)
|
|
101
103
|
self.connection.commit()
|
|
102
104
|
return True
|
|
@@ -112,6 +114,7 @@ class SummarizedFilesDb:
|
|
|
112
114
|
file_path: str,
|
|
113
115
|
instruction: str,
|
|
114
116
|
summarize_level: int,
|
|
117
|
+
summarize_prompt: str,
|
|
115
118
|
) -> str | None:
|
|
116
119
|
self._connect_to_db()
|
|
117
120
|
self._ensure_tables()
|
|
@@ -119,7 +122,7 @@ class SummarizedFilesDb:
|
|
|
119
122
|
cursor = self.connection.cursor()
|
|
120
123
|
cursor.execute(
|
|
121
124
|
summarized_files_select_query,
|
|
122
|
-
(file_path, instruction, summarize_level,)
|
|
125
|
+
(file_path, instruction, summarize_level, summarize_prompt,)
|
|
123
126
|
)
|
|
124
127
|
row = cursor.fetchone()
|
|
125
128
|
if row is None:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|