Skip to content

Commit a5ac672

Browse files
committed
Use Gpt4Service in PluginService
Prompt: Modify the PluginService class. In the PluginService.executeMode() method, call Gpt4Service.call(prompt, model) if model equals "gpt4" or "gpt3" - don't use Gpt3Service. Add tests for your changes in test/pluginService.test.js
1 parent 149f3cf commit a5ac672

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

src/services/pluginService.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,11 @@ export default class PluginService {
8686
await this.processPipedInput()
8787
return "Changes applied"
8888
}
89-
if (model === "gpt3") {
90-
return await Gpt3Service.call(prompt)
91-
}
92-
if (model === "gpt4") {
93-
return await Gpt4Service.call(prompt)
89+
if (model === "gpt3" || model === "gpt4") {
90+
return await Gpt4Service.call(prompt, model)
9491
}
9592
console.log(`model ${model} is not supported`)
9693
exit(1)
9794
}
9895

99-
}
96+
}

test/pluginService.test.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,18 @@ describe('PluginService', () => {
2121
if (gpt4ServiceStub) gpt4ServiceStub.restore()
2222
});
2323

24-
it('should call Gpt3Service when mode is gpt3', async () => {
25-
const gpt3ServiceStub = sinon.stub(Gpt3Service, 'call').resolves('GPT3 result');
24+
it('should call Gpt4Service when mode is gpt3', async () => {
25+
gpt4ServiceStub.resolves('GPT3 result');
2626
const result = await PluginService.executeMode('gpt3', 'Test prompt');
2727
assert.strictEqual(result, 'GPT3 result');
28-
gpt3ServiceStub.restore();
28+
sinon.assert.calledWith(gpt4ServiceStub, 'Test prompt', 'gpt3');
2929
});
3030

3131
it('should call Gpt4Service when mode is gpt4', async () => {
3232
gpt4ServiceStub.resolves('GPT4 result');
3333
const result = await PluginService.executeMode('gpt4', 'Test prompt');
3434
assert.strictEqual(result, 'GPT4 result');
35+
sinon.assert.calledWith(gpt4ServiceStub, 'Test prompt', 'gpt4');
3536
});
3637
});
3738

0 commit comments

Comments
 (0)