SQLAgent#
- class lumen.ai.agents.SQLAgent(*, debug, interface, steps_layout, user, llm, memory, prompts, template_overrides, purpose, name)#
Methods#
- async SQLAgent.find_join_tables(messages: list[Message])#
- async SQLAgent.requirements(messages: list[Message]) list[str] #
- async SQLAgent.respond(messages: list[Message], render_output: bool = False, step_title: str | None = None) Any #
Steps: 1. Retrieve the current source and table from memory. 2. If the source lacks a get_sql_expr method, return None. 3. Fetch the schema for the current table using get_schema without min/max values. 4. Determine if a join is required by calling _check_requires_joins. 5. If required, find additional tables via find_join_tables; otherwise, use the current source and table. 6. For each source and table, get the schema and SQL expression, storing them in table_schemas. 7. Render the SQL prompt using the table schemas, dialect, join status, and table. 8. If a join is required, remove source/table prefixes from the last message. 9. Construct the SQL query with _create_valid_sql.
- SQLAgent.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
- SQLAgent.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