更新 ImageToMarkdown 处理器的设置
(self)
| 839 | print(f"更新图标失败: {e}") |
| 840 | |
| 841 | def update_client_settings(self): |
| 842 | """更新 ImageToMarkdown 处理器的设置""" |
| 843 | current_provider = self.provider_var.get() |
| 844 | settings = self.provider_settings.get(current_provider, {}) |
| 845 | |
| 846 | # 更新API Key |
| 847 | self.processor.set_api_key(settings.get('api_key', '')) |
| 848 | |
| 849 | # 更新代理 |
| 850 | self.processor.set_proxy(settings.get('proxy', '')) |
| 851 | |
| 852 | # 更新模型 |
| 853 | if current_provider == 'OPENAI': |
| 854 | self.processor.set_gpt_model(settings.get('model', 'gpt-4o')) |
| 855 | elif current_provider == '火山引擎': |
| 856 | self.processor.set_gpt_model(settings.get('model', '')) |
| 857 | elif current_provider == '自定义': |
| 858 | self.processor.set_gpt_model(settings.get('model', '')) |
| 859 | |
| 860 | # 更新Prompt&Token 设置 |
| 861 | prov_cfg = settings.get('prompt_settings', {}) |
| 862 | self.processor.set_prompts( |
| 863 | prov_cfg.get('system_prompt', 'You are a helpful assistant that converts images to markdown format. If the image contains mathematical formulas, use LaTeX syntax for them. Return only the markdown content of the image, without any additional words or explanations.'), |
| 864 | prov_cfg.get('user_prompt', 'Here is my image.') |
| 865 | ) |
| 866 | self.processor.set_max_tokens( |
| 867 | int(prov_cfg.get('max_tokens', 1000)) |
| 868 | ) |
| 869 | |
| 870 | def apply_provider_settings(self): |
| 871 | """处理和切换服务商相关的 UI 界面更新和组件显示""" |
no test coverage detected