Migrating from composeContext
to new prompt composition methods and useModel
Important: This guide provides comprehensive documentation for migrating fromcomposeContext
to the new prompt composition methods, and from the old generation functions touseModel
.
composeContext
split into two specialized functionsruntime.useModel
{{var}}
to {{{var}}}
to prevent HTML escapingcomposePromptFromState
intelligently flattens complex State objects{{name1}}
, {{name2}}
, etc. with random namesgenerateText
, generateObject
, generateMessageResponse
)useModel
method for all model interactionscomposePromptFromState
intelligently handles State objectsModelType
enum for model selectionruntime.registerModel
composeState
composeState
with filteringgenerateMessageResponse
with useModel
parseKeyValueXml
instead of direct object accessentityId
and new creation methodcomposeContext
with composePrompt
or composePromptFromState
generateText
with runtime.useModel(ModelType.TEXT_*)
generateObject
with runtime.useModel
+ parseKeyValueXml
generateMessageResponse
with runtime.useModel
+ parseKeyValueXml
ModelClass
to ModelType
enum valuesparseJSONObjectFromText
with parseKeyValueXml
entityId
instead of userId
runtime.updateRecentMessageState
with filtered composeState
getEmbeddingZeroVector
- embeddings are handled automatically