Skip to content

Commit

Permalink
Adding conftest.py and moving loading of main engine modules to init
Browse files Browse the repository at this point in the history
  • Loading branch information
Getty committed Dec 28, 2024
1 parent 5ec37e1 commit 6eb87a6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion mcp/engine/anthropic.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from typing import Any, Union, Dict, List, Optional
from anthropic import Anthropic
import os

from . import MCPEngine
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion mcp/engine/groq.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from typing import Any, Union, Dict, List, Optional
from groq import Groq
import os

from . import MCPEngine
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion mcp/engine/openai.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from typing import Any, Union, Dict, List, Optional
from openai import OpenAI
import os

from . import MCPEngine
Expand All @@ -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):
Expand Down
5 changes: 5 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -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__), '..')))

0 comments on commit 6eb87a6

Please sign in to comment.