Contents

LanguageModelSession.Profile

A profile that contains dynamic instructions.

Declaration

struct Profile

Mentioned in

Overview

A profile binds DynamicInstructions to a set of session-level configuration values. The DynamicInstructions describes the content and tools and a LanguageModelSession.DynamicProfile orchestrates transitions betwen session configurations.

Profile {
    // Custom instructions and tools for a creative task.
}
.model(PrivateCloudComputeLanguageModel())
// Use a higher creative temperature value when a person likes poetry.
.temperature(likesPoetry ? 0.8 : 0.1)
// Perform deeper reasoning when a person likes astronomy.
.reasoningLevel(likesAstronomy ? .deep : .light)

A LanguageModelSession.Profile conforms to LanguageModelSession.DynamicProfile and includes all the same modifiers that you use to configure a unit of work to perform. Observe and react to key moments during a session by using life cycle modifiers. When a profile and a subprofile both register a callback, the framework calls both. The following shows observing onToolOutput(perform:) to handle logging after a tool provides output:

Profile {
    // Custom instructions and tools for the task.
}
.onToolOutput { toolCall, output in
    // Runs after the tool to log any necessary activity.
}

Topics

Creating a profile

See Also

Dynamic profiles