Context
@daydreamsai/core / Context
Interface: Context<TMemory, Schema, Ctx, Actions, Events>
Defined in: packages/core/src/types.ts:1077
Extends
ContextConfigApi<TMemory,Schema,Ctx,Actions,Events>
Type Parameters
TMemory
TMemory = any
Schema
Schema extends z.ZodTypeAny | ZodRawShape = z.ZodTypeAny
Ctx
Ctx = any
Actions
Actions extends AnyAction[] = AnyAction[]
Events
Events extends Record<string, z.ZodTypeAny | ZodRawShape> = Record<string, z.ZodTypeAny | ZodRawShape>
Properties
__composers?
optional__composers:BaseContextComposer<Context<TMemory,Schema,Ctx,Actions,Events>>[]
Defined in: packages/core/src/types.ts:1191
__templateResolvers?
optional__templateResolvers:Record<string,TemplateResolver<AgentContext<Context<TMemory,Schema,Ctx,Actions,Events>> &ContextStateApi<Context<TMemory,Schema,Ctx,Actions,Events>>>>
Defined in: packages/core/src/types.ts:1193
actions?
optionalactions:Resolver<Action<ActionSchema,any,unknown,AnyContext,AnyAgent,ActionState>[],ContextState<Context<TMemory,Schema,Ctx,Actions,Events>>>
Defined in: packages/core/src/types.ts:1165
create()?
optionalcreate: (params,agent) =>TMemory|Promise<TMemory>
Defined in: packages/core/src/types.ts:1102
Optional function to create new memory for this context
Parameters
params
args
InferSchemaArguments<Schema>
id
string
key?
string
options
Ctx
settings
agent
Returns
TMemory | Promise<TMemory>
description?
optionaldescription:Resolver<string|string[],ContextState<Context<TMemory,Schema,Ctx,Actions,Events>>>
Defined in: packages/core/src/types.ts:1117
Optional description of this context
episodeHooks?
optionalepisodeHooks:EpisodeHooks<Context<TMemory,Schema,Ctx,Actions,Events>>
Defined in: packages/core/src/types.ts:1163
Episode detection and creation hooks for this context
events?
optionalevents:Resolver<Events,ContextState<Context<TMemory,Schema,Ctx,Actions,Events>>>
Defined in: packages/core/src/types.ts:1167
inputs?
optionalinputs:Resolver<Record<string,InputConfig<any,any,AnyAgent>>,ContextState<Context<TMemory,Schema,Ctx,Actions,Events>>>
Defined in: packages/core/src/types.ts:1172
A record of input configurations for the context.
instructions?
optionalinstructions:Resolver<Instruction,ContextState<Context<TMemory,Schema,Ctx,Actions,Events>>>
Defined in: packages/core/src/types.ts:1114
Optional instructions for this context
key()?
optionalkey: (args) =>string
Defined in: packages/core/src/types.ts:1092
Function to generate a unique key from context arguments
Parameters
args
InferSchemaArguments<Schema>
Returns
string
load()?
optionalload: (id,params) =>Promise<null|TMemory>
Defined in: packages/core/src/types.ts:1120
Optional function to load existing memory
Parameters
id
string
params
options
Ctx
settings
Returns
Promise<null | TMemory>
loader()?
optionalloader: (state,agent) =>Promise<void>
Defined in: packages/core/src/types.ts:1156
Parameters
state
ContextState<Context<TMemory, Schema, Ctx, Actions, Events>>
agent
Returns
Promise<void>
maxSteps?
optionalmaxSteps:number
Defined in: packages/core/src/types.ts:1158
maxWorkingMemorySize?
optionalmaxWorkingMemorySize:number
Defined in: packages/core/src/types.ts:1160
model?
optionalmodel:LanguageModel
Defined in: packages/core/src/types.ts:1132
modelSettings?
optionalmodelSettings:object
Defined in: packages/core/src/types.ts:1134
Index Signature
[key: string]: any
maxTokens?
optionalmaxTokens:number
providerOptions?
optionalproviderOptions:Record<string,any>
stopSequences?
optionalstopSequences:string[]
temperature?
optionaltemperature:number
topK?
optionaltopK:number
topP?
optionaltopP:number
onError()?
optionalonError: (error,ctx,agent) =>Promise<void>
Defined in: packages/core/src/types.ts:1150
Parameters
error
unknown
ctx
AgentContext<Context<TMemory, Schema, Ctx, Actions, Events>>
agent
Returns
Promise<void>
onRun()?
optionalonRun: (ctx,agent) =>Promise<void>
Defined in: packages/core/src/types.ts:1144
Parameters
ctx
AgentContext<Context<TMemory, Schema, Ctx, Actions, Events>>
agent
Returns
Promise<void>
onStep()?
optionalonStep: (ctx,agent) =>Promise<void>
Defined in: packages/core/src/types.ts:1146
Parameters
ctx
AgentContext<Context<TMemory, Schema, Ctx, Actions, Events>>
agent
Returns
Promise<void>
outputs?
optionaloutputs:Resolver<Record<string,Omit<Output<any,any,AnyContext,any>,"name">>,ContextState<Context<TMemory,Schema,Ctx,Actions,Events>>>
Defined in: packages/core/src/types.ts:1180
A record of output configurations for the context.
render()?
optionalrender: (state) =>string|string[] |XMLElement|XMLElement[] | (string|XMLElement)[]
Defined in: packages/core/src/types.ts:1128
Optional function to render memory state
Parameters
state
ContextState<Context<TMemory, Schema, Ctx, Actions, Events>>
Returns
string | string[] | XMLElement | XMLElement[] | (string | XMLElement)[]
retrieval?
optionalretrieval:Resolver<RetrievalPolicy,ContextState<Context<TMemory,Schema,Ctx,Actions,Events>>>
Defined in: packages/core/src/types.ts:1189
Retrieval configuration to adapt memory recall per-context. Can be a static object or a function of the current context state.
save()?
optionalsave: (state) =>Promise<void>
Defined in: packages/core/src/types.ts:1125
Optional function to save memory state
Parameters
state
ContextState<Context<TMemory, Schema, Ctx, Actions, Events>>
Returns
Promise<void>
schema?
optionalschema:Schema
Defined in: packages/core/src/types.ts:1090
Zod schema for validating context arguments
setup()?
optionalsetup: (args,settings,agent) =>Ctx|Promise<Ctx>
Defined in: packages/core/src/types.ts:1095
Setup function to initialize context data
Parameters
args
InferSchemaArguments<Schema>
settings
agent
Returns
Ctx | Promise<Ctx>
shouldContinue()?
optionalshouldContinue: (ctx) =>boolean
Defined in: packages/core/src/types.ts:1148
Parameters
ctx
AgentContext<Context<TMemory, Schema, Ctx, Actions, Events>>
Returns
boolean
type
type:
string
Defined in: packages/core/src/types.ts:1088
Unique type identifier for this context
Methods
setActions()
setActions<
TActions>(actions):Context<TMemory,Schema,Ctx,TActions,Events>
Defined in: packages/core/src/types.ts:992
Type Parameters
TActions
TActions extends AnyActionWithContext<Context<TMemory, Schema, Ctx, any, Events>>[]
Parameters
actions
TActions
Returns
Context<TMemory, Schema, Ctx, TActions, Events>
Inherited from
ContextConfigApi.setActions
setInputs()
setInputs<
TSchemas>(inputs):Context<TMemory,Schema,Ctx,Actions,Events>
Defined in: packages/core/src/types.ts:999
Type Parameters
TSchemas
TSchemas extends Record<string, Readonly<{[k: string]: $ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>; }> | ZodString | ZodObject<$ZodLooseShape, $strip>>
Parameters
inputs
{ [K in string | number | symbol]: InputConfig<TSchemas[K], Context<TMemory, Schema, Ctx, Actions, Events>, AnyAgent> }
Returns
Context<TMemory, Schema, Ctx, Actions, Events>
Inherited from
ContextConfigApi.setInputs
setOutputs()
setOutputs<
TSchemas>(outputs):Context<TMemory,Schema,Ctx,Actions,Events>
Defined in: packages/core/src/types.ts:1008
Type Parameters
TSchemas
TSchemas extends Record<string, Readonly<{[k: string]: $ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>; }> | ZodString | ZodObject<$ZodLooseShape, $strip>>
Parameters
outputs
{ [K in string | number | symbol]: OutputConfig<TSchemas[K], any, Context<TMemory, Schema, Ctx, Actions, Events>, AnyAgent> }
Returns
Context<TMemory, Schema, Ctx, Actions, Events>
Inherited from
ContextConfigApi.setOutputs
use()
use<
Refs>(composer):Context<TMemory,Schema,Ctx,Actions,Events>
Defined in: packages/core/src/types.ts:1019
Type Parameters
Refs
Refs extends AnyContext[]
Parameters
composer
ContextComposer<Context<TMemory, Schema, Ctx, Actions, Events>, Refs>
Returns
Context<TMemory, Schema, Ctx, Actions, Events>
Inherited from
ContextConfigApi.use