feat: add response guidelines and guardrails field (#11911)

Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
This commit is contained in:
Shivam Mishra
2025-07-15 08:56:03 +05:30
committed by GitHub
parent 1132556512
commit 4378506a35
6 changed files with 72 additions and 16 deletions

View File

@@ -62,7 +62,9 @@ RSpec.describe 'Api::V1::Accounts::Captain::Assistants', type: :request do
{
assistant: {
name: 'New Assistant',
description: 'Assistant Description'
description: 'Assistant Description',
response_guidelines: ['Be helpful', 'Be concise'],
guardrails: ['No harmful content', 'Stay on topic']
}
}
end
@@ -96,6 +98,8 @@ RSpec.describe 'Api::V1::Accounts::Captain::Assistants', type: :request do
end.to change(Captain::Assistant, :count).by(1)
expect(json_response[:name]).to eq('New Assistant')
expect(json_response[:response_guidelines]).to eq(['Be helpful', 'Be concise'])
expect(json_response[:guardrails]).to eq(['No harmful content', 'Stay on topic'])
expect(response).to have_http_status(:success)
end
end
@@ -106,7 +110,9 @@ RSpec.describe 'Api::V1::Accounts::Captain::Assistants', type: :request do
let(:update_attributes) do
{
assistant: {
name: 'Updated Assistant'
name: 'Updated Assistant',
response_guidelines: ['Updated guideline'],
guardrails: ['Updated guardrail']
}
}
end
@@ -139,6 +145,38 @@ RSpec.describe 'Api::V1::Accounts::Captain::Assistants', type: :request do
expect(response).to have_http_status(:success)
expect(json_response[:name]).to eq('Updated Assistant')
expect(json_response[:response_guidelines]).to eq(['Updated guideline'])
expect(json_response[:guardrails]).to eq(['Updated guardrail'])
end
it 'updates only response_guidelines when only that is provided' do
assistant.update!(response_guidelines: ['Original guideline'], guardrails: ['Original guardrail'])
original_name = assistant.name
patch "/api/v1/accounts/#{account.id}/captain/assistants/#{assistant.id}",
params: { assistant: { response_guidelines: ['New guideline only'] } },
headers: admin.create_new_auth_token,
as: :json
expect(response).to have_http_status(:success)
expect(json_response[:name]).to eq(original_name)
expect(json_response[:response_guidelines]).to eq(['New guideline only'])
expect(json_response[:guardrails]).to eq(['Original guardrail'])
end
it 'updates only guardrails when only that is provided' do
assistant.update!(response_guidelines: ['Original guideline'], guardrails: ['Original guardrail'])
original_name = assistant.name
patch "/api/v1/accounts/#{account.id}/captain/assistants/#{assistant.id}",
params: { assistant: { guardrails: ['New guardrail only'] } },
headers: admin.create_new_auth_token,
as: :json
expect(response).to have_http_status(:success)
expect(json_response[:name]).to eq(original_name)
expect(json_response[:response_guidelines]).to eq(['Original guideline'])
expect(json_response[:guardrails]).to eq(['New guardrail only'])
end
end
end