Skip to content

Latest commit

 

History

History
1011 lines (507 loc) · 23.1 KB

AgentRuntime.md

File metadata and controls

1011 lines (507 loc) · 23.1 KB

@elizaos/core v0.25.8 / AgentRuntime

Class: AgentRuntime

Implements

Constructors

new AgentRuntime()

new AgentRuntime(opts): AgentRuntime

Creates an instance of AgentRuntime.

Parameters

opts

The options for configuring the AgentRuntime.

opts.conversationLength?: number

The number of messages to hold in the recent message cache.

opts.agentId?: `${string}-${string}-${string}-${string}-${string}`

Optional ID of the agent.

opts.character?: Character

opts.token: string

The JWT token, can be a JWT token if outside worker, or an OpenAI token if inside worker.

opts.serverUrl?: string

The URL of the worker.

opts.actions?: Action[]

Optional custom actions.

opts.evaluators?: Evaluator[]

Optional custom evaluators.

opts.plugins?: Plugin[]

opts.providers?: Provider[]

Optional context providers.

opts.modelProvider: ModelProviderName

opts.services?: Service[]

Optional custom services.

opts.managers?: IMemoryManager[]

opts.databaseAdapter?: IDatabaseAdapter

The database adapter used for interacting with the database.

opts.fetch?: unknown

Custom fetch function to use for making requests.

opts.speechModelPath?: string

opts.cacheManager?: ICacheManager

opts.logging?: boolean

Returns

AgentRuntime

Defined in

packages/core/src/runtime.ts:245

Properties

agentId

agentId: `${string}-${string}-${string}-${string}-${string}`

The ID of the agent

Implementation of

IAgentRuntime.agentId

Defined in

packages/core/src/runtime.ts:83


serverUrl

serverUrl: string = "http://localhost:7998"

The base URL of the server where the agent's requests are processed.

Implementation of

IAgentRuntime.serverUrl

Defined in

packages/core/src/runtime.ts:87


databaseAdapter

databaseAdapter: IDatabaseAdapter

The database adapter used for interacting with the database.

Implementation of

IAgentRuntime.databaseAdapter

Defined in

packages/core/src/runtime.ts:92


token

token: string

Authentication token used for securing requests.

Implementation of

IAgentRuntime.token

Defined in

packages/core/src/runtime.ts:97


actions

actions: Action[] = []

Custom actions that the agent can perform.

Implementation of

IAgentRuntime.actions

Defined in

packages/core/src/runtime.ts:102


evaluators

evaluators: Evaluator[] = []

Evaluators used to assess and guide the agent's responses.

Implementation of

IAgentRuntime.evaluators

Defined in

packages/core/src/runtime.ts:107


providers

providers: Provider[] = []

Context providers used to provide context for message generation.

Implementation of

IAgentRuntime.providers

Defined in

packages/core/src/runtime.ts:112


adapters

adapters: Adapter[] = []

Database adapters used to interact with the database.

Defined in

packages/core/src/runtime.ts:117


plugins

plugins: Plugin[] = []

Implementation of

IAgentRuntime.plugins

Defined in

packages/core/src/runtime.ts:119


modelProvider

modelProvider: ModelProviderName

The model to use for generateText.

Implementation of

IAgentRuntime.modelProvider

Defined in

packages/core/src/runtime.ts:124


imageModelProvider

imageModelProvider: ModelProviderName

The model to use for generateImage.

Implementation of

IAgentRuntime.imageModelProvider

Defined in

packages/core/src/runtime.ts:129


imageVisionModelProvider

imageVisionModelProvider: ModelProviderName

The model to use for describing images.

Implementation of

IAgentRuntime.imageVisionModelProvider

Defined in

packages/core/src/runtime.ts:134


fetch()

fetch: (input, init?) => Promise<Response>(input, init?) => Promise<Response>

Fetch function to use Some environments may not have access to the global fetch function and need a custom fetch override.

MDN Reference

Parameters

input: RequestInfo | URL

init?: RequestInit

Returns

Promise<Response>

Parameters

input: string | Request | URL

init?: RequestInit

Returns

Promise<Response>

Implementation of

IAgentRuntime.fetch

Defined in

packages/core/src/runtime.ts:140


character

character: Character

The character to use for the agent

Implementation of

IAgentRuntime.character

Defined in

packages/core/src/runtime.ts:145


messageManager

messageManager: IMemoryManager

Store messages that are sent and received by the agent.

Implementation of

IAgentRuntime.messageManager

Defined in

packages/core/src/runtime.ts:150


descriptionManager

descriptionManager: IMemoryManager

Store and recall descriptions of users based on conversations.

Implementation of

IAgentRuntime.descriptionManager

Defined in

packages/core/src/runtime.ts:155


loreManager

loreManager: IMemoryManager

Manage the creation and recall of static information (documents, historical game lore, etc)

Implementation of

IAgentRuntime.loreManager

Defined in

packages/core/src/runtime.ts:160


documentsManager

documentsManager: IMemoryManager

Hold large documents that can be referenced

Implementation of

IAgentRuntime.documentsManager

Defined in

packages/core/src/runtime.ts:165


knowledgeManager

knowledgeManager: IMemoryManager

Searchable document fragments

Implementation of

IAgentRuntime.knowledgeManager

Defined in

packages/core/src/runtime.ts:170


ragKnowledgeManager

ragKnowledgeManager: IRAGKnowledgeManager

Implementation of

IAgentRuntime.ragKnowledgeManager

Defined in

packages/core/src/runtime.ts:172


services

services: Map<ServiceType, Service>

Implementation of

IAgentRuntime.services

Defined in

packages/core/src/runtime.ts:176


memoryManagers

memoryManagers: Map<string, IMemoryManager>

Defined in

packages/core/src/runtime.ts:177


cacheManager

cacheManager: ICacheManager

Implementation of

IAgentRuntime.cacheManager

Defined in

packages/core/src/runtime.ts:178


clients

clients: ClientInstance[] = []

Implementation of

IAgentRuntime.clients

Defined in

packages/core/src/runtime.ts:179

Methods

registerMemoryManager()

registerMemoryManager(manager): void

verifiableInferenceAdapter?: IVerifiableInferenceAdapter;

Parameters

manager: IMemoryManager

Returns

void

Implementation of

IAgentRuntime.registerMemoryManager

Defined in

packages/core/src/runtime.ts:183


getMemoryManager()

getMemoryManager(tableName): IMemoryManager

Parameters

tableName: string

Returns

IMemoryManager

Implementation of

IAgentRuntime.getMemoryManager

Defined in

packages/core/src/runtime.ts:198


getService()

getService<T>(service): T

Type Parameters

T extends Service

Parameters

service: ServiceType

Returns

T

Implementation of

IAgentRuntime.getService

Defined in

packages/core/src/runtime.ts:202


registerService()

registerService(service): Promise<void>

Parameters

service: Service

Returns

Promise<void>

Implementation of

IAgentRuntime.registerService

Defined in

packages/core/src/runtime.ts:211


initialize()

initialize(): Promise<void>

verifiableInferenceAdapter?: IVerifiableInferenceAdapter | null;

Returns

Promise<void>

Implementation of

IAgentRuntime.initialize

Defined in

packages/core/src/runtime.ts:459


stop()

stop(): Promise<void>

Returns

Promise<void>

Defined in

packages/core/src/runtime.ts:580


getSetting()

getSetting(key): any

Parameters

key: string

Returns

any

Implementation of

IAgentRuntime.getSetting

Defined in

packages/core/src/runtime.ts:945


getConversationLength()

getConversationLength(): number

Get the number of messages that are kept in the conversation buffer.

Returns

number

The number of recent messages to be kept in memory.

Implementation of

IAgentRuntime.getConversationLength

Defined in

packages/core/src/runtime.ts:967


registerAction()

registerAction(action): void

Register an action for the agent to perform.

Parameters

action: Action

The action to register.

Returns

void

Implementation of

IAgentRuntime.registerAction

Defined in

packages/core/src/runtime.ts:975


registerEvaluator()

registerEvaluator(evaluator): void

Register an evaluator to assess and guide the agent's responses.

Parameters

evaluator: Evaluator

The evaluator to register.

Returns

void

Defined in

packages/core/src/runtime.ts:984


registerContextProvider()

registerContextProvider(provider): void

Register a context provider to provide context for message generation.

Parameters

provider: Provider

The context provider to register.

Returns

void

Defined in

packages/core/src/runtime.ts:992


registerAdapter()

registerAdapter(adapter): void

Register an adapter for the agent to use.

Parameters

adapter: Adapter

The adapter to register.

Returns

void

Defined in

packages/core/src/runtime.ts:1000


processActions()

processActions(message, responses, state?, callback?): Promise<void>

Process the actions of a message.

Parameters

message: Memory

The message to process.

responses: Memory[]

state?: State

callback?: HandlerCallback

Returns

Promise<void>

Implementation of

IAgentRuntime.processActions

Defined in

packages/core/src/runtime.ts:1009


evaluate()

evaluate(message, state, didRespond?, callback?): Promise<string[]>

Evaluate the message and state using the registered evaluators.

Parameters

message: Memory

The message to evaluate.

state: State

The state of the agent.

didRespond?: boolean

Whether the agent responded to the message.~

callback?: HandlerCallback

The handler callback

Returns

Promise<string[]>

The results of the evaluation.

Implementation of

IAgentRuntime.evaluate

Defined in

packages/core/src/runtime.ts:1093


ensureParticipantExists()

ensureParticipantExists(userId, roomId): Promise<void>

Ensure the existence of a participant in the room. If the participant does not exist, they are added to the room.

Parameters

userId: `${string}-${string}-${string}-${string}-${string}`

The user ID to ensure the existence of.

roomId: `${string}-${string}-${string}-${string}-${string}`

Returns

Promise<void>

Throws

An error if the participant cannot be added.

Implementation of

IAgentRuntime.ensureParticipantExists

Defined in

packages/core/src/runtime.ts:1163


ensureUserExists()

ensureUserExists(userId, userName, name, email?, source?): Promise<void>

Ensure the existence of a user in the database. If the user does not exist, they are added to the database.

Parameters

userId: `${string}-${string}-${string}-${string}-${string}`

The user ID to ensure the existence of.

userName: string

The user name to ensure the existence of.

name: string

email?: string

source?: string

Returns

Promise<void>

Implementation of

IAgentRuntime.ensureUserExists

Defined in

packages/core/src/runtime.ts:1179


ensureParticipantInRoom()

ensureParticipantInRoom(userId, roomId): Promise<void>

Parameters

userId: `${string}-${string}-${string}-${string}-${string}`

roomId: `${string}-${string}-${string}-${string}-${string}`

Returns

Promise<void>

Implementation of

IAgentRuntime.ensureParticipantInRoom

Defined in

packages/core/src/runtime.ts:1205


ensureConnection()

ensureConnection(userId, roomId, userName?, userScreenName?, source?): Promise<void>

Parameters

userId: `${string}-${string}-${string}-${string}-${string}`

roomId: `${string}-${string}-${string}-${string}-${string}`

userName?: string

userScreenName?: string

source?: string

Returns

Promise<void>

Implementation of

IAgentRuntime.ensureConnection

Defined in

packages/core/src/runtime.ts:1222


ensureRoomExists()

ensureRoomExists(roomId): Promise<void>

Ensure the existence of a room between the agent and a user. If no room exists, a new room is created and the user and agent are added as participants. The room ID is returned.

Parameters

roomId: `${string}-${string}-${string}-${string}-${string}`

Returns

Promise<void>

The room ID of the room between the agent and the user.

Throws

An error if the room cannot be created.

Implementation of

IAgentRuntime.ensureRoomExists

Defined in

packages/core/src/runtime.ts:1258


composeState()

composeState(message, additionalKeys): Promise<State>

Compose the state of the agent into an object that can be passed or used for response generation.

Parameters

message: Memory

The message to compose the state from.

additionalKeys = {}

Returns

Promise<State>

The state of the agent.

Implementation of

IAgentRuntime.composeState

Defined in

packages/core/src/runtime.ts:1271


updateRecentMessageState()

updateRecentMessageState(state): Promise<State>

Parameters

state: State

Returns

Promise<State>

Implementation of

IAgentRuntime.updateRecentMessageState

Defined in

packages/core/src/runtime.ts:1728