Running an Agent Locally using BOSA Connectors
This example will show you how to create agent with BOSA connector.
Learn more about BOSA Connectors here.
Running The Code
git clone https://github.com/GDP-ADMIN/gen-ai-examples.git
cd gen-ai-examples/examples/custom-tool-and-agent
Set up your OPENAI_API_KEY, BOSA_API_BASE_URL, and BOSA_API_KEY
OPENAI_API_KEY, BOSA_API_BASE_URL, and BOSA_API_KEY
Get your OpenAI API key from https://platform.openai.com/api-keys.
Environment Variable Option
export OPENAI_API_KEY="sk-..." export BOSA_API_BASE_URL="https://api.bosa.id" export BOSA_API_KEY="sk-..."
Environment File (.env) Option
echo 'OPENAI_API_KEY="sk-..."' > .env echo 'BOSA_API_BASE_URL="https://api.bosa.id"' >> .env echo 'BOSA_API_KEY="sk-..."' >> .env
Agent Example using Tool Generator BOSA Connectors
This example will show you how to create agent with BOSA connector tool without creating their own tool. This approach will help you easily integrate and deploy with minimal setup time.
You only need to set the tools in the Agent using bosa_connector_tool_generator.generate_tools()
, after which you can utilize the tools provided by the BOSA Connectors SDK.
Execute the script
python hello_agent_bosa_connector_example.py
With verbose=True
, you will see the agent's thinking process, which may look like this:
> Entering new AgentExecutor chain... Invoking: `bosa_twitter_tool` with `{'username': 'elonmusk'}`
I found the Twitter account for the username "elonmusk". The account details are:
*Name: gorklon rust Username: elonmusk User ID: 44196397
If you have any other questions or need further fell free to ask! > Finished chain. Agent 'BOSAConnectorAgent' completed its task. I've located the Twitter account for the user "elonmusk". Here are the details:
Name: gorklon rust
Username: elonmusk
User ID: 44196397
If you have any other questions or need further details, feel free to ask!
The key indicators of success:
The agent initialization completes without errors
The verbose output shows the tool being invoked
The final output shows the user detail of twitter
elonmusk
Agent Using BOSA Connectors SDK
This is an example of how to run an agent that leverages BOSA Connectors locally using own tools that using BOSA Connector SDK. This will help you to tailor tools to meet specific requirements or advanced functionalities from extending BOSA Connectors SDK functionality.
Tool Example Code
This is the example tool that we use:ool Generator
as you can see from this tool code example, we implement our own tool and implement BOSA connector SDK to connect. The advantage using this you can tailor tools to meet specific requirements or advanced functionalities & develop unique processes that match your application’s needs.
Execute the script
python hello_agent_bosa_twitter_example.py
With verbose=True
, you will see the agent's thinking process, which may look like this:
> Entering new AgentExecutor chain... Invoking: `bosa_twitter_tool` with `{'username': 'elonmusk'}`
I found the Twitter account for the username "elonmusk". The account details are:
*Name: gorklon rust Username: elonmusk User ID: 44196397
If you have any other questions or need further fell free to ask! > Finished chain. Agent 'BOSAConnectorTwitterAgent' completed its task. I've located the Twitter account for the user "elonmusk". Here are the details:
Name: gorklon rust
Username: elonmusk
User ID: 44196397
If you have any other questions or need further details, feel free to ask!
The key indicators of success:
The agent initialization completes without errors
The verbose output shows the tool being invoked
The final output shows the user detail of twitter
elonmusk
Last updated