diff --git a/backend/src/community/jina_ai/jina_client.py b/backend/src/community/jina_ai/jina_client.py index 2f0d07b..3b1a219 100644 --- a/backend/src/community/jina_ai/jina_client.py +++ b/backend/src/community/jina_ai/jina_client.py @@ -7,7 +7,6 @@ logger = logging.getLogger(__name__) class JinaClient: - def crawl(self, url: str, return_format: str = "html", timeout: int = 10) -> str: headers = { "Content-Type": "application/json", @@ -17,17 +16,13 @@ class JinaClient: if os.getenv("JINA_API_KEY"): headers["Authorization"] = f"Bearer {os.getenv('JINA_API_KEY')}" else: - logger.warning( - "Jina API key is not set. Provide your own key to access a higher rate limit. See https://jina.ai/reader for more information." - ) + logger.warning("Jina API key is not set. Provide your own key to access a higher rate limit. See https://jina.ai/reader for more information.") data = {"url": url} try: response = requests.post("https://r.jina.ai/", headers=headers, json=data) if response.status_code != 200: - error_message = ( - f"Jina API returned status {response.status_code}: {response.text}" - ) + error_message = f"Jina API returned status {response.status_code}: {response.text}" logger.error(error_message) return f"Error: {error_message}" diff --git a/backend/src/community/tavily/tools.py b/backend/src/community/tavily/tools.py index 0654cd0..9d675d8 100644 --- a/backend/src/community/tavily/tools.py +++ b/backend/src/community/tavily/tools.py @@ -45,7 +45,7 @@ def web_fetch_tool(url: str) -> str: """ res = tavily_client.extract([url]) if "failed_results" in res and len(res["failed_results"]) > 0: - return f"Error: {res["failed_results"][0]["error"]}" + return f"Error: {res['failed_results'][0]['error']}" elif "results" in res and len(res["results"]) > 0: result = res["results"][0] return f"# {result['title']}\n\n{result['raw_content']}" diff --git a/backend/src/config/model_config.py b/backend/src/config/model_config.py index ab79b47..a505c8f 100644 --- a/backend/src/config/model_config.py +++ b/backend/src/config/model_config.py @@ -5,21 +5,15 @@ class ModelConfig(BaseModel): """Config section for a model""" name: str = Field(..., description="Unique name for the model") - display_name: str | None = Field( - ..., default_factory=lambda: None, description="Display name for the model" - ) - description: str | None = Field( - ..., default_factory=lambda: None, description="Description for the model" - ) + display_name: str | None = Field(..., default_factory=lambda: None, description="Display name for the model") + description: str | None = Field(..., default_factory=lambda: None, description="Description for the model") use: str = Field( ..., description="Class path of the model provider(e.g. langchain_openai.ChatOpenAI)", ) model: str = Field(..., description="Model name") model_config = ConfigDict(extra="allow") - supports_thinking: bool = Field( - default_factory=lambda: False, description="Whether the model supports thinking" - ) + supports_thinking: bool = Field(default_factory=lambda: False, description="Whether the model supports thinking") when_thinking_enabled: dict | None = Field( default_factory=lambda: None, description="Extra settings to be passed to the model when thinking is enabled", diff --git a/backend/src/models/factory.py b/backend/src/models/factory.py index 879ca0a..8189cee 100644 --- a/backend/src/models/factory.py +++ b/backend/src/models/factory.py @@ -4,9 +4,7 @@ from src.config import get_app_config from src.reflection import resolve_class -def create_chat_model( - name: str | None = None, thinking_enabled: bool = False, **kwargs -) -> BaseChatModel: +def create_chat_model(name: str | None = None, thinking_enabled: bool = False, **kwargs) -> BaseChatModel: """Create a chat model instance from the config. Args: @@ -35,9 +33,7 @@ def create_chat_model( ) if thinking_enabled and model_config.when_thinking_enabled is not None: if not model_config.supports_thinking: - raise ValueError( - f"Model {name} does not support thinking. Set `supports_thinking` to true in the `config.yaml` to enable thinking." - ) from None + raise ValueError(f"Model {name} does not support thinking. Set `supports_thinking` to true in the `config.yaml` to enable thinking.") from None model_settings_from_config.update(model_config.when_thinking_enabled) model_instance = model_class(**kwargs, **model_settings_from_config) return model_instance diff --git a/backend/src/tools/tools.py b/backend/src/tools/tools.py index c8aa04d..870df6b 100644 --- a/backend/src/tools/tools.py +++ b/backend/src/tools/tools.py @@ -7,8 +7,4 @@ from src.reflection import resolve_variable def get_available_tools(groups: list[str] | None = None) -> list[BaseTool]: """Get all available tools from config""" config = get_app_config() - return [ - resolve_variable(tool.use, BaseTool) - for tool in config.tools - if groups is None or tool.group in groups - ] + return [resolve_variable(tool.use, BaseTool) for tool in config.tools if groups is None or tool.group in groups]