Skip to content

Commit

Permalink
Bump anthropic from 0.37.1 to 0.39.0 (#355)
Browse files Browse the repository at this point in the history
* Bump anthropic from 0.37.1 to 0.39.0

Bumps [anthropic](https://github.com/anthropics/anthropic-sdk-python) from 0.37.1 to 0.39.0.
- [Release notes](https://github.com/anthropics/anthropic-sdk-python/releases)
- [Changelog](https://github.com/anthropics/anthropic-sdk-python/blob/main/CHANGELOG.md)
- [Commits](anthropics/anthropic-sdk-python@v0.37.1...v0.39.0)


* remove count_tokens api call, it has been removed in anthropic 0.39.0

* skip langchain anthropic test for now
  • Loading branch information
wenzhe-log10 authored Nov 15, 2024
1 parent 8685857 commit f4a2f1c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
19 changes: 9 additions & 10 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/log10/anthropic.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ def convert_claude_to_messages(prompt: str):

@staticmethod
def create_tokens_usage(prompt: str, completion: str):
client = anthropic.Anthropic()
prompt_tokens = client.count_tokens(prompt)
completion_tokens = client.count_tokens(completion)
# count_tokens is removed from the API in 0.39.0, consider to deprecate anthropic completion
prompt_tokens = 0
completion_tokens = 0
total_tokens = prompt_tokens + completion_tokens

# Imitate OpenAI usage format.
Expand Down
5 changes: 3 additions & 2 deletions tests/test_langchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ def test_chat_openai_messages(session, openai_model):
_LogAssertion(completion_id=session.last_completion_id(), message_content=content).assert_chat_response()


@pytest.mark.skip(reason="Anthropic API removed count_tokens in 0.39.0, langchain_community not updated")
@pytest.mark.chat
def test_chat_anthropic_messages(session, anthropic_legacy_model):
def test_chat_anthropic_messages(session, anthropic_model):
log10(anthropic)
llm = ChatAnthropic(model=anthropic_legacy_model, temperature=0.7)
llm = ChatAnthropic(model=anthropic_model, temperature=0.7)
messages = [SystemMessage(content="You are a ping pong machine"), HumanMessage(content="Ping?")]
completion = llm.predict_messages(messages)

Expand Down

0 comments on commit f4a2f1c

Please sign in to comment.