diff --git a/rag/llm/cv_model.py b/rag/llm/cv_model.py index 67d1bd10e..cdadf9476 100644 --- a/rag/llm/cv_model.py +++ b/rag/llm/cv_model.py @@ -228,7 +228,7 @@ class QWenCV(GptV4): base_url = "https://dashscope.aliyuncs.com/compatible-mode/v1" super().__init__(key, model_name, lang=lang, base_url=base_url, **kwargs) - def chat(self, system, history, gen_conf, images=None, video_bytes=None, filename=""): + def chat(self, system, history, gen_conf, images=None, video_bytes=None, filename="", **kwargs): if video_bytes: try: summary, summary_num_tokens = self._process_video(video_bytes, filename) @@ -547,7 +547,7 @@ class OllamaCV(Base): except Exception as e: return "**ERROR**: " + str(e), 0 - def chat(self, system, history, gen_conf, images=None): + def chat(self, system, history, gen_conf, images=None, **kwargs): try: response = self.client.chat( model=self.model_name, @@ -561,7 +561,7 @@ class OllamaCV(Base): except Exception as e: return "**ERROR**: " + str(e), 0 - def chat_streamly(self, system, history, gen_conf, images=None): + def chat_streamly(self, system, history, gen_conf, images=None, **kwargs): ans = "" try: response = self.client.chat( @@ -633,7 +633,7 @@ class GeminiCV(Base): return res.text, total_token_count_from_response(res) - def chat(self, system, history, gen_conf, images=None, video_bytes=None, filename=""): + def chat(self, system, history, gen_conf, images=None, video_bytes=None, filename="", **kwargs): if video_bytes: try: summary, summary_num_tokens = self._process_video(video_bytes, filename) @@ -651,7 +651,7 @@ class GeminiCV(Base): except Exception as e: return "**ERROR**: " + str(e), 0 - def chat_streamly(self, system, history, gen_conf, images=None): + def chat_streamly(self, system, history, gen_conf, images=None, **kwargs): ans = "" response = None try: @@ -858,7 +858,7 @@ class AnthropicCV(Base): gen_conf["max_tokens"] = self.max_tokens return gen_conf - def chat(self, system, history, gen_conf, images=None): + def chat(self, system, history, gen_conf, images=None, **kwargs): gen_conf = self._clean_conf(gen_conf) ans = "" try: @@ -879,7 +879,7 @@ class AnthropicCV(Base): except Exception as e: return ans + "\n**ERROR**: " + str(e), 0 - def chat_streamly(self, system, history, gen_conf, images=None): + def chat_streamly(self, system, history, gen_conf, images=None, **kwargs): gen_conf = self._clean_conf(gen_conf) total_tokens = 0 try: @@ -963,13 +963,13 @@ class GoogleCV(AnthropicCV, GeminiCV): else: return GeminiCV.describe_with_prompt(self, image, prompt) - def chat(self, system, history, gen_conf, images=None): + def chat(self, system, history, gen_conf, images=None, **kwargs): if "claude" in self.model_name: return AnthropicCV.chat(self, system, history, gen_conf, images) else: return GeminiCV.chat(self, system, history, gen_conf, images) - def chat_streamly(self, system, history, gen_conf, images=None): + def chat_streamly(self, system, history, gen_conf, images=None, **kwargs): if "claude" in self.model_name: for ans in AnthropicCV.chat_streamly(self, system, history, gen_conf, images): yield ans diff --git a/rag/prompts/generator.py b/rag/prompts/generator.py index 7214a32b1..c7fef07ff 100644 --- a/rag/prompts/generator.py +++ b/rag/prompts/generator.py @@ -755,7 +755,7 @@ async def run_toc_from_text(chunks, chat_mdl, callback=None): # Merge structure and content (by index) prune = len(toc_with_levels) > 512 - max_lvl = sorted([t.get("level", "0") for t in toc_with_levels])[-1] + max_lvl = sorted([t.get("level", "0") for t in toc_with_levels if isinstance(t, dict)])[-1] merged = [] for _ , (toc_item, src_item) in enumerate(zip(toc_with_levels, filtered)): if prune and toc_item.get("level", "0") >= max_lvl: