Skip to content

Commit

Permalink
ChatGPT: Add "NO_RESPONSE" option in case no answer is needed (#2163)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-Gilles authored Nov 8, 2024
1 parent c102bbb commit 37f76c4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion server/lib/gateway/gateway.forwardMessageToOpenAI.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const intentTranslation = {
INFO: 'info.get-info',
};

const disableOpenAiFirstReply = new Set(['GET_TEMPERATURE', 'GET_HUMIDITY']);
const disableOpenAiFirstReply = new Set(['GET_TEMPERATURE', 'GET_HUMIDITY', 'NO_RESPONSE']);

/**
* @public
Expand Down
12 changes: 12 additions & 0 deletions server/test/lib/gateway/gateway.forwardMessageToOpenAI.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,18 @@ describe('gateway.forwardMessageToOpenAI', () => {
intent: 'temperature-sensor.get-in-room',
});
});
it('should do nothing, no-response was sent', async () => {
gateway.gladysGatewayClient.openAIAsk = fake.resolves({
type: 'NO_RESPONSE',
answer: '',
room: '',
});
const classification = await gateway.forwardMessageToOpenAI({ message, previousQuestions, context });
expect(classification).to.deep.equal({
intent: undefined,
});
assert.notCalled(messageManager.reply);
});
it('should start scene from OpenAI', async () => {
gateway.gladysGatewayClient.openAIAsk = fake.resolves({
type: 'SCENE_START',
Expand Down

0 comments on commit 37f76c4

Please sign in to comment.