mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-07-11 00:33:40 +00:00
🧊 fix: Include Conversation Starters in Agent View and List Responses (#14142)
* fix: include conversation_starters in agent view and list responses * test: cover conversation_starters in agent view and list projections * test: include conversation_starters in agent list whitelist --------- Co-authored-by: Danny Avila <danny@librechat.ai>
This commit is contained in:
parent
96367828e1
commit
96d213afe6
4 changed files with 45 additions and 0 deletions
|
|
@ -543,6 +543,7 @@ const getAgentHandler = async (req, res, expandProperties = false) => {
|
|||
id: agent.id,
|
||||
name: agent.name,
|
||||
description: agent.description,
|
||||
conversation_starters: agent.conversation_starters,
|
||||
avatar: agent.avatar,
|
||||
author: agent.author,
|
||||
provider: agent.provider,
|
||||
|
|
|
|||
|
|
@ -634,6 +634,27 @@ describe('Agent Controllers - Mass Assignment Protection', () => {
|
|||
});
|
||||
expect(response.owner_contact).toBeUndefined();
|
||||
});
|
||||
|
||||
test('should include conversation_starters in the basic VIEW response', async () => {
|
||||
const starters = ['Summarize this page', 'What can you do?'];
|
||||
const agent = await Agent.create({
|
||||
id: `agent_${uuidv4()}`,
|
||||
name: 'Starter Agent',
|
||||
description: 'Exposes conversation starters',
|
||||
provider: 'openai',
|
||||
model: 'gpt-4',
|
||||
author: mockReq.user.id,
|
||||
conversation_starters: starters,
|
||||
});
|
||||
|
||||
mockReq.params = { id: agent.id };
|
||||
|
||||
await getAgentHandler(mockReq, mockRes);
|
||||
|
||||
expect(mockRes.status).toHaveBeenCalledWith(200);
|
||||
const response = mockRes.json.mock.calls[0][0];
|
||||
expect(response.conversation_starters).toEqual(starters);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getAgentVersionsHandler', () => {
|
||||
|
|
@ -1625,6 +1646,7 @@ describe('Agent Controllers - Mass Assignment Protection', () => {
|
|||
'author',
|
||||
'avatar',
|
||||
'category',
|
||||
'conversation_starters',
|
||||
'description',
|
||||
'id',
|
||||
'is_promoted',
|
||||
|
|
|
|||
|
|
@ -3620,6 +3620,27 @@ describe('Support Contact Field', () => {
|
|||
expect(result.data[0].skills_enabled).toBe(true);
|
||||
});
|
||||
|
||||
test('should include conversation_starters in the default list projection', async () => {
|
||||
const starters = ['Summarize this page', 'What can you do?'];
|
||||
const scopedAgent = await createAgent({
|
||||
id: `agent_${uuidv4().slice(0, 12)}`,
|
||||
name: 'Agent With Starters',
|
||||
description: 'Agent exposing conversation starters',
|
||||
provider: 'openai',
|
||||
model: 'gpt-4',
|
||||
author: userA,
|
||||
conversation_starters: starters,
|
||||
});
|
||||
|
||||
const result = await getListAgentsByAccess({
|
||||
accessibleIds: [scopedAgent._id] as mongoose.Types.ObjectId[],
|
||||
otherParams: {},
|
||||
});
|
||||
|
||||
expect(result.data).toHaveLength(1);
|
||||
expect(result.data[0].conversation_starters).toEqual(starters);
|
||||
});
|
||||
|
||||
test('should return multiple accessible agents when provided', async () => {
|
||||
// Give User B access to two of User A's agents
|
||||
const accessibleIds = [agentA1._id, agentA3._id] as mongoose.Types.ObjectId[];
|
||||
|
|
|
|||
|
|
@ -905,6 +905,7 @@ export function createAgentMethods(
|
|||
avatar: 1,
|
||||
author: 1,
|
||||
description: 1,
|
||||
conversation_starters: 1,
|
||||
updatedAt: 1,
|
||||
category: 1,
|
||||
support_contact: 1,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue