Skip to content
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

PR to solicit feedback for simplifying the agent creation process and… #268

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
42 changes: 42 additions & 0 deletions libs/aws/langchain_aws/agents/agent_builder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
'''

The create_agent method of agents/base.py has a large number of parameters. I want
to offer an easier way to create agents without having to enter in
so many parameters or even offer built-in features quicker (confirmations, human-as-a-tool).

Check failure on line 5 in libs/aws/langchain_aws/agents/agent_builder.py

View workflow job for this annotation

GitHub Actions / cd libs/aws / make lint #3.12

Ruff (E501)

langchain_aws/agents/agent_builder.py:5:89: E501 Line too long (92 > 88)

I want to get comments on 2 different possible solutions.

First is the builder pattern which is not as common in Python but still used.

Second is config pattern which is a more common pattern.

'''


# builder

agent = (BedrockAgentBuilder("my-agent", "arn:aws:iam::xyz123:role/agent")

Check failure on line 18 in libs/aws/langchain_aws/agents/agent_builder.py

View workflow job for this annotation

GitHub Actions / cd libs/aws / make lint #3.12

Ruff (F821)

langchain_aws/agents/agent_builder.py:18:10: F821 Undefined name `BedrockAgentBuilder`
.with_tools([tool1, tool2])

Check failure on line 19 in libs/aws/langchain_aws/agents/agent_builder.py

View workflow job for this annotation

GitHub Actions / cd libs/aws / make lint #3.12

Ruff (F821)

langchain_aws/agents/agent_builder.py:19:18: F821 Undefined name `tool1`

Check failure on line 19 in libs/aws/langchain_aws/agents/agent_builder.py

View workflow job for this annotation

GitHub Actions / cd libs/aws / make lint #3.12

Ruff (F821)

langchain_aws/agents/agent_builder.py:19:25: F821 Undefined name `tool2`
.with_instructions("You are a helpful financial agent who answers finance related questions using "

Check failure on line 20 in libs/aws/langchain_aws/agents/agent_builder.py

View workflow job for this annotation

GitHub Actions / cd libs/aws / make lint #3.12

Ruff (E501)

langchain_aws/agents/agent_builder.py:20:89: E501 Line too long (103 > 88)
"the provided tools.")
.with_idle_timeout(3600)
.with_tracing()
.with_human_input()
.with_confirmations()
.build())



# config
agent = create_bedrock_agent(

Check failure on line 31 in libs/aws/langchain_aws/agents/agent_builder.py

View workflow job for this annotation

GitHub Actions / cd libs/aws / make lint #3.12

Ruff (F821)

langchain_aws/agents/agent_builder.py:31:9: F821 Undefined name `create_bedrock_agent`
config=BedrockAgentConfig(

Check failure on line 32 in libs/aws/langchain_aws/agents/agent_builder.py

View workflow job for this annotation

GitHub Actions / cd libs/aws / make lint #3.12

Ruff (F821)

langchain_aws/agents/agent_builder.py:32:12: F821 Undefined name `BedrockAgentConfig`
name="my-agent",
role_arn="arn:aws:iam::123:role/agent",
model="anthropic.claude-3",
instruction="Help users with tasks",
mixins=[HumanInTheLoopMixin, HumanConfirmationMixin, TracingMixin]

Check failure on line 37 in libs/aws/langchain_aws/agents/agent_builder.py

View workflow job for this annotation

GitHub Actions / cd libs/aws / make lint #3.12

Ruff (F821)

langchain_aws/agents/agent_builder.py:37:17: F821 Undefined name `HumanInTheLoopMixin`

Check failure on line 37 in libs/aws/langchain_aws/agents/agent_builder.py

View workflow job for this annotation

GitHub Actions / cd libs/aws / make lint #3.12

Ruff (F821)

langchain_aws/agents/agent_builder.py:37:38: F821 Undefined name `HumanConfirmationMixin`

Check failure on line 37 in libs/aws/langchain_aws/agents/agent_builder.py

View workflow job for this annotation

GitHub Actions / cd libs/aws / make lint #3.12

Ruff (F821)

langchain_aws/agents/agent_builder.py:37:62: F821 Undefined name `TracingMixin`
)
)


##Thoughts on either? Or something else?
Loading