LLM API Reference
This page summarises the modules, agent classes, goals, beliefs and events described in this section. For implementation details, see the astra-langchain4j and astra-langchain4j-tools source.
astra-langchain4j
LLMModel
astra.langchain4j.LLMModel connects to a model. Its actions fail if the operation cannot be completed.
Operation |
Purpose |
|---|---|
|
Load the API key from an environment variable |
|
Load the API key from the first line of a file |
|
Set the API key directly |
|
Create the model, using a configuration class and optional parameters such as |
|
Send text and bind the reply |
|
Render a template and send it. Fails if a placeholder is unbound |
Templater
astra.langchain4j.Templater builds prompts and extracts values from replies. See Prompts, responses and beliefs.
Operation |
Purpose |
|---|---|
|
Create a |
|
Bind a placeholder |
|
Clear the bindings for reuse |
|
Render a template as text |
|
Create a |
|
Match a reply against a response template. Fails if it does not match |
|
Read a value extracted by |
|
Combine templates into one prompt |
BelRAG
astra.langchain4j.BelRAG builds prompt text from beliefs. In 2.3.0, its input bindings are not substituted.
Operation |
Purpose |
|---|---|
|
Create a |
|
Add a sentence template for each belief matching a query |
Agent classes
Class |
Purpose |
|---|---|
|
Declares |
|
Extend |
Reasoning agents
The classes in astra.langchain4j.reasoning extend LLMAgent. See The reasoning architecture.
Class |
Goal |
Beliefs it reads |
|---|---|---|
|
|
— |
|
|
— |
|
|
|
|
|
|
|
|
As |
|
|
|
|
|
— |
|
|
|
In each goal, the inputs are bound when the goal is adopted, and the final argument is bound when it completes. parts is a list of strings.
astra-langchain4j-tools
A2A
astra.langchain4j.tools.a2a.A2A declares services, handles requests and calls other agents. See Agent-to-Agent communication.
Service declarations, made by the instance that receives !main(["describe"]):
Operation |
Purpose |
|---|---|
|
Set the AgentCard’s details. The content-type lists must not be empty |
|
Declare a skill handled by this class. The lists must not be empty |
|
Publish the card, naming the default skill |
|
Report that the declarations could not be made |
Request handling, by the worker that receives !main([id, contextId, skill, payload]):
Operation |
Purpose |
|---|---|
|
Deliver the request as a |
|
Report progress on the task |
|
Complete the task with a JSON object result |
|
Fail the task with a reason |
|
Formula: true while the task is pending and within its deadline |
Calling other agents:
Operation |
Purpose |
|---|---|
|
Send a JSON object to a skill of the agent at |
|
Send to the agent’s default skill |
|
Term: the |
Events, named after the module ($a2a for module ... A2A a2a;):
Event |
Meaning |
|---|---|
|
A request for this worker to handle |
|
A call completed with a JSON result |
|
A call failed |
|
A called agent reported progress |
Service configuration properties, in application.properties:
Property |
Purpose |
|---|---|
|
The ASTRA class that implements the service |
|
The URL advertised in the AgentCard |
JSONConverter
astra.langchain4j.tools.JSONConverter reads and builds JSON. Paths are JSON Pointers, such as /items/0/name; bracket paths such as /items[0]/name are also accepted. Each reading operation accepts either a JSON string or a JsonNode.
Operation |
Purpose |
|---|---|
|
Term: parse a string into a |
|
Term: the node at a path |
|
Formulae: test a path |
|
Terms: read a typed value. Fail if the value is missing, null or of another type |
|
Term: the length of an array |
|
Term: the field names of an object, as a list |
|
Formula: test a value |
|
Term: an empty object |
|
Term: a copy of an object with one field added or replaced. The value can be a string, number, boolean or |
|
Term: the node as a JSON string |
ASTRA code that declares JsonNode variables imports com.fasterxml.jackson.databind.JsonNode.
Inspector
astra.langchain4j.tools.a2a.Inspector launches a prepared checkout of the A2A Inspector.
Operation |
Purpose |
|---|---|
|
Start the Inspector, waiting up to 30 seconds for it to be ready |
|
Stop the Inspector started by this module |
|
Block until the Inspector exits |
|
Formula: true while the Inspector is running |
|
Term: the Inspector’s URL |
|
Terms: the |