diff --git a/mcp/engine/anthropic.py b/mcp/engine/anthropic.py index 035ec6c..81898b3 100644 --- a/mcp/engine/anthropic.py +++ b/mcp/engine/anthropic.py @@ -1,5 +1,4 @@ from typing import Any, Union, Dict, List, Optional -from anthropic import Anthropic import os from . import MCPEngine @@ -14,6 +13,7 @@ def __init__(self, self.api_key = api_key or os.environ.get("ANTHROPIC_API_KEY") if not isinstance(self.api_key, str) or len(self.api_key) < 51: raise Exception("Anthropic needs api_key (ANTHROPIC_API_KEY)") + from anthropic import Anthropic self.client = Anthropic(api_key=self.api_key) self.max_tokens = max_tokens or MCPEngineAnthropic.default_max_tokens diff --git a/mcp/engine/groq.py b/mcp/engine/groq.py index e301e71..293faa5 100644 --- a/mcp/engine/groq.py +++ b/mcp/engine/groq.py @@ -1,5 +1,4 @@ from typing import Any, Union, Dict, List, Optional -from groq import Groq import os from . import MCPEngine @@ -12,6 +11,7 @@ def __init__(self, self.api_key = api_key or os.environ.get("GROQ_API_KEY") if not isinstance(self.api_key, str) or len(self.api_key) < 51: raise Exception("Groq needs api_key (GROQ_API_KEY)") + from groq import Groq self.client = Groq(api_key=self.api_key) def update_models(self): diff --git a/mcp/engine/openai.py b/mcp/engine/openai.py index 3e46060..ba66965 100644 --- a/mcp/engine/openai.py +++ b/mcp/engine/openai.py @@ -1,5 +1,4 @@ from typing import Any, Union, Dict, List, Optional -from openai import OpenAI import os from . import MCPEngine @@ -12,6 +11,7 @@ def __init__(self, self.api_key = api_key or os.environ.get("OPENAI_API_KEY") if not isinstance(self.api_key, str) or len(self.api_key) < 51: raise Exception("OpenAI needs api_key (OPENAI_API_KEY)") + from openai import OpenAI self.client = OpenAI(api_key=self.api_key) def update_models(self): diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..d0a38ff --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,5 @@ +import sys +import os + +# Add the library's root directory to sys.path +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))