auto-coder 0.1.193__py3-none-any.whl → 0.1.194__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.

autocoder/auto_coder.py CHANGED
@@ -70,7 +70,8 @@ def load_include_files(config, base_path, max_depth=10, current_depth=0):
70
70
  with open(abs_include_path, "r") as f:
71
71
  include_config = yaml.safe_load(f)
72
72
  if not include_config:
73
- logger.info(f"Include file {abs_include_path} is empty,skipping.")
73
+ logger.info(
74
+ f"Include file {abs_include_path} is empty,skipping.")
74
75
  continue
75
76
  config.update(
76
77
  {
@@ -99,7 +100,7 @@ def main(input_args: Optional[List[str]] = None):
99
100
  config = load_include_files(config, args.file)
100
101
  for key, value in config.items():
101
102
  if key != "file": # 排除 --file 参数本身
102
- ## key: ENV {{VARIABLE_NAME}}
103
+ # key: ENV {{VARIABLE_NAME}}
103
104
  if isinstance(value, str) and value.startswith("ENV"):
104
105
  template = Template(value.removeprefix("ENV").strip())
105
106
  value = template.render(os.environ)
@@ -154,14 +155,16 @@ def main(input_args: Optional[List[str]] = None):
154
155
  )
155
156
  return
156
157
  os.makedirs(os.path.join(args.source_dir, "actions"), exist_ok=True)
157
- os.makedirs(os.path.join(args.source_dir, ".auto-coder"), exist_ok=True)
158
+ os.makedirs(os.path.join(args.source_dir,
159
+ ".auto-coder"), exist_ok=True)
158
160
 
159
161
  from autocoder.common.command_templates import create_actions
160
162
 
161
163
  source_dir = os.path.abspath(args.source_dir)
162
164
  create_actions(
163
165
  source_dir=source_dir,
164
- params={"project_type": args.project_type, "source_dir": source_dir},
166
+ params={"project_type": args.project_type,
167
+ "source_dir": source_dir},
165
168
  )
166
169
  git_utils.init(os.path.abspath(args.source_dir))
167
170
 
@@ -204,28 +207,33 @@ def main(input_args: Optional[List[str]] = None):
204
207
 
205
208
  if raw_args.from_yaml:
206
209
  # If --from_yaml is specified, copy content from the matching YAML file
207
- from_files = [f for f in action_files if f.startswith(raw_args.from_yaml)]
210
+ from_files = [
211
+ f for f in action_files if f.startswith(raw_args.from_yaml)]
208
212
  if from_files:
209
213
  from_file = from_files[0] # Take the first match
210
214
  with open(os.path.join(actions_dir, from_file), "r") as f:
211
215
  content = f.read()
212
- new_file = os.path.join(actions_dir, f"{new_seq}_{raw_args.name}.yml")
216
+ new_file = os.path.join(
217
+ actions_dir, f"{new_seq}_{raw_args.name}.yml")
213
218
  with open(new_file, "w") as f:
214
219
  f.write(content)
215
220
  else:
216
- print(f"No YAML file found matching prefix: {raw_args.from_yaml}")
221
+ print(
222
+ f"No YAML file found matching prefix: {raw_args.from_yaml}")
217
223
  return
218
224
  else:
219
225
  # If --from_yaml is not specified, use the previous logic
220
226
  if not prev_files:
221
- new_file = os.path.join(actions_dir, f"{new_seq}_{raw_args.name}.yml")
227
+ new_file = os.path.join(
228
+ actions_dir, f"{new_seq}_{raw_args.name}.yml")
222
229
  with open(new_file, "w") as f:
223
230
  pass
224
231
  else:
225
232
  prev_file = sorted(prev_files)[-1] # 取序号最大的文件
226
233
  with open(os.path.join(actions_dir, prev_file), "r") as f:
227
234
  content = f.read()
228
- new_file = os.path.join(actions_dir, f"{new_seq}_{raw_args.name}.yml")
235
+ new_file = os.path.join(
236
+ actions_dir, f"{new_seq}_{raw_args.name}.yml")
229
237
  with open(new_file, "w") as f:
230
238
  f.write(content)
231
239
 
@@ -311,7 +319,8 @@ def main(input_args: Optional[List[str]] = None):
311
319
  logger.warning(get_message("clipboard_not_supported"))
312
320
  console.print(
313
321
  Panel(
314
- get_message("human_as_model_instructions_no_clipboard"),
322
+ get_message(
323
+ "human_as_model_instructions_no_clipboard"),
315
324
  title="Instructions",
316
325
  border_style="blue",
317
326
  expand=False,
@@ -343,7 +352,8 @@ def main(input_args: Optional[List[str]] = None):
343
352
 
344
353
  lines = []
345
354
  while True:
346
- line = prompt(FormattedText([("#00FF00", "> ")]), multiline=False)
355
+ line = prompt(FormattedText(
356
+ [("#00FF00", "> ")]), multiline=False)
347
357
  line_lower = line.strip().lower()
348
358
  if line_lower in ["eof", "/eof"]:
349
359
  break
@@ -352,7 +362,8 @@ def main(input_args: Optional[List[str]] = None):
352
362
  print("\033[2J\033[H") # Clear terminal screen
353
363
  continue
354
364
  elif line_lower in ["/break"]:
355
- raise Exception("User requested to break the operation.")
365
+ raise Exception(
366
+ "User requested to break the operation.")
356
367
  lines.append(line)
357
368
 
358
369
  result = "\n".join(lines)
@@ -369,7 +380,8 @@ def main(input_args: Optional[List[str]] = None):
369
380
  ]
370
381
  return False, v
371
382
 
372
- llm.add_event_callback(EventName.BEFORE_CALL_MODEL, intercept_callback)
383
+ llm.add_event_callback(
384
+ EventName.BEFORE_CALL_MODEL, intercept_callback)
373
385
  code_model = llm.get_sub_client("code_model")
374
386
  if code_model:
375
387
  code_model.add_event_callback(
@@ -537,7 +549,8 @@ def main(input_args: Optional[List[str]] = None):
537
549
  import tempfile
538
550
 
539
551
  transcribe_audio = TranscribeAudio()
540
- temp_wav_file = os.path.join(tempfile.gettempdir(), "voice_input.wav")
552
+ temp_wav_file = os.path.join(
553
+ tempfile.gettempdir(), "voice_input.wav")
541
554
 
542
555
  console = Console()
543
556
 
@@ -644,7 +657,7 @@ def main(input_args: Optional[List[str]] = None):
644
657
  return
645
658
 
646
659
  elif raw_args.agent_command == "designer":
647
- from autocoder.agent.designer import SVGDesigner, SDDesigner
660
+ from autocoder.agent.designer import SVGDesigner, SDDesigner, LogoDesigner
648
661
 
649
662
  if args.agent_designer_mode == "svg":
650
663
  designer = SVGDesigner(args, llm)
@@ -654,11 +667,16 @@ def main(input_args: Optional[List[str]] = None):
654
667
  designer = SDDesigner(args, llm)
655
668
  designer.run(args.query)
656
669
  print("Successfully generated image in output.jpg")
670
+ elif args.agent_designer_mode.startswith("logo"):
671
+ designer = LogoDesigner(args, llm)
672
+ designer.run(args.query)
673
+ print("Successfully generated image in output.png")
657
674
  if args.request_id:
658
675
  request_queue.add_request(
659
676
  args.request_id,
660
677
  RequestValue(
661
- value=DefaultValue(value="Successfully generated image"),
678
+ value=DefaultValue(
679
+ value="Successfully generated image"),
662
680
  status=RequestOption.COMPLETED,
663
681
  ),
664
682
  )
@@ -712,7 +730,8 @@ def main(input_args: Optional[List[str]] = None):
712
730
  "content": f"下面是一些文档和源码,如果用户的问题和他们相关,请参考他们:\n{file_content}",
713
731
  },
714
732
  )
715
- pre_conversations.append({"role": "assistant", "content": "read"})
733
+ pre_conversations.append(
734
+ {"role": "assistant", "content": "read"})
716
735
  source_count += 1
717
736
 
718
737
  from autocoder.index.index import IndexManager, build_index_and_filter_files
@@ -728,7 +747,8 @@ def main(input_args: Optional[List[str]] = None):
728
747
  pp = SuffixProject(args=args, llm=llm, file_filter=None)
729
748
  pp.run()
730
749
  sources = pp.sources
731
- s = build_index_and_filter_files(llm=llm, args=args, sources=sources)
750
+ s = build_index_and_filter_files(
751
+ llm=llm, args=args, sources=sources)
732
752
  if s:
733
753
  pre_conversations.append(
734
754
  {
@@ -736,10 +756,12 @@ def main(input_args: Optional[List[str]] = None):
736
756
  "content": f"下面是一些文档和源码,如果用户的问题和他们相关,请参考他们:\n{s}",
737
757
  }
738
758
  )
739
- pre_conversations.append({"role": "assistant", "content": "read"})
759
+ pre_conversations.append(
760
+ {"role": "assistant", "content": "read"})
740
761
  source_count += 1
741
762
 
742
- loaded_conversations = pre_conversations + chat_history["ask_conversation"]
763
+ loaded_conversations = pre_conversations + \
764
+ chat_history["ask_conversation"]
743
765
 
744
766
  if args.human_as_model:
745
767
  console = Console()
@@ -760,12 +782,12 @@ def main(input_args: Optional[List[str]] = None):
760
782
  {% endfor %}
761
783
  {% endif %}
762
784
 
763
-
785
+
764
786
  参考上面的文件以及对话,回答用户的问题。
765
787
  用户的问题: {{ last_conversation.content }}
766
788
  """
767
789
 
768
- source_codes_conversations = loaded_conversations[0 : source_count * 2]
790
+ source_codes_conversations = loaded_conversations[0: source_count * 2]
769
791
  source_codes = ""
770
792
  for conv in source_codes_conversations:
771
793
  if conv["role"] == "user":
@@ -773,7 +795,7 @@ def main(input_args: Optional[List[str]] = None):
773
795
 
774
796
  chat_content = chat_with_human_as_model.prompt(
775
797
  source_codes=source_codes,
776
- pre_conversations=loaded_conversations[source_count * 2 : -1],
798
+ pre_conversations=loaded_conversations[source_count * 2: -1],
777
799
  last_conversation=loaded_conversations[-1],
778
800
  )
779
801
  try:
@@ -792,20 +814,22 @@ def main(input_args: Optional[List[str]] = None):
792
814
  logger.warning(get_message("clipboard_not_supported"))
793
815
  console.print(
794
816
  Panel(
795
- get_message("human_as_model_instructions_no_clipboard"),
817
+ get_message(
818
+ "human_as_model_instructions_no_clipboard"),
796
819
  title="Instructions",
797
820
  border_style="blue",
798
821
  expand=False,
799
822
  )
800
823
  )
801
- return
824
+ return
802
825
  # Save chat content to file
803
826
  with open(args.target_file, "w") as f:
804
827
  f.write(chat_content)
805
828
 
806
829
  lines = []
807
830
  while True:
808
- line = prompt(FormattedText([("#00FF00", "> ")]), multiline=False)
831
+ line = prompt(FormattedText(
832
+ [("#00FF00", "> ")]), multiline=False)
809
833
  line_lower = line.strip().lower()
810
834
  if line_lower in ["eof", "/eof"]:
811
835
  break
@@ -814,7 +838,8 @@ def main(input_args: Optional[List[str]] = None):
814
838
  print("\033[2J\033[H") # Clear terminal screen
815
839
  continue
816
840
  elif line_lower in ["/break"]:
817
- raise Exception("User requested to break the operation.")
841
+ raise Exception(
842
+ "User requested to break the operation.")
818
843
  lines.append(line)
819
844
 
820
845
  result = "\n".join(lines)
@@ -826,7 +851,7 @@ def main(input_args: Optional[List[str]] = None):
826
851
 
827
852
  with open(memory_file, "w") as f:
828
853
  json.dump(chat_history, f, ensure_ascii=False)
829
-
854
+
830
855
  request_queue.add_request(
831
856
  args.request_id,
832
857
  RequestValue(
@@ -838,7 +863,8 @@ def main(input_args: Optional[List[str]] = None):
838
863
 
839
864
  if args.enable_rag_search or args.enable_rag_context:
840
865
  rag = RAGFactory.get_rag(llm=chat_llm, args=args, path="")
841
- response = rag.stream_chat_oai(conversations=loaded_conversations)[0]
866
+ response = rag.stream_chat_oai(
867
+ conversations=loaded_conversations)[0]
842
868
  v = ([item, None] for item in response)
843
869
  else:
844
870
  v = chat_llm.stream_chat_oai(
@@ -848,35 +874,43 @@ def main(input_args: Optional[List[str]] = None):
848
874
  assistant_response = ""
849
875
  markdown_content = ""
850
876
 
851
- with Live(
852
- Panel("", title="Response"),
853
- refresh_per_second=4,
854
- ) as live:
855
- for res in v:
856
- markdown_content += res[0]
857
- assistant_response += res[0]
858
- request_queue.add_request(
859
- args.request_id,
860
- RequestValue(
861
- value=StreamValue(value=[res[0]]),
862
- status=RequestOption.RUNNING,
863
- ),
864
- )
865
- live.update(
866
- Panel(
867
- Markdown(markdown_content),
868
- title="Response",
869
- border_style="green",
870
- expand=False,
877
+ try:
878
+ with Live(
879
+ Panel("", title="Response"),
880
+ refresh_per_second=4,
881
+ ) as live:
882
+ for res in v:
883
+ markdown_content += res[0]
884
+ assistant_response += res[0]
885
+ request_queue.add_request(
886
+ args.request_id,
887
+ RequestValue(
888
+ value=StreamValue(value=[res[0]]),
889
+ status=RequestOption.RUNNING,
890
+ ),
871
891
  )
872
- )
873
-
874
- request_queue.add_request(
875
- args.request_id,
876
- RequestValue(
877
- value=StreamValue(value=[""]), status=RequestOption.COMPLETED
878
- ),
879
- )
892
+ live.update(
893
+ Panel(
894
+ Markdown(markdown_content),
895
+ title="Response",
896
+ border_style="green",
897
+ expand=False,
898
+ )
899
+ )
900
+ except Exception as e:
901
+ request_queue.add_request(
902
+ args.request_id,
903
+ RequestValue(
904
+ value=StreamValue(value=[str(e)]), status=RequestOption.FAILED
905
+ ),
906
+ )
907
+ finally:
908
+ request_queue.add_request(
909
+ args.request_id,
910
+ RequestValue(
911
+ value=StreamValue(value=[""]), status=RequestOption.COMPLETED
912
+ ),
913
+ )
880
914
 
881
915
  chat_history["ask_conversation"].append(
882
916
  {"role": "assistant", "content": assistant_response}
@@ -232,14 +232,14 @@ async def coding(request: QueryRequest, background_tasks: BackgroundTasks):
232
232
  os.remove(execute_file)
233
233
  except FileNotFoundError:
234
234
  pass
235
- _ = queue_communicate.send_event_no_wait(
235
+ _ = queue_communicate.send_event(
236
236
  request_id=request_id,
237
237
  event=CommunicateEvent(
238
238
  event_type=CommunicateEventType.CODE_END.value, data=""
239
239
  ),
240
240
  )
241
241
 
242
- _ = queue_communicate.send_event_no_wait(
242
+ _ = queue_communicate.send_event(
243
243
  request_id=request_id,
244
244
  event=CommunicateEvent(
245
245
  event_type=CommunicateEventType.CODE_START.value, data=request.query
@@ -955,7 +955,7 @@ class CommandCompleter(Completer):
955
955
  self.all_files = get_all_file_in_project()
956
956
  self.all_dir_names = get_all_dir_names_in_project()
957
957
  self.all_files_with_dot = get_all_file_in_project_with_dot()
958
- self.symbol_list = get_symbol_list()
958
+ self.symbol_list = get_symbol_list()
959
959
 
960
960
 
961
961
  completer = CommandCompleter(commands)
@@ -1019,6 +1019,7 @@ def add_files(args: List[str]):
1019
1019
 
1020
1020
  if args[0] == "/refresh":
1021
1021
  completer.refresh_files()
1022
+ load_memory()
1022
1023
  console.print(
1023
1024
  Panel("Refreshed file list.", title="Files Refreshed", border_style="green")
1024
1025
  )
@@ -1635,6 +1636,9 @@ def design(query: str):
1635
1636
  elif query.strip().startswith("/sd"):
1636
1637
  query = query.replace("/svg", "", 1).strip()
1637
1638
  yaml_config["agent_designer_mode"] = "sd"
1639
+ elif query.strip().startswith("/logo"):
1640
+ query = query.replace("/logo", "", 1).strip()
1641
+ yaml_config["agent_designer_mode"] = "logo"
1638
1642
  else:
1639
1643
  yaml_config["agent_designer_mode"] = "svg"
1640
1644
 
autocoder/command_args.py CHANGED
@@ -331,6 +331,19 @@ def parse_args(input_args: Optional[List[str]] = None) -> AutoCoderArgs:
331
331
  help="",
332
332
  )
333
333
 
334
+ parser.add_argument(
335
+ "--verify_file_relevance_score",
336
+ type=int,
337
+ default=6,
338
+ help="",
339
+ )
340
+ parser.add_argument(
341
+ "--filter_batch_size",
342
+ type=int,
343
+ default=5,
344
+ help=desc["filter_batch_size"],
345
+ )
346
+
334
347
  doc_serve_parse.add_argument(
335
348
  "--required_exts", default="", help=desc["doc_build_parse_required_exts"]
336
349
  )
@@ -263,7 +263,8 @@ class AutoCoderArgs(pydantic.BaseModel):
263
263
  rag_token: Optional[str] = ""
264
264
  rag_type: Optional[str] = "storage"
265
265
  rag_doc_filter_relevance: Optional[int] = 5
266
- rag_context_window_limit: Optional[int] = 120000
266
+ rag_context_window_limit: Optional[int] = 120000
267
+ verify_file_relevance_score: int = 6
267
268
  enable_rag_search: Optional[Union[bool, str]] = False
268
269
  enable_rag_context: Optional[Union[bool, str]] = False
269
270
  collection: Optional[str] = None
@@ -287,6 +288,7 @@ class AutoCoderArgs(pydantic.BaseModel):
287
288
  monitor_mode: bool = False
288
289
  enable_hybrid_index: bool = False
289
290
  disable_auto_window: bool = False
291
+ filter_batch_size: Optional[int] = 5
290
292
  disable_segment_reorder: bool = False
291
293
  rag_doc_filter_relevance: int = 5
292
294
  tokenizer_path: Optional[str] = None
@@ -247,7 +247,7 @@ class CodeAutoMergeEditBlock:
247
247
  }
248
248
  )
249
249
 
250
- _ = queue_communicate.send_event_no_wait(
250
+ _ = queue_communicate.send_event(
251
251
  request_id=self.args.request_id,
252
252
  event=CommunicateEvent(
253
253
  event_type=CommunicateEventType.CODE_MERGE_RESULT.value,
@@ -174,8 +174,8 @@ def base_base(source_dir:str,project_type:str)->str:
174
174
  model_max_input_length: 100000
175
175
  model_max_input_length: 120000
176
176
  enable_multi_round_generate: false
177
- index_filter_workers: 5
178
- index_build_workers: 20
177
+ index_filter_workers: 100
178
+ index_build_workers: 100
179
179
  index_filter_level: 1
180
180
 
181
181
  execute: true