-
Notifications
You must be signed in to change notification settings - Fork 1
update models suffix endpoint for azure deployed model, updated payload for bedrock llm call #180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
| ) | ||
| return response.to_json() | ||
|
|
||
|
|
@@ -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 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| messages=messages, | ||
| stream=True, | ||
| ) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| "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" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| } | ||
| ], | ||
| } | ||
| ), | ||
| 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", | ||
|
|
@@ -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. | ||
|
|
@@ -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", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| "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" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| } | ||
| ], | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a comment explaining why 'gpt35' is being used here. Is this a specific deployment name or a general model ID?