Skip to content

Commit

Permalink
Remove devices from OpenAI payload
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-Gilles committed Oct 25, 2024
1 parent b2a57c0 commit 2c1399c
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 44 deletions.
18 changes: 0 additions & 18 deletions server/lib/gateway/gateway.forwardMessageToOpenAI.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,10 @@ const disableOpenAiFirstReply = new Set(['GET_TEMPERATURE', 'GET_HUMIDITY']);
*/
async function forwardMessageToOpenAI({ message, image, previousQuestions, context }) {
try {
const devices = this.stateManager.getAllKeys('device').map((deviceSelector) => {
const d = this.stateManager.get('device', deviceSelector);
return {
name: d.name,
room: d.room ? d.room.name : '',
features: d.features.map((f) => ({
name: f.name,
selector: f.selector,
category: f.category,
type: f.type,
last_value: f.last_value,
last_value_changed: f.last_value_changed,
unit: f.unit,
})),
};
});

const response = await this.openAIAsk({
question: message.text,
image,
previous_questions: previousQuestions,
devices,
});

const classification = {};
Expand Down
26 changes: 0 additions & 26 deletions server/test/lib/gateway/gateway.forwardMessageToOpenAI.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,32 +162,6 @@ describe('gateway.forwardMessageToOpenAI', () => {
const classification = await gateway.forwardMessageToOpenAI({ message, previousQuestions, context });
assert.calledWith(gateway.gladysGatewayClient.openAIAsk, {
question: 'Turn on the light in the living room',
devices: [
{
name: 'Capteur salon',
room: 'salon',
features: [
{
name: 'Batterie',
selector: 'mqtt-battery',
category: 'battery',
type: 'integer',
last_value: null,
last_value_changed: null,
unit: 'percent',
},
{
name: 'Niveau de Co2',
selector: 'mqtt-co2',
category: 'co2-sensor',
type: 'integer',
last_value: 1200,
last_value_changed: '2024-10-18T01:40:12.042Z',
unit: 'ppm',
},
],
},
],
image: undefined,
previous_questions: [],
});
Expand Down

0 comments on commit 2c1399c

Please sign in to comment.