Skip to content

Commit

Permalink
claude3 examples
Browse files Browse the repository at this point in the history
  • Loading branch information
phact committed Mar 13, 2024
1 parent f3c0dde commit a9f5b1b
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 126 deletions.
5 changes: 4 additions & 1 deletion examples/python/chat_completion/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from streaming_assistants import patch

load_dotenv("./.env")
load_dotenv("../../../.env")

def print_chat_completion(client, model, prompt):
response = client.chat.completions.create(
Expand Down Expand Up @@ -30,7 +31,9 @@ def print_chat_completion(client, model, prompt):
print(part.choices[0].delta.content, end="")

# Ensure the right environment variables are configured for the model you are using
model="gpt-4-1106-preview"
#model="anthropic/claude-3-opus-20240229"
model="anthropic/claude-3-sonnet-20240229"
#model="gpt-4-1106-preview"
#model="gpt-3.5-turbo"
#model="cohere/command"
#model="perplexity/mixtral-8x7b-instruct"
Expand Down
4 changes: 3 additions & 1 deletion examples/python/function_calling/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
client = patch(OpenAI())

# Ensure the right environment variables are configured for the model you are using
model="gpt-4-1106-preview"
#model="gpt-4-1106-preview"
#model="anthropic/claude-3-opus-20240229"
model="anthropic/claude-3-sonet-20240229"
#model="gpt-3.5-turbo"
#model="cohere/command"
#model="perplexity/mixtral-8x7b-instruct"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from streaming_assistants import patch

load_dotenv("./.env")
load_dotenv("../../../.env")

def run_with_assistant(assistant, client):
print(f"created assistant: {assistant.name}")
Expand Down Expand Up @@ -48,11 +49,10 @@ def run_with_assistant(assistant, client):
run_id=run.id,
)
time.sleep(0.5)
print(f"streaming messages")
print("-->", end="")
response = client.beta.threads.messages.list(thread_id=thread.id, stream=True)
for part in response:
print(f"{part.data[0].content[0].delta.value}", end="")
print(part.data[0].content[0].deta.value, end="")
print("\n")


Expand Down
Loading

0 comments on commit a9f5b1b

Please sign in to comment.