[1.x] Let apps generate a conversation's title the way the package does
Merged
ME
7d ago+164+164+012345678901234567890123456789-16-16-01234567890123456789
RememberConversation titles only the conversations it creates. Apps that create the row before the first prompt (the #983 workaround) get no title. Title generation now runs through ConversationTitleAgent, so apps can reuse it and replace it.
Title a conversation the app created
$conversation->update([
'title' => app(ConversationTitleAgent::class)->prompt($message)->text,
]);
Replace the title agent
$this->app->bind(ConversationTitleAgent::class, SupportTitleAgent::class);
#[UseSmartestModel]
class SupportTitleAgent extends ConversationTitleAgent
{
public function instructions(): string
{
return 'Title this support thread in 3-6 words, naming the product area first.';
}
}
Fake it
ConversationTitleAgent::fake(['Billing Question']);
[!NOTE]
A faked conversational agent no longer spends one of its fake responses on the title. The title agent answers with its own fake unless the test fakes it.
PHP does not inherit attributes. A subclass without a model attribute runs on the provider's default model, not the cheapest.