Module
agent
Module agent
API
Declarations
Definitions
nadheeshjihan/agent
0.2.4
Functions
extractToolsFromOpenApiSpec
function extractToolsFromOpenApiSpec(string filePath, *AdditionInfoFlags additionInfoFlags) returns ApiSpecification & readonly|error
Classes
agent: Agent
Isolated
Agent implementation to perform tools with LLMs to add computational power and knowledge to the LLMs
Constructor
Initialize an Agent
init (LlmModel model, (BaseToolKit|Tool)... tools)
- model LlmModel - LLM model instance
- tools (BaseToolKit|Tool)... -
createAgentExecutor
Isolated Function
function createAgentExecutor(string query, string|map<json> context) returns AgentExecutor
iterator
Isolated Function
function iterator(string query, string|map<json> context) returns AgentIterator
run
Isolated Function
function run(string query, int maxIter, string|map<json> context, boolean verbose) returns ExecutorOutput[]
Execute the agent for a given user's query
Parameters
- query string - Natural langauge commands to the agent
- maxIter int (default 5) - No. of max iterations that agent will run to execute the task
- verbose boolean (default true) - If true, then print the reasoning steps
Return Type
- ExecutorOutput[] - Returns error, in case of a failure
agent: AgentExecutor
next
Isolated Function
function next() returns record {| value ExecutorOutput |}?
agent: AgentIterator
iterator
function iterator() returns object {
public function next() returns record {|ExecutorOutput value;|}?;
}
agent: ChatGptModel
Isolated
generate
Isolated Function
function generate(PromptConstruct prompt) returns string|error
Method included from *LlmModel
chatComplete
Isolated Function
function chatComplete(ChatMessage[] messages) returns string|error
Parameters
- messages ChatMessage[] -
Fields
- Fields Included from *LlmModel
- llmClient LlmRemoteClient
agent: Gpt3Model
Isolated
generate
Isolated Function
function generate(PromptConstruct prompt) returns string|error
Method included from *LlmModel
complete
Isolated Function
Parameters
- prompt string -
Fields
- Fields Included from *LlmModel
- llmClient LlmRemoteClient
agent: HttpToolKit
Isolated
getTools
Isolated Function
Method included from *BaseToolKit
Enums
agent: ComplexInputType
Members
OBJECT
ARRAY
agent: HttpMethod
Members
GET
POST
DELETE
PUT
PATCH
HEAD
OPTIONS
agent: PrimitiveInputType
Members
STRING
INTEGER
FLOAT
BOOLEAN
NUMBER
Records
agent: AdditionInfoFlags
Closed record
Fields
- extractDescrition boolean(default false) -
- extractDefault boolean(default false) -
agent: AllOfInputSchema
Closed record
Fields
- allOf JsonSubSchema[] -
agent: AnyOfInputSchema
Closed record
Fields
- anyOf JsonSubSchema[] -
agent: ApiSpecification
Closed record
Fields
- serverUrl string? -
- tools HttpTool[] -
agent: ArrayInputSchema
Closed record
Fields
- 'type ARRAY(default ARRAY) -
- items JsonSubSchema -
agent: ChatGptModelConfig
Read OnlyClosed record
Fields
- model string(default GPT3_5_MODEL_NAME) -
- temperature decimal(default DEFAULT_TEMPERATURE) -
- messages never? -
- stop never? -
agent: ExecutorOutput
Closed record
Fields
- thought string -
- observation any|error? -
agent: Gpt3ModelConfig
Read OnlyClosed record
Fields
- model string(default GPT3_MODEL_NAME) -
- temperature decimal(default DEFAULT_TEMPERATURE) -
- max_tokens int(default DEFAULT_MAX_TOKEN_COUNT) -
- stop never? -
- prompt never? -
agent: HttpHeader
Read Only
Fields
agent: HttpTool
Closed record
Fields
- name string -
- description string -
- method HttpMethod -
- path string -
- queryParams InputSchema?(default ()) -
- requestBody InputSchema?(default ()) -
agent: NotInputSchema
Closed record
Fields
- not JsonSubSchema -
agent: ObjectInputSchema
Closed record
Fields
- 'type OBJECT(default OBJECT) -
- required string[]? -
- properties map<JsonSubSchema> -
agent: OneOfInputSchema
Closed record
Fields
- oneOf JsonSubSchema[] -
agent: PrimitiveInputSchema
Closed record
Fields
- 'type PrimitiveInputType -
- format string? -
- pattern string? -
- description string? -
- default anydata? -
- 'enum string[]? -
agent: PromptConstruct
Closed record
Fields
- instruction string -
- query string -
- history string[] -
agent: SimpleInputSchema
Fields
- 'type never? -
- string|SimpleInputSchema|SimpleInputSchema[]... - Rest field
agent: Tool
Closed record
Fields
- name string -
- description string -
- inputSchema InputSchema?(default ()) -
- caller
function() ()
-
Object types
agent: BaseToolKit
Distinct
allows implmenting custom toolkits by extending this type
agent: LlmModel
Distinct
Extendable LLM model object that can be used for completion tasks Useful to initialize the agents
Union types
agent: InputSchema
InputSchema
agent: JsonInputSchema
JsonInputSchema
agent: JsonSubSchema
JsonSubSchema
Import
import nadheeshjihan/agent;
Metadata
Released date: over 1 year ago
Version: 0.2.4
Compatibility
Platform: any
Ballerina version: 2201.5.0
GraalVM compatible: Yes
Pull count
Total: 66
Current verison: 3
Weekly downloads