chore: drop tiktoken from anthropic async max_tokens test

This commit is contained in:
Greyson LaLonde
2026-04-11 03:20:20 +08:00
committed by GitHub
parent 9537ba0413
commit 298fc7b9c0
6 changed files with 6 additions and 27 deletions

View File

@@ -3,13 +3,9 @@ import json
import logging
import pytest
import tiktoken
from pydantic import BaseModel
from crewai.llm import LLM
# Pre-cache tiktoken encoding so VCR doesn't intercept the download request
tiktoken.get_encoding("cl100k_base")
from crewai.llms.providers.anthropic.completion import AnthropicCompletion
@@ -48,9 +44,7 @@ async def test_anthropic_async_with_max_tokens():
assert result is not None
assert isinstance(result, str)
encoder = tiktoken.get_encoding("cl100k_base")
token_count = len(encoder.encode(result))
assert token_count <= 10
assert len(result.split()) <= 10
@pytest.mark.vcr()

View File

@@ -1,7 +1,6 @@
"""Tests for Azure async completion functionality."""
import pytest
import tiktoken
from crewai import Agent, Task, Crew
from crewai.llm import LLM
@@ -57,9 +56,7 @@ async def test_azure_async_with_max_tokens():
assert result is not None
assert isinstance(result, str)
encoder = tiktoken.get_encoding("cl100k_base")
token_count = len(encoder.encode(result))
assert token_count <= 10
assert len(result.split()) <= 10
@pytest.mark.vcr()

View File

@@ -6,7 +6,6 @@ cannot be played back properly in CI.
"""
import pytest
import tiktoken
from crewai.llm import LLM
@@ -51,9 +50,7 @@ async def test_bedrock_async_with_max_tokens():
assert result is not None
assert isinstance(result, str)
encoder = tiktoken.get_encoding("cl100k_base")
token_count = len(encoder.encode(result))
assert token_count <= 10
assert len(result.split()) <= 10
@pytest.mark.vcr()

View File

@@ -1,7 +1,6 @@
"""Tests for Google (Gemini) async completion functionality."""
import pytest
import tiktoken
from crewai import Agent, Task, Crew
from crewai.llm import LLM
@@ -43,9 +42,7 @@ async def test_gemini_async_with_max_tokens():
assert result is not None
assert isinstance(result, str)
encoder = tiktoken.get_encoding("cl100k_base")
token_count = len(encoder.encode(result))
assert token_count <= 1000
assert len(result.split()) <= 1000
@pytest.mark.vcr()

View File

@@ -1,7 +1,6 @@
"""Tests for LiteLLM fallback async completion functionality."""
import pytest
import tiktoken
from crewai.llm import LLM
@@ -44,9 +43,7 @@ async def test_litellm_async_with_max_tokens():
assert result is not None
assert isinstance(result, str)
encoder = tiktoken.get_encoding("cl100k_base")
token_count = len(encoder.encode(result))
assert token_count <= 10
assert len(result.split()) <= 10
@pytest.mark.asyncio

View File

@@ -1,7 +1,6 @@
"""Tests for OpenAI async completion functionality."""
import pytest
import tiktoken
from crewai import Agent, Task, Crew
from crewai.llm import LLM
@@ -42,9 +41,7 @@ async def test_openai_async_with_max_tokens():
assert result is not None
assert isinstance(result, str)
encoder = tiktoken.get_encoding("cl100k_base")
token_count = len(encoder.encode(result))
assert token_count <= 10
assert len(result.split()) <= 10
@pytest.mark.vcr()