Skip to content

Commit

Permalink
fix format and del unused import (#525)
Browse files Browse the repository at this point in the history
Co-authored-by: Wendong <w3ndong.fan@gmail.com>
  • Loading branch information
ocss884 and Wendong-Fan committed Apr 23, 2024
1 parent 25c8e42 commit b91d07b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ jobs:
GOOGLE_API_KEY: "${{ secrets.GOOGLE_API_KEY }}"
SEARCH_ENGINE_ID: "${{ secrets.SEARCH_ENGINE_ID }}"
OPENWEATHERMAP_API_KEY: "${{ secrets.OPENWEATHERMAP_API_KEY }}"
ANTHROPIC_API_KEY: "${{ secrets.ANTHROPIC_API_KEY }}"
run: pytest --fast-test-mode ./test
3 changes: 3 additions & 0 deletions .github/workflows/pytest_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
GOOGLE_API_KEY: "${{ secrets.GOOGLE_API_KEY }}"
SEARCH_ENGINE_ID: "${{ secrets.SEARCH_ENGINE_ID }}"
OPENWEATHERMAP_API_KEY: "${{ secrets.OPENWEATHERMAP_API_KEY }}"
ANTHROPIC_API_KEY: "${{ secrets.ANTHROPIC_API_KEY }}"
run: poetry run pytest --fast-test-mode test/

pytest_package_llm_test:
Expand All @@ -43,6 +44,7 @@ jobs:
GOOGLE_API_KEY: "${{ secrets.GOOGLE_API_KEY }}"
SEARCH_ENGINE_ID: "${{ secrets.SEARCH_ENGINE_ID }}"
OPENWEATHERMAP_API_KEY: "${{ secrets.OPENWEATHERMAP_API_KEY }}"
ANTHROPIC_API_KEY: "${{ secrets.ANTHROPIC_API_KEY }}"
run: poetry run pytest --llm-test-only test/

pytest_package_very_slow_test:
Expand All @@ -59,4 +61,5 @@ jobs:
GOOGLE_API_KEY: "${{ secrets.GOOGLE_API_KEY }}"
SEARCH_ENGINE_ID: "${{ secrets.SEARCH_ENGINE_ID }}"
OPENWEATHERMAP_API_KEY: "${{ secrets.OPENWEATHERMAP_API_KEY }}"
ANTHROPIC_API_KEY: "${{ secrets.ANTHROPIC_API_KEY }}"
run: poetry run pytest --very-slow-test-only test/
5 changes: 2 additions & 3 deletions camel/utils/token_counting.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
from math import ceil
from typing import List, Optional

from anthropic import Anthropic
from PIL import Image

from anthropic import AI_PROMPT, HUMAN_PROMPT, Anthropic

from camel.messages import OpenAIMessage
from camel.types import ModelType, OpenAIImageDetailType, OpenAIImageType

Expand Down Expand Up @@ -257,7 +256,6 @@ def count_tokens_from_messages(self, messages: List[OpenAIMessage]) -> int:
return num_tokens



class AnthropicTokenCounter(BaseTokenCounter):

def __init__(self, model_type: ModelType):
Expand Down Expand Up @@ -287,6 +285,7 @@ def count_tokens_from_messages(self, messages: List[OpenAIMessage]) -> int:

return self.client.count_tokens(prompt)


def count_tokens_from_image(image: Image.Image,
detail: OpenAIImageDetailType) -> int:
r"""Count image tokens for OpenAI vision model. An :obj:`"auto"`
Expand Down

0 comments on commit b91d07b

Please sign in to comment.