From eec4574f1f6668804c88bda67b901db10400fbc3 Mon Sep 17 00:00:00 2001 From: Stainless Bot <107565488+stainless-bot@users.noreply.github.com> Date: Tue, 19 Dec 2023 13:53:28 -0500 Subject: [PATCH] docs(readme): remove old migration guide (#289) --- README.md | 64 ------------------------------------------------------- 1 file changed, 64 deletions(-) diff --git a/README.md b/README.md index 82e8c20c..ae5c548f 100644 --- a/README.md +++ b/README.md @@ -8,70 +8,6 @@ and offers both synchronous and asynchronous clients powered by [httpx](https:// For the AWS Bedrock API, see [`anthropic-bedrock`](https://github.com/anthropics/anthropic-bedrock-python). -## Migration from v0.2.x and below - -In `v0.3.0`, we introduced a fully rewritten SDK. - -The new version uses separate sync and async clients, unified streaming, typed params and structured response objects, and resource-oriented methods: - -**Sync before/after:** - -```diff -- client = anthropic.Client(os.environ["ANTHROPIC_API_KEY"]) -+ client = anthropic.Anthropic(api_key=os.environ["ANTHROPIC_API_KEY"]) - # or, simply provide an ANTHROPIC_API_KEY environment variable: -+ client = anthropic.Anthropic() - -- rsp = client.completion(**params) -- rsp["completion"] -+ rsp = client.completions.create(**params) -+ rsp.completion -``` - -**Async before/after:** - -```diff -- client = anthropic.Client(os.environ["ANTHROPIC_API_KEY"]) -+ client = anthropic.AsyncAnthropic(api_key=os.environ["ANTHROPIC_API_KEY"]) - -- await client.acompletion(**params) -+ await client.completions.create(**params) -``` - -The `.completion_stream()` and `.acompletion_stream()` methods have been removed; -simply pass `stream=True`to `.completions.create()`. - -Streaming responses are now incremental; the full text is not sent in each message, -as v0.3 sends the `Anthropic-Version: 2023-06-01` header. - -
-Example streaming diff - -```diff py - import anthropic - -- client = anthropic.Client(os.environ["ANTHROPIC_API_KEY"]) -+ client = anthropic.Anthropic() - - # Streams are now incremental diffs of text - # rather than sending the whole message every time: - text = " -- stream = client.completion_stream(**params) -- for data in stream: -- diff = data["completion"].replace(text, "") -- text = data["completion"] -+ stream = client.completions.create(**params, stream=True) -+ for data in stream: -+ diff = data.completion # incremental text -+ text += data.completion - print(diff, end="") - - print("Done. Final text is:") - print(text) -``` - -
- ## Documentation The API documentation can be found [here](https://docs.anthropic.com/claude/reference/).