ai.agent
Module ai.agent
API
Declarations
Definitions
nadheeshjihan/ai.agent
Functions
extractToolsFromOpenApiSpec
function extractToolsFromOpenApiSpec(string filePath, *AdditionInfoFlags additionInfoFlags) returns HttpApiSpecification & readonly|error
Classes
ai.agent: Agent
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)... -
getExecutor
function getExecutor(string query, string|map<json> context) returns AgentExecutor
Initialize the agent executor for a given query. Agent executor is useful for streaming-like execution of the agent
Parameters
- query string - User's query
Return Type
- AgentExecutor - AgentExecutor instance
getIterator
function getIterator(string query, string|map<json> context) returns AgentIterator
Initialize the agent iterator for a given query. Agent executor is useful for foreach execution of the agent
Parameters
- query string - User's query
Return Type
- AgentIterator - AgentIterator instance
run
function run(string query, int maxIter, string|map<json> context, boolean verbose) returns ExecutionStep[]
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
- ExecutionStep[] - Returns error, in case of a failure
ai.agent: AgentExecutor
next
function next() returns record {| value ExecutionStep |}?
ai.agent: AgentIterator
iterator
function iterator() returns object {
public function next() returns record {|ExecutionStep value;|}?;
}
ai.agent: AzureGpt3Model
generate
function generate(PromptConstruct prompt) returns string|error
Method included from *LlmModel
complete
ai.agent: ChatGptModel
generate
function generate(PromptConstruct prompt) returns string|error
Method included from *LlmModel
chatComplete
function chatComplete(ChatCompletionRequestMessage[] messages, string? stop) returns string|error
ai.agent: Gpt3Model
generate
function generate(PromptConstruct prompt) returns string|error
Method included from *LlmModel
complete
ai.agent: HttpServiceToolKit
getTools
Method included from *BaseToolKit
Enums
ai.agent: HttpMethod
Members
ai.agent: InputType
Members
Records
ai.agent: AdditionInfoFlags
Fields
- extractDescrition boolean(default false) -
- extractDefault boolean(default false) -
ai.agent: AllOfInputSchema
Fields
- allOf JsonSubSchema[] -
ai.agent: AnyOfInputSchema
Fields
- anyOf JsonSubSchema[] -
ai.agent: ArrayInputSchema
Fields
- Fields Included from *BaseInputTypeSchema
- 'type ARRAY(default ARRAY) -
- items JsonSubSchema -
- default json[]? -
ai.agent: AzureGpt3ModelConfig
Fields
- model string(default GPT3_MODEL_NAME) -
- temperature decimal(default DEFAULT_TEMPERATURE) -
- max_tokens int(default DEFAULT_MAX_TOKEN_COUNT) -
- stop never? -
- prompt never? -
ai.agent: BaseInputTypeSchema
Fields
- 'type InputType -
- description string? -
- default json? -
ai.agent: ChatGptModelConfig
Fields
- model string(default GPT3_5_MODEL_NAME) -
- temperature decimal(default DEFAULT_TEMPERATURE) -
- messages never? -
- stop never? -
ai.agent: ConstantValueSchema
Fields
- 'const json -
ai.agent: ExecutionStep
Fields
- thought string -
- observation any|error? -
ai.agent: Gpt3ModelConfig
Fields
- model string(default GPT3_MODEL_NAME) -
- temperature decimal(default DEFAULT_TEMPERATURE) -
- max_tokens int(default DEFAULT_MAX_TOKEN_COUNT) -
- stop never? -
- prompt never? -
ai.agent: HttpApiSpecification
Fields
- serviceUrl string? -
- tools HttpTool[] -
ai.agent: HttpHeader
Fields
ai.agent: HttpTool
Fields
- name string -
- description string -
- method HttpMethod -
- path string -
- queryParams InputSchema? -
- pathParams InputSchema? -
- requestBody InputSchema? -
ai.agent: NotInputSchema
Fields
- not JsonSubSchema -
ai.agent: ObjectInputSchema
Fields
- Fields Included from *BaseInputTypeSchema
- 'type OBJECT(default OBJECT) -
- required string[]? -
- properties map<JsonSubSchema> -
ai.agent: OneOfInputSchema
Fields
- oneOf JsonSubSchema[] -
ai.agent: PrimitiveInputSchema
Fields
- Fields Included from *BaseInputTypeSchema
- format string? -
- pattern string? -
- 'enum string[]? -
ai.agent: PromptConstruct
Fields
- instruction string -
- query string -
- history ExecutionStep[] -
ai.agent: SimpleInputSchema
Fields
- 'type never? -
- string|SimpleInputSchema|SimpleInputSchema[]... - Rest field
ai.agent: Tool
Fields
- name string -
- description string -
- inputSchema InputSchema?(default ()) -
- caller
function() ()
-
Object types
ai.agent: BaseToolKit
allows implmenting custom toolkits by extending this type
ai.agent: LlmModel
Extendable LLM model object that can be used for completion tasks Useful to initialize the agents
Union types
ai.agent: InputSchema
InputSchema
ai.agent: JsonInputSchema
JsonInputSchema
ai.agent: JsonSubSchema
JsonSubSchema
Import
import nadheeshjihan/ai.agent;
Metadata
Released date: over 1 year ago
Version: 0.1.0
Compatibility
Platform: any
Ballerina version: 2201.5.0
GraalVM compatible: Yes
Pull count
Total: 23
Current verison: 1
Weekly downloads