How to call AI agent with python code?

Hello, everybody.
I have already built a visual agent.
I want to build a Dash webapp "calling" that visual agent.
I saw this tutorial, but here tools are in a utils.py file. But I have created my tools as plugins (like mentioned here). I used these tools creating a visual agent.
Is it possible to call my visual agent in a dash webapp?
Thank you.
Operating system used: Ubuntu 22.04
Answers
-
Hello @rafael_rosado97
An agent in Dataiku is callable with our Python API like any other LLM. So, a very simple snippet would look like the following:
import dataiku AGENT_ID = "agent:XXXXXXXX" agent = dataiku.api_client().get_default_project().get_llm(AGENT_ID) # Create and run a completion query completion = agent.new_completion() completion.with_message( "any message", role="user") response = completion.execute()
More information can be found in the Developer Guide here. In the tutorial you are linking, the
utils.py
file contains acreate_chat_session
method that uses our API in the same way.In order to get the correct
AGENT_ID
, you need to replace theXXXXXXXX
with the 8 characters you'll see in the URL of your visual agent (something likesavedmodels/9jkCUzAk/…
). Another way is to use thelist_llms()
method.We will try to make it clearer that agents can be used like any LLM with our API.
Hope this helps !