Skip to content

Commit

Permalink
Update code
Browse files Browse the repository at this point in the history
  • Loading branch information
congminh1254 committed Jul 11, 2024
1 parent 70a6828 commit 4bc0008
Showing 1 changed file with 130 additions and 130 deletions.
260 changes: 130 additions & 130 deletions test/commands/ai.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,139 +5,139 @@ const assert = require('chai').assert;
const { TEST_API_ROOT, getFixture } = require('../helpers/test-helper');

describe('AI', () => {
// describe('ai:ask', () => {
// const expectedRequestBody = {
// items: [
// {
// id: '12345',
// type: 'file',
// },
// ],
// mode: 'single_item_qa',
// prompt: 'What is the status of this document?',
// };
// const expectedResponseBody = {
// answer:
// 'This document is currently in progress and being actively worked on.',
// created_at: '2024-07-09T11:29:46.835Z',
// completion_reason: 'done',
// };
// const fixture = getFixture('ai/post_ai_ask_resonse');
// const yamlFixture = getFixture('ai/post_ai_ask_resonse_yaml.txt');
describe.skip('ai:ask', () => {
const expectedRequestBody = {
items: [
{
id: '12345',
type: 'file',
},
],
mode: 'single_item_qa',
prompt: 'What is the status of this document?',
};
const expectedResponseBody = {
answer:
'This document is currently in progress and being actively worked on.',
created_at: '2024-07-09T11:29:46.835Z',
completion_reason: 'done',
};
const fixture = getFixture('ai/post_ai_ask_resonse');
const yamlFixture = getFixture('ai/post_ai_ask_resonse_yaml.txt');

// test
// .nock(TEST_API_ROOT, (api) =>
// api
// .post('/2.0/ai/ask', expectedRequestBody)
// .reply(200, expectedResponseBody)
// )
// .stdout()
// .command([
// 'ai:ask',
// '--items=id=12345,type=file',
// '--prompt',
// 'What is the status of this document?',
// '--mode',
// 'single_item_qa',
// '--json',
// '--token=test',
// ])
// .it(
// 'should send the correct request and output the response (JSON Output)',
// (ctx) => {
// assert.equal(ctx.stdout, fixture);
// }
// );
test
.nock(TEST_API_ROOT, (api) =>
api
.post('/2.0/ai/ask', expectedRequestBody)
.reply(200, expectedResponseBody)
)
.stdout()
.command([
'ai:ask',
'--items=id=12345,type=file',
'--prompt',
'What is the status of this document?',
'--mode',
'single_item_qa',
'--json',
'--token=test',
])
.it(
'should send the correct request and output the response (JSON Output)',
(ctx) => {
assert.equal(ctx.stdout, fixture);
}
);

// test
// .nock(TEST_API_ROOT, (api) =>
// api
// .post('/2.0/ai/ask', expectedRequestBody)
// .reply(200, expectedResponseBody)
// )
// .stdout()
// .command([
// 'ai:ask',
// '--items=id=12345,type=file',
// '--prompt',
// 'What is the status of this document?',
// '--mode',
// 'single_item_qa',
// '--token=test',
// ])
// .it(
// 'should send the correct request and output the response (YAML Output)',
// (ctx) => {
// assert.equal(ctx.stdout, yamlFixture);
// }
// );
// });
test
.nock(TEST_API_ROOT, (api) =>
api
.post('/2.0/ai/ask', expectedRequestBody)
.reply(200, expectedResponseBody)
)
.stdout()
.command([
'ai:ask',
'--items=id=12345,type=file',
'--prompt',
'What is the status of this document?',
'--mode',
'single_item_qa',
'--token=test',
])
.it(
'should send the correct request and output the response (YAML Output)',
(ctx) => {
assert.equal(ctx.stdout, yamlFixture);
}
);
});

// describe('ai:text-gen', () => {
// const expectedRequestBody = {
// prompt: 'What is the status of this document?',
// items: [{ id: '12345', type: 'file' }],
// dialogue_history: [
// {
// prompt: 'What is the status of this document?',
// answer: 'It is in review',
// created_at: '2024-07-09T11:29:46+00:00'
// },
// ],
// };
// const expectedResponseBody = {
// answer: 'The document is currently in review and awaiting approval.',
// created_at: '2024-07-09T11:29:46.835Z',
// completion_reason: 'done',
// };
// const fixture = getFixture('ai/post_ai_text_gen_response');
// const yamlFixture = getFixture('ai/post_ai_text_gen_response_yaml.txt');
describe.skip('ai:text-gen', () => {
const expectedRequestBody = {
prompt: 'What is the status of this document?',
items: [{ id: '12345', type: 'file' }],
dialogue_history: [
{
prompt: 'What is the status of this document?',
answer: 'It is in review',
created_at: '2024-07-09T11:29:46+00:00'
},
],
};
const expectedResponseBody = {
answer: 'The document is currently in review and awaiting approval.',
created_at: '2024-07-09T11:29:46.835Z',
completion_reason: 'done',
};
const fixture = getFixture('ai/post_ai_text_gen_response');
const yamlFixture = getFixture('ai/post_ai_text_gen_response_yaml.txt');

// test
// .nock(TEST_API_ROOT, (api) =>
// api
// .post('/2.0/ai/text_gen', expectedRequestBody)
// .reply(200, expectedResponseBody)
// )
// .stdout()
// .command([
// 'ai:text-gen',
// '--dialogue_history',
// 'prompt=What is the status of this document?,answer=It is in review,created_at=2024-07-09T11:29:46.835Z',
// '--items=id=12345,type=file',
// '--prompt',
// 'What is the status of this document?',
// '--json',
// '--token=test',
// ])
// .it(
// 'should send the correct request and output the response (JSON Output)',
// (ctx) => {
// assert.equal(ctx.stdout, fixture);
// }
// );
test
.nock(TEST_API_ROOT, (api) =>
api
.post('/2.0/ai/text_gen', expectedRequestBody)
.reply(200, expectedResponseBody)
)
.stdout()
.command([
'ai:text-gen',
'--dialogue_history',
'prompt=What is the status of this document?,answer=It is in review,created_at=2024-07-09T11:29:46.835Z',
'--items=id=12345,type=file',
'--prompt',
'What is the status of this document?',
'--json',
'--token=test',
])
.it(
'should send the correct request and output the response (JSON Output)',
(ctx) => {
assert.equal(ctx.stdout, fixture);
}
);

// test
// .nock(TEST_API_ROOT, (api) =>
// api
// .post('/2.0/ai/text_gen', expectedRequestBody)
// .reply(200, expectedResponseBody)
// )
// .stdout()
// .command([
// 'ai:text-gen',
// '--dialogue_history',
// 'prompt=What is the status of this document?,answer=It is in review,created_at=2024-07-09T11:29:46.835Z',
// '--items=id=12345,type=file',
// '--prompt',
// 'What is the status of this document?',
// '--token=test',
// ])
// .it(
// 'should send the correct request and output the response (YAML Output)',
// (ctx) => {
// assert.equal(ctx.stdout, yamlFixture);
// }
// );
// });
test
.nock(TEST_API_ROOT, (api) =>
api
.post('/2.0/ai/text_gen', expectedRequestBody)
.reply(200, expectedResponseBody)
)
.stdout()
.command([
'ai:text-gen',
'--dialogue_history',
'prompt=What is the status of this document?,answer=It is in review,created_at=2024-07-09T11:29:46.835Z',
'--items=id=12345,type=file',
'--prompt',
'What is the status of this document?',
'--token=test',
])
.it(
'should send the correct request and output the response (YAML Output)',
(ctx) => {
assert.equal(ctx.stdout, yamlFixture);
}
);
});
});

0 comments on commit 4bc0008

Please sign in to comment.