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

Configuring custom bee tools in Chat UI #59

Open
ajshedivy opened this issue Dec 5, 2024 · 1 comment
Open

Configuring custom bee tools in Chat UI #59

ajshedivy opened this issue Dec 5, 2024 · 1 comment

Comments

@ajshedivy
Copy link

ajshedivy commented Dec 5, 2024

I created a Db2 for i Bee agent using the Bee agent template and it works great! The core logic comes from the custom "IBMiTool" that leverages a new database access layer for Db2 for i called Mapepire.

IBM i agent: https://github.com/ajshedivy/bee-agent-ibmi

Here is my main question: is it possible to use custom Bee Tools like the one I created for Db2i within the chat UI? Is this already possible through the API?

On another note, Anthropic recently released MCP for connecting data sources with AI assistants, are there plans to explore this for Bee?

@ajshedivy
Copy link
Author

My workaround at the moment is to create a simple webserver on IBM i that can talk to Db2 that accepts requests like:

curl -X POST http://HOST:PORT/api/execute-sql \
     -H "Content-Type: application/json" \
     -d '{"sql": "SELECT * FROM sample.employee"}'

This will return the result set from the given SQL. The API is very similar to my "IBMiTool" used in the IBM i agent I mentioned above.

I can then create a "proxy tool" for Bee that sends requests to this endpoint:

import requests

def send_sql_query(sql_query) -> dict:
    """
    Sends a SQL statement to the Flask server and returns the result.

    Args:
        sql_query (str): The SQL statement to execute.

    Returns:
        dict: The server's response as a dictionary.
    """
    url = "http://HOST:PORT/api/execute-sql"  # Server endpoint
    headers = {"Content-Type": "application/json"}
    payload = {"sql": sql_query}

    try:
        response = requests.post(url, json=payload, headers=headers)
        response.raise_for_status() 
        return response.json()     
    except requests.exceptions.RequestException as e:
        return {"error": str(e)}

I created a bee agent for Db2 for i with access to this tool which works surprising well for toy examples:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant