🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org
Python agentai-societiesartificial-intelligencecommunicative-aicooperative-aideep-learninglarge-language-modelsmulti-agent-systemsnatural-language-processing
fix: bugs and update openai_compatible_model (#2287)
Tao Sun425969a9756a
diff --git a/.env b/.envindex 01528a484..c4908c3a3 100644--- a/.env+++ b/.env@@ -103,9 +103,9 @@# OpenBB Platform API (https://my.openbb.co/app/credentials)# OPENBB_TOKEN="Fill your API key here"-# AWS API (https://aws.amazon.com/)-# BEDROCK_API_BASE_URL="Fill your Access Key ID here"-# BEDROCK_API_KEY="Fill your Secret Access Key here"+# AWS API (https://github.com/aws-samples/bedrock-access-gateway/blob/main/README.md)+# BEDROCK_API_BASE_URL="Fill your API Base Url here"+# BEDROCK_API_KEY="Fill your API Key here"# Bocha Platform API(https://open.bochaai.com)# BOCHA_API_KEY="Fill your API key here"diff --git a/camel/models/openai_compatible_model.py b/camel/models/openai_compatible_model.pyindex 7ee4ccc39..c53a0b00f 100644--- a/camel/models/openai_compatible_model.py+++ b/camel/models/openai_compatible_model.py@@ -16,7 +16,7 @@ import osfrom json import JSONDecodeErrorfrom typing import Any, Dict, List, Optional, Type, Union-from openai import AsyncOpenAI, AsyncStream, OpenAI, Stream+from openai import AsyncOpenAI, AsyncStream, BadRequestError, OpenAI, Streamfrom pydantic import BaseModel, ValidationErrorfrom camel.logger import get_logger@@ -198,7 +198,7 @@ class OpenAICompatibleModel(BaseModelBackend):model=self.model_type,**request_config,)- except (ValidationError, JSONDecodeError) as e:+ except (ValidationError, JSONDecodeError, BadRequestError) as e:logger.warning(f"Format validation error: {e}. "f"Attempting fallback with JSON format."@@ -237,7 +237,7 @@ class OpenAICompatibleModel(BaseModelBackend):model=self.model_type,**request_config,)- except (ValidationError, JSONDecodeError) as e:+ except (ValidationError, JSONDecodeError, BadRequestError) as e:logger.warning(f"Format validation error: {e}. "f"Attempting fallback with JSON format."diff --git a/camel/toolkits/browser_toolkit.py b/camel/toolkits/browser_toolkit.pyindex 4d4ee4a0f..a216d5a70 100644--- a/camel/toolkits/browser_toolkit.py+++ b/camel/toolkits/browser_toolkit.py@@ -542,10 +542,24 @@ class BaseBrowser:Returns:str: The answer to the question."""- video_analyzer = VideoAnalysisToolkit()- result = video_analyzer.ask_question_about_video(- self.page_url, question+ current_url = self.get_url()++ # Confirm with user before proceeding due to potential slow processing time+ confirmation_message = (+ f"Do you want to analyze the video on the current "+ f"page({current_url})? This operation may take a long time.(y/n): ")+ user_confirmation = input(confirmation_message)++ if user_confirmation.lower() not in ['y', 'yes']:+ return "User cancelled the video analysis."++ model = None+ if hasattr(self, 'web_agent_model'):+ model = self.web_agent_model++ video_analyzer = VideoAnalysisToolkit(model=model)+ result = video_analyzer.ask_question_about_video(current_url, question)return result@retry_on_error()