Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/azure-openai/azure-universal.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def get_chat_completion_sync(azure_client, messages):
"""

response = azure_client.chat.completions.create(
model="gpt-4", messages=messages # Adjust to your Azure deployment name
model="gpt35", messages=messages # Adjust to your Azure deployment name
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Consider adding a comment explaining why 'gpt35' is being used here. Is this a specific deployment name or a general model ID?

        model="gpt35", messages=messages  # Adjust to your Azure deployment name, using gpt35 model

)
return response.to_json()

Expand All @@ -65,7 +65,7 @@ def get_chat_completion_stream(azure_client, messages):
Returns the concatenated text from the streamed chunks.
"""
response = azure_client.chat.completions.create(
model="gpt-4", # Adjust to your Azure deployment name
model="gpt35", # Adjust to your Azure deployment name
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Same here, consider adding a comment explaining why 'gpt35' is being used here.

        model="gpt35",  # Adjust to your Azure deployment name, using gpt35 model

messages=messages,
stream=True,
)
Expand Down
18 changes: 5 additions & 13 deletions examples/bedrock/bedrock_client_universal.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,32 +68,27 @@ def bedrock_converse_example(bedrock_runtime_client):
{
"anthropic_version": "bedrock-2023-05-31",
"max_tokens": 500,
"system": [
{"type": "text", "text": "You are an economist with access to lots of data"}
],
"system": "You are an economist with access to lots of data",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The 'system' field is now a string instead of a list of dictionaries. Ensure this change is compatible with the Bedrock API and that the system prompt is being correctly interpreted.

                "system": "You are an economist with access to lots of data",

"messages": [
{
"role": "user",
"content": [{"type": "text", "text": "Write an article about the impact of high inflation on a country's GDP"}]
"content": "Write an article about the impact of high inflation on a country's GDP"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The 'content' field is now a string instead of a list of dictionaries. Ensure this change is compatible with the Bedrock API and that the user message is being correctly interpreted.

                        "content": "Write an article about the impact of high inflation on a country's GDP"

}
],
}
),
contentType="application/json",
)

response_body = json.loads(response["body"].read())
return json.dumps(response_body, indent=2)



def bedrock_invoke_stream_example(bedrock_runtime_client):
"""
Demonstrates a streaming 'invoke' call by processing the response tokens as they arrive.
Iterates over the streaming response lines and prints them in real-time.
"""
response = bedrock_runtime_client.invoke_model(
modelId="anthropic.claude-3-5-sonnet-20240620-v1:0", # Example model ID
modelId="anthropic.claude-3-5-sonnet-20240620-v1:0",
body=json.dumps(
{
"anthropic_version": "bedrock-2023-05-31",
Expand All @@ -114,7 +109,6 @@ def bedrock_invoke_stream_example(bedrock_runtime_client):
print("Error streaming invoke response:", e)
return "".join(tokens)


def bedrock_converse_stream_example(bedrock_runtime_client):
"""
Demonstrates a streaming 'converse' call by processing the response tokens as they arrive.
Expand All @@ -126,13 +120,11 @@ def bedrock_converse_stream_example(bedrock_runtime_client):
{
"anthropic_version": "bedrock-2023-05-31",
"max_tokens": 500,
"system": [
{"type": "text", "text": "You are an economist with access to lots of data"}
],
"system": "You are an economist with access to lots of data",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The 'system' field is now a string instead of a list of dictionaries. Ensure this change is compatible with the Bedrock API and that the system prompt is being correctly interpreted.

                "system": "You are an economist with access to lots of data",

"messages": [
{
"role": "user",
"content": [{"type": "text", "text": "Write an article about the impact of high inflation on a country's GDP"}]
"content": "Write an article about the impact of high inflation on a country's GDP"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The 'content' field is now a string instead of a list of dictionaries. Ensure this change is compatible with the Bedrock API and that the user message is being correctly interpreted.

                        "content": "Write an article about the impact of high inflation on a country's GDP"

}
],
}
Expand Down
Loading