auto-coder 0.1.298__py3-none-any.whl → 0.1.299__py3-none-any.whl
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 auto-coder might be problematic. Click here for more details.
- {auto_coder-0.1.298.dist-info → auto_coder-0.1.299.dist-info}/METADATA +2 -2
- {auto_coder-0.1.298.dist-info → auto_coder-0.1.299.dist-info}/RECORD +8 -8
- autocoder/rag/cache/local_duckdb_storage_cache.py +111 -17
- autocoder/version.py +1 -1
- {auto_coder-0.1.298.dist-info → auto_coder-0.1.299.dist-info}/LICENSE +0 -0
- {auto_coder-0.1.298.dist-info → auto_coder-0.1.299.dist-info}/WHEEL +0 -0
- {auto_coder-0.1.298.dist-info → auto_coder-0.1.299.dist-info}/entry_points.txt +0 -0
- {auto_coder-0.1.298.dist-info → auto_coder-0.1.299.dist-info}/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: auto-coder
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.299
|
|
4
4
|
Summary: AutoCoder: AutoCoder
|
|
5
5
|
Author: allwefantasy
|
|
6
6
|
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
@@ -27,7 +27,7 @@ Requires-Dist: jupyter-client
|
|
|
27
27
|
Requires-Dist: prompt-toolkit
|
|
28
28
|
Requires-Dist: tokenizers
|
|
29
29
|
Requires-Dist: aiofiles
|
|
30
|
-
Requires-Dist: byzerllm[saas] >=0.1.
|
|
30
|
+
Requires-Dist: byzerllm[saas] >=0.1.177
|
|
31
31
|
Requires-Dist: patch
|
|
32
32
|
Requires-Dist: diff-match-patch
|
|
33
33
|
Requires-Dist: GitPython
|
|
@@ -12,7 +12,7 @@ autocoder/chat_auto_coder_lang.py,sha256=-vyKq02RGn6N275YA06JZqXpfJkNq6PNjQ8wy4M
|
|
|
12
12
|
autocoder/command_args.py,sha256=9aYJ-AmPxP1sQh6ciw04FWHjSn31f2W9afXFwo8wgx4,30441
|
|
13
13
|
autocoder/lang.py,sha256=U6AjVV8Rs1uLyjFCZ8sT6WWuNUxMBqkXXIOs4S120uk,14511
|
|
14
14
|
autocoder/models.py,sha256=AyoZ-Pzy0oyYUmWCxOIRiOImsqboSfRET7LO9-UOuxI,11172
|
|
15
|
-
autocoder/version.py,sha256=
|
|
15
|
+
autocoder/version.py,sha256=WqTNULBHjgI3IA8iCC2s7W5EwDTmsEzCsgDE9lfb_Z0,23
|
|
16
16
|
autocoder/agent/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
17
|
autocoder/agent/auto_demand_organizer.py,sha256=NWSAEsEk94vT3lGjfo25kKLMwYdPcpy9e-i21txPasQ,6942
|
|
18
18
|
autocoder/agent/auto_filegroup.py,sha256=CW7bqp0FW1GIEMnl-blyAc2UGT7O9Mom0q66ITz1ckM,6635
|
|
@@ -144,7 +144,7 @@ autocoder/rag/cache/byzer_storage_cache.py,sha256=S_afj4_fFt88A0KJ23N-Gc3mMwPTDj
|
|
|
144
144
|
autocoder/rag/cache/cache_result_merge.py,sha256=VnTdbT2OMBmWl_83bqds97d9_M33IhPNX8tF7KH2GMM,10556
|
|
145
145
|
autocoder/rag/cache/file_monitor_cache.py,sha256=OdSXTH3vo6inAzkN5d55I0RN03GUlSlnUEKmXpjFl78,9443
|
|
146
146
|
autocoder/rag/cache/local_byzer_storage_cache.py,sha256=1xskK7X_hFEAsHHoT_F9lFYhQOTrpQtsFyFCIeI2Mvk,31964
|
|
147
|
-
autocoder/rag/cache/local_duckdb_storage_cache.py,sha256=
|
|
147
|
+
autocoder/rag/cache/local_duckdb_storage_cache.py,sha256=37WH2mlOgykBUrp6ow43kcaaKFZc1CRTkNLSFdELPcE,32714
|
|
148
148
|
autocoder/rag/cache/rag_file_meta.py,sha256=RQ3n4wfkHlB-1ljS3sFSi8ijbsUPeIqBSgjmmbRuwRI,20521
|
|
149
149
|
autocoder/rag/cache/simple_cache.py,sha256=j9dxhei-Nwq9FJrrGOWhaDIDSb_Iz6JSojT1pelS9k4,13084
|
|
150
150
|
autocoder/rag/loaders/__init__.py,sha256=EQHEZ5Cmz-mGP2SllUTvcIbYCnF7W149dNpNItfs0yE,304
|
|
@@ -183,9 +183,9 @@ autocoder/utils/types.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
183
183
|
autocoder/utils/auto_coder_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
184
184
|
autocoder/utils/auto_coder_utils/chat_stream_out.py,sha256=lkJ_A-sYU36JMzjFWkk3pR6uos8oZHYt9GPsPe_CPAo,11766
|
|
185
185
|
autocoder/utils/chat_auto_coder_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
186
|
-
auto_coder-0.1.
|
|
187
|
-
auto_coder-0.1.
|
|
188
|
-
auto_coder-0.1.
|
|
189
|
-
auto_coder-0.1.
|
|
190
|
-
auto_coder-0.1.
|
|
191
|
-
auto_coder-0.1.
|
|
186
|
+
auto_coder-0.1.299.dist-info/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
|
|
187
|
+
auto_coder-0.1.299.dist-info/METADATA,sha256=niJlVBDpwch1egujCz1OYDJHsz0bLumRLvnpOCJqKQA,2689
|
|
188
|
+
auto_coder-0.1.299.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
|
189
|
+
auto_coder-0.1.299.dist-info/entry_points.txt,sha256=0nzHtHH4pNcM7xq4EBA2toS28Qelrvcbrr59GqD_0Ak,350
|
|
190
|
+
auto_coder-0.1.299.dist-info/top_level.txt,sha256=Jqc0_uJSw2GwoFQAa9iJxYns-2mWla-9ok_Y3Gcznjk,10
|
|
191
|
+
auto_coder-0.1.299.dist-info/RECORD,,
|
|
@@ -652,40 +652,68 @@ class LocalDuckDBStorageCache(BaseCacheManager):
|
|
|
652
652
|
|
|
653
653
|
return all_files
|
|
654
654
|
|
|
655
|
-
def
|
|
656
|
-
"""
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
655
|
+
def _get_single_cache(self, query: str, options: Dict[str, Any]) -> List[Dict[str, Any]]:
|
|
656
|
+
"""
|
|
657
|
+
使用单个查询检索缓存文档
|
|
658
|
+
|
|
659
|
+
参数:
|
|
660
|
+
query: 查询字符串
|
|
661
|
+
options: 包含查询选项的字典
|
|
662
|
+
|
|
663
|
+
返回:
|
|
664
|
+
包含文档信息的字典列表,每个字典包含_id、file_path、mtime和score字段
|
|
665
|
+
"""
|
|
664
666
|
logger.info(f"正在使用向量搜索检索数据, 你的问题: {query}")
|
|
665
|
-
total_tokens = 0
|
|
666
667
|
results = []
|
|
667
668
|
|
|
668
669
|
# Add vector search if enabled
|
|
669
670
|
if options.get("enable_vector_search", True):
|
|
670
671
|
# 返回值包含 [(_id, file_path, mtime, score,),]
|
|
671
|
-
# results = self.storage.vector_search(query, similarity_value=0.7, similarity_top_k=200)
|
|
672
672
|
search_results = self.storage.vector_search(
|
|
673
673
|
query,
|
|
674
674
|
similarity_value=self.extra_params.rag_duckdb_query_similarity,
|
|
675
675
|
similarity_top_k=self.extra_params.rag_duckdb_query_top_k,
|
|
676
676
|
query_dim=self.extra_params.rag_duckdb_vector_dim
|
|
677
677
|
)
|
|
678
|
-
|
|
679
|
-
|
|
678
|
+
|
|
679
|
+
# Convert tuples to dictionaries for the merger
|
|
680
|
+
for _id, file_path, mtime, score in search_results:
|
|
681
|
+
results.append({
|
|
682
|
+
"_id": _id,
|
|
683
|
+
"file_path": file_path,
|
|
684
|
+
"mtime": mtime,
|
|
685
|
+
"score": score
|
|
686
|
+
})
|
|
687
|
+
|
|
688
|
+
logger.info(f"查询 '{query}' 返回 {len(results)} 条记录")
|
|
689
|
+
return results
|
|
690
|
+
|
|
691
|
+
def _process_search_results(self, results: List[Dict[str, Any]]) -> Dict[str, Dict]:
|
|
692
|
+
"""
|
|
693
|
+
处理搜索结果,提取文件路径并构建结果字典
|
|
694
|
+
|
|
695
|
+
参数:
|
|
696
|
+
results: 搜索结果列表,每项包含文档信息的字典
|
|
697
|
+
|
|
698
|
+
返回:
|
|
699
|
+
匹配文档的字典,键为文件路径,值为文件内容
|
|
700
|
+
|
|
701
|
+
说明:
|
|
702
|
+
该方法会根据查询结果从缓存中提取文件内容,并记录累计token数,
|
|
703
|
+
当累计token数超过max_output_tokens时,将停止处理并返回已处理的结果。
|
|
704
|
+
"""
|
|
705
|
+
# 记录被处理的总tokens数
|
|
706
|
+
total_tokens = 0
|
|
707
|
+
|
|
680
708
|
# Group results by file_path and reconstruct documents while preserving order
|
|
681
709
|
# 这里还可以有排序优化,综合考虑一篇内容出现的次数以及排序位置
|
|
682
710
|
file_paths = []
|
|
683
711
|
seen = set()
|
|
684
712
|
for result in results:
|
|
685
|
-
|
|
686
|
-
if
|
|
687
|
-
seen.add(
|
|
688
|
-
file_paths.append(
|
|
713
|
+
file_path = result["file_path"]
|
|
714
|
+
if file_path not in seen:
|
|
715
|
+
seen.add(file_path)
|
|
716
|
+
file_paths.append(file_path)
|
|
689
717
|
|
|
690
718
|
# 从缓存中获取文件内容
|
|
691
719
|
result = {}
|
|
@@ -706,3 +734,69 @@ class LocalDuckDBStorageCache(BaseCacheManager):
|
|
|
706
734
|
f"累计tokens: {total_tokens}, "
|
|
707
735
|
f"经过向量搜索共检索出 {len(result.keys())} 个文档, 共 {len(self.cache.keys())} 个文档")
|
|
708
736
|
return result
|
|
737
|
+
|
|
738
|
+
def get_cache(self, options: Optional[Dict[str, Any]] = None) -> Dict[str, Dict]:
|
|
739
|
+
"""
|
|
740
|
+
获取缓存中的文档信息
|
|
741
|
+
|
|
742
|
+
参数:
|
|
743
|
+
options: 包含查询参数的字典,可以包含以下键:
|
|
744
|
+
- queries: 查询列表,可以是单个查询或多个查询
|
|
745
|
+
- enable_vector_search: 是否启用向量搜索,默认为True
|
|
746
|
+
- merge_strategy: 多查询时的合并策略,默认为WEIGHTED_RANK
|
|
747
|
+
- max_results: 最大结果数,默认为None表示不限制
|
|
748
|
+
|
|
749
|
+
返回:
|
|
750
|
+
匹配文档的字典,键为文件路径,值为文件内容
|
|
751
|
+
"""
|
|
752
|
+
self.trigger_update() # 检查更新
|
|
753
|
+
|
|
754
|
+
if options is None or "queries" not in options:
|
|
755
|
+
return {file_path: self.cache[file_path].model_dump() for file_path in self.cache}
|
|
756
|
+
|
|
757
|
+
queries = options.get("queries", [])
|
|
758
|
+
|
|
759
|
+
# 如果没有查询或只有一个查询,使用原来的方法
|
|
760
|
+
if not queries:
|
|
761
|
+
return {file_path: self.cache[file_path].model_dump() for file_path in self.cache}
|
|
762
|
+
elif len(queries) == 1:
|
|
763
|
+
results = self._get_single_cache(queries[0], options)
|
|
764
|
+
return self._process_search_results(results)
|
|
765
|
+
|
|
766
|
+
# 导入合并策略
|
|
767
|
+
from autocoder.rag.cache.cache_result_merge import CacheResultMerger, MergeStrategy
|
|
768
|
+
|
|
769
|
+
# 获取合并策略
|
|
770
|
+
merge_strategy_name = options.get("merge_strategy", MergeStrategy.WEIGHTED_RANK.value)
|
|
771
|
+
try:
|
|
772
|
+
merge_strategy = MergeStrategy(merge_strategy_name)
|
|
773
|
+
except ValueError:
|
|
774
|
+
logger.warning(f"未知的合并策略: {merge_strategy_name}, 使用默认策略 WEIGHTED_RANK")
|
|
775
|
+
merge_strategy = MergeStrategy.WEIGHTED_RANK
|
|
776
|
+
|
|
777
|
+
# 限制最大结果数
|
|
778
|
+
max_results = options.get("max_results", None)
|
|
779
|
+
merger = CacheResultMerger(max_results=max_results)
|
|
780
|
+
|
|
781
|
+
# 并发处理多个查询
|
|
782
|
+
logger.info(f"处理多查询请求,查询数量: {len(queries)}, 合并策略: {merge_strategy}")
|
|
783
|
+
query_results = []
|
|
784
|
+
with ThreadPoolExecutor(max_workers=min(len(queries), 10)) as executor:
|
|
785
|
+
future_to_query = {executor.submit(self._get_single_cache, query, options): query for query in queries}
|
|
786
|
+
for future in as_completed(future_to_query):
|
|
787
|
+
query = future_to_query[future]
|
|
788
|
+
try:
|
|
789
|
+
query_result = future.result()
|
|
790
|
+
logger.info(f"查询 '{query}' 返回 {len(query_result)} 条记录")
|
|
791
|
+
query_results.append((query, query_result))
|
|
792
|
+
except Exception as e:
|
|
793
|
+
logger.error(f"处理查询 '{query}' 时出错: {str(e)}")
|
|
794
|
+
|
|
795
|
+
logger.info(f"所有查询共返回 {sum(len(r) for _, r in query_results)} 条记录")
|
|
796
|
+
|
|
797
|
+
# 使用策略合并结果
|
|
798
|
+
merged_results = merger.merge(query_results, strategy=merge_strategy)
|
|
799
|
+
logger.info(f"合并后的结果共 {len(merged_results)} 条记录")
|
|
800
|
+
|
|
801
|
+
# 处理合并后的结果
|
|
802
|
+
return self._process_search_results(merged_results)
|
autocoder/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.1.
|
|
1
|
+
__version__ = "0.1.299"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|