Agent#

class lumen.ai.agents.Agent(*, debug, interface, steps_layout, user, llm, memory, prompts, template_overrides, purpose, name)#

Agents are actors responsible for taking a user query and performing a particular task and responding by adding context to the current memory and creating outputs.

Each Agent can require certain context that is needed to perform the task and should declare any context it itself provides.

Agents have access to an LLM and the current memory and can solve tasks by executing a series of prompts or by rendering contents such as forms or widgets to gather user input.


Parameters#

debug

type: bool
default: False
Whether to enable verbose error reporting.

interface

type: panel.chat.ChatInterface
default: None
The ChatInterface to report progress to.

llm

type: lumen.ai.llm.Llm
default: None
The LLM implementation to query.

memory

type: lumen.ai.memory._Memory
default: None
Local memory which will be used to provide the agent context.If None the global memory will be used.

name

type: str
default: 'Agent'
String identifier for this object.

prompts

type: dict
default: {}
A dictionary of prompts used by the actor, indexed by prompt name.Each prompt should be defined as a dictionary containing a template’template’ and optionally a ‘model’ and ‘tools’.

provides

type: list
default: []
List of context values it provides to current working memory.

purpose

type: str
default: ''
Describes the purpose of this actor for consumption ofother actors that might invoke it.

requires

type: list
default: []
List of context values it requires to be in memory.

steps_layout

type: panel.Column
default: None
The layout progress updates will be streamed to.

template_overrides

type: dict
default: {}
Overrides the template’s ‘instructions’, ‘context’, ‘tools’, or ‘examples’ jinja2 blocks.Is a nested dictionary with the prompt name (e.g. main) as the keyand the block names as the inner keys with the new content as thevalues.

user

type: str
default: 'Agent'
The name of the user that will be respond to the user query.


Methods#

async Agent.requirements(messages: list[Message]) list[str]#
async Agent.respond(messages: list[Message], render_output: bool = False, step_title: str | None = None) Any#

Provides a response to the user query.

The type of the response may be a simple string or an object.

Parameters:
  • messages (list[Message]) – The list of messages corresponding to the user query and any other system messages to be included.

  • render_output (bool) – Whether to render the output to the chat interface.

  • step_title (str | None) – If the Agent response is part of a longer query this describes the step currently being processed.

Agent.servable(title: str | None = None, location: bool | Location = True, area: str = 'main', target: str | None = None) Viewable#

Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.

Parameters:
  • title (str) – A string title to give the Document (if served as an app)

  • location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.

  • area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.

  • target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.

Return type:

The Panel object itself

Agent.show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | Location = True, **kwargs) threading.Thread | Server#

Starts a Bokeh server and displays the Viewable in a new tab.

Parameters:
  • title (str | None) – A string title to give the Document (if served as an app)

  • port (int (optional, default=0)) – Allows specifying a specific port

  • address (str) – The address the server should listen on for HTTP requests.

  • websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.

  • threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.

  • verbose (boolean (optional, default=True)) – Whether to print the address and port

  • open (boolean (optional, default=True)) – Whether to open the server in a new browser tab

  • location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.

Returns:

server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

Return type:

bokeh.server.Server or panel.io.server.StoppableThread

Types#

SourceAgent

SourceAgent renders a form that allows a user to upload or

SourceAgent.html
ChatAgent

ChatAgent provides general information about available data

ChatAgent.html
TableListAgent

TableListAgent Agent

TableListAgent.html
DocumentListAgent

The DocumentListAgent lists all available documents provided by the user.

DocumentListAgent.html
LumenBaseAgent

LumenBaseAgent Agent

LumenBaseAgent.html
AnalystAgent

AnalystAgent Agent

AnalystAgent.html
SQLAgent

SQLAgent Agent

SQLAgent.html
BaseViewAgent

BaseViewAgent Agent

BaseViewAgent.html
AnalysisAgent

AnalysisAgent Agent

AnalysisAgent.html
hvPlotAgent

hvPlotAgent Agent

hvPlotAgent.html
VegaLiteAgent

VegaLiteAgent Agent

VegaLiteAgent.html