PromptRepresentable
A type whose value can represent a prompt.
Declaration
protocol PromptRepresentableOverview
For types that are not Generable, you may provide your own implementation.
Experiment with different representations to find one that works well for your type. Generally, any format that is easily understandable to humans will work well for the model as well.
struct FamousHistoricalFigure: PromptRepresentable {
var name: String
var biggestAccomplishment: String
var promptRepresentation: Prompt {
"""
Famous Historical Figure:
- name: \(name)
- best known for: \(biggestAccomplishment)
"""
}
}
let response = try await LanguageModelSession().respond {
"Tell me more about..."
FamousHistoricalFigure(
name: "Albert Einstein",
biggestAccomplishment: "Theory of Relativity"
)
}