Skip to content

Commit

Permalink
add integration tests for other providers
Browse files Browse the repository at this point in the history
  • Loading branch information
the-praxs committed Jan 13, 2025
1 parent 751873b commit 558848a
Show file tree
Hide file tree
Showing 3 changed files with 421 additions and 27 deletions.
94 changes: 94 additions & 0 deletions tests/fixtures/providers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import os
import pytest
from typing import Any, List
import litellm
from openai import OpenAI
from anthropic import Anthropic
from ai21 import AI21Client, AsyncAI21Client
from cohere import Client as CohereClient
from groq import Groq
from mistralai import Mistral
from ai21.models.chat import ChatMessage
from dotenv import load_dotenv

load_dotenv()

# Test messages for different providers
@pytest.fixture
def test_messages():
return [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Write a short greeting."}
]

@pytest.fixture
def ai21_test_messages():
return [
ChatMessage(content="You are an expert mathematician.", role="system"),
ChatMessage(
content="Write a summary of 5 lines on the Shockley diode equation.",
role="user",
),
]

# Client fixtures
@pytest.fixture
def openai_client():
"""Initialize OpenAI client."""
api_key = os.getenv("OPENAI_API_KEY")
if not api_key:
pytest.skip("OPENAI_API_KEY not found in environment variables")
return OpenAI(api_key=api_key)

@pytest.fixture
def anthropic_client():
"""Initialize Anthropic client."""
api_key = os.getenv("ANTHROPIC_API_KEY")
if not api_key:
pytest.skip("ANTHROPIC_API_KEY not found in environment variables")
return Anthropic(api_key=api_key)

@pytest.fixture
def ai21_client():
"""Initialize AI21 sync client."""
api_key = os.getenv("AI21_API_KEY")
if not api_key:
pytest.skip("AI21_API_KEY not found in environment variables")
return AI21Client(api_key=api_key)

@pytest.fixture
def ai21_async_client():
"""Initialize AI21 async client."""
api_key = os.getenv("AI21_API_KEY")
if not api_key:
pytest.skip("AI21_API_KEY not found in environment variables")
return AsyncAI21Client(api_key=api_key)

@pytest.fixture
def cohere_client():
"""Initialize Cohere client."""
api_key = os.getenv("COHERE_API_KEY")
if not api_key:
pytest.skip("COHERE_API_KEY not found in environment variables")
return CohereClient(api_key=api_key)

@pytest.fixture
def groq_client():
"""Initialize Groq client."""
api_key = os.getenv("GROQ_API_KEY")
if not api_key:
pytest.skip("GROQ_API_KEY not found in environment variables")
return Groq(api_key=api_key)

@pytest.fixture
def mistral_client():
"""Initialize Mistral client."""
api_key = os.getenv("MISTRAL_API_KEY")
if not api_key:
pytest.skip("MISTRAL_API_KEY not found in environment variables")
return Mistral(api_key=api_key)

@pytest.fixture
def litellm_client():
"""Initialize LiteLLM client."""
return litellm
5 changes: 2 additions & 3 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import pytest

import agentops
from tests.fixtures.vcr import vcr_config

from tests.fixtures.providers import *

@pytest.fixture
def agentops_session():
agentops.start_session()

yield

agentops.end_all_sessions()
agentops.end_all_sessions()
Loading

0 comments on commit 558848a

Please sign in to comment.