#chat->ask(message, schema?) → any KScript.AI
发送消息并返回回复,同时保留历史记录。若提供模式(schema),回复即为映射。
参数可以命名:->ask(…, schema: …)。
示例
<let name="chat" value="@chat('Answer in one word.')" />
<echo>{ $chat->ask('What colour is the sky?') }</echo>
<echo>{ $chat->ask('And grass?') }</echo>
<let name="rating" value="$chat->ask('Rate this review: Loved it!', schema: { stars: 'int 1-5' })" />
<echo>{ $rating.stars } stars</echo>$chat = @chat('Answer in one word.')
echo $chat->ask('What colour is the sky?')
echo $chat->ask('And grass?')
$rating = $chat->ask('Rate this review: Loved it!', schema: { stars: 'int 1-5' })
echo "{ $rating.stars } stars"