Skip to content

Commit

Permalink
Address comments first batch
Browse files Browse the repository at this point in the history
  • Loading branch information
TaoChenOSU committed Jan 29, 2025
1 parent 3ed873b commit 439dc62
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ pandas = [
"pandas ~= 2.2"
]
aws = [
"boto3>=1.36.4",
"boto3~=1.36.4",
]
dapr = [
"dapr>=1.14.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
AGENT_NAME = "semantic-kernel-bedrock-agent-simple-chat-sample"

# If creating a new agent, you need to specify the following:
INSTRUCTION = "You are a fridenly assistant. You help people find information."
INSTRUCTION = "You are a friendly assistant. You help people find information."

# If using an existing agent, you need to specify the following:
AGENT_ID = ""
Expand All @@ -34,7 +34,7 @@ async def main():
else:
bedrock_agent = await use_existing_agent(AGENT_ID, AGENT_NAME)

# Use an uiud as the session id
# Use a uiud as the session id
new_session_id = str(uuid.uuid4())

# Invoke the agent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
AGENT_NAME = "semantic-kernel-bedrock-agent-simple-chat-code-interpreter-sample"

# If creating a new agent, you need to specify the following:
INSTRUCTION = "You are a fridenly assistant. You help people find information."
INSTRUCTION = "You are a friendly assistant. You help people find information."

# If using an existing agent, you need to specify the following:
AGENT_ID = ""
Expand All @@ -51,7 +51,7 @@ async def main():
else:
bedrock_agent = await use_existing_agent(AGENT_ID, AGENT_NAME)

# Use an uiud as the session id
# Use a uiud as the session id
new_session_id = str(uuid.uuid4())

# Placeholder for the file generated by the code interpreter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
AGENT_NAME = "semantic-kernel-bedrock-agent-simple-chat-kernel-function-sample"

# If creating a new agent, you need to specify the following:
INSTRUCTION = "You are a fridenly assistant. You help people find information."
INSTRUCTION = "You are a friendly assistant. You help people find information."

# If using an existing agent, you need to specify the following:
AGENT_ID = ""
Expand Down Expand Up @@ -64,7 +64,7 @@ async def main():
else:
bedrock_agent = await use_existing_agent(AGENT_ID, AGENT_NAME, kernel=kernel)

# Use an uiud as the session id
# Use a uiud as the session id
new_session_id = str(uuid.uuid4())

# Invoke the agent
Expand Down
2 changes: 1 addition & 1 deletion python/semantic_kernel/agents/bedrock/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Overview

AWS Bedrock Agents is a managed service that allows users to stand up and run AI agents in the cloud quickly.
AWS Bedrock Agents is a managed service that allows users to stand up and run AI agents in the AWS cloud quickly.

## Tools/Functions

Expand Down
7 changes: 4 additions & 3 deletions python/semantic_kernel/agents/bedrock/bedrock_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,13 @@ async def invoke_stream(
full_message: StreamingChatMessageContent = reduce(lambda x, y: x + y, all_function_call_messages)
function_calls = [item for item in full_message.items if isinstance(item, FunctionCallContent)]

chat_history = ChatHistory()
# Create a temporary chat history to store the function call results.
temp_chat_history = ChatHistory()
await asyncio.gather(
*[
self.kernel.invoke_function_call(
function_call=function_call,
chat_history=chat_history,
chat_history=temp_chat_history,
function_call_count=len(function_calls),
request_index=request_index,
)
Expand All @@ -265,7 +266,7 @@ async def invoke_stream(
)
function_result_contents = [
item
for chat_message in chat_history.messages
for chat_message in temp_chat_history.messages
for item in chat_message.items
if isinstance(item, FunctionResultContent)
]
Expand Down
3 changes: 2 additions & 1 deletion python/semantic_kernel/agents/bedrock/bedrock_agent_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import asyncio
import logging
from collections.abc import Callable
from functools import partial
from typing import Any, ClassVar

Expand Down Expand Up @@ -74,7 +75,7 @@ def validate_function_choice_behavior(
raise ValueError("Only FunctionChoiceType.AUTO is supported.")
return function_choice_behavior

async def _run_in_executor(self, executor, func, *args, **kwargs) -> Any:
async def _run_in_executor(self, executor: Any, func: Callable, *args, **kwargs) -> Any:
"""Run a function in an executor."""
return await asyncio.get_event_loop().run_in_executor(executor, partial(func, *args, **kwargs))

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# Copyright (c) Microsoft. All rights reserved.


from enum import StrEnum
from enum import Enum

from semantic_kernel.utils.experimental_decorator import experimental_class


@experimental_class
class BedrockAgentEventType(StrEnum):
class BedrockAgentEventType(str, Enum):
"""Bedrock Agent Event Type."""

# Contains the text response from the agent.
Expand Down
2 changes: 1 addition & 1 deletion python/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 439dc62

Please sign in to comment.