Running a Custom Tool and Agent Locally

This is an example of how to run a custom tool and agent locally, independent of GLChat.

Prerequisites

This example specifically requires:

Installation

# you can use a Conda environment
pip install gllm-agents-binary

Running The Code

All the code used in the following examples can be found in our GitHub repository gen-ai-examples/custom-tool-and-agent.

This example uses hello_tool.py for the tool definition and hello_agent_example.py to run the agent.

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

Get your OpenAI API key from https://platform.openai.com/api-keys.

export OPENAI_API_KEY="sk-..."

Execute the script

python hello_agent_example.py

With verbose=True, you will see the agent's thinking process, which may look like this:

> Entering new AgentExecutor chain... Invoking: `simple_hello_tool` with `{'name': 'World'}` Hello, World! > Finished chain. Hello, World!

The key indicators of success:

  • The agent initialization completes without errors

  • The verbose output shows the tool being invoked

  • The final output includes the greeting "Hello, World!"

Troubleshooting

For common issues and their solutions, please refer to the centralized FAQ document.

Last updated