-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add anthropic messages support and stream (#118)
* add anthropic messages support and stream add examples * update anthropic version dependency * add log10.load Anthropic client * use claude-instant-1.2 in anthropic completions example
- Loading branch information
1 parent
045e0ed
commit 1b7b4ef
Showing
8 changed files
with
228 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import anthropic | ||
|
||
from log10.load import log10 | ||
|
||
|
||
log10(anthropic) | ||
|
||
client = anthropic.Anthropic() | ||
|
||
message = client.messages.create( | ||
model="claude-3-opus-20240229", | ||
max_tokens=1000, | ||
temperature=0.0, | ||
system="Respond only in Yoda-speak.", | ||
messages=[{"role": "user", "content": "How are you today?"}], | ||
) | ||
|
||
print(message.content[0].text) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import anthropic | ||
from anthropic import Anthropic | ||
|
||
from log10.load import log10 | ||
|
||
|
||
log10(anthropic) | ||
|
||
|
||
client = Anthropic() | ||
|
||
stream = client.messages.create( | ||
model="claude-3-opus-20240229", | ||
messages=[ | ||
{ | ||
"role": "user", | ||
"content": "Tell a 50 words joke.", | ||
} | ||
], | ||
max_tokens=128, | ||
temperature=0.9, | ||
stream=True, | ||
) | ||
for event in stream: | ||
if event.type == "content_block_delta": | ||
print(event.delta.text, end="", flush=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters