mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00:00
@@ -32,6 +32,7 @@ import {
|
||||
chatWithImages,
|
||||
chatWithText,
|
||||
chatWithTextStream,
|
||||
chatWithWorkflow,
|
||||
createCopilotMessage,
|
||||
createCopilotSession,
|
||||
getHistories,
|
||||
@@ -238,6 +239,31 @@ test('should be able to chat with api', async t => {
|
||||
Sinon.restore();
|
||||
});
|
||||
|
||||
test('should be able to chat with api by workflow', async t => {
|
||||
const { app } = t.context;
|
||||
|
||||
const { id } = await createWorkspace(app, token);
|
||||
const sessionId = await createCopilotSession(
|
||||
app,
|
||||
token,
|
||||
id,
|
||||
randomUUID(),
|
||||
'workflow:presentation'
|
||||
);
|
||||
const messageId = await createCopilotMessage(
|
||||
app,
|
||||
token,
|
||||
sessionId,
|
||||
'apple company'
|
||||
);
|
||||
const ret = await chatWithWorkflow(app, token, sessionId, messageId);
|
||||
t.is(
|
||||
ret,
|
||||
textToEventStream('generate text to text stream', messageId),
|
||||
'should be able to chat with workflow'
|
||||
);
|
||||
});
|
||||
|
||||
test('should be able to chat with special image model', async t => {
|
||||
const { app, storage } = t.context;
|
||||
|
||||
|
||||
@@ -553,8 +553,8 @@ test.skip('should be able to preview workflow', async t => {
|
||||
|
||||
let result = '';
|
||||
for await (const ret of workflow.runGraph(
|
||||
'Create a presentation',
|
||||
'apple company'
|
||||
{ content: 'apple company' },
|
||||
'workflow:presentation'
|
||||
)) {
|
||||
result += ret;
|
||||
console.log('stream result:', ret);
|
||||
|
||||
@@ -33,6 +33,7 @@ export class MockCopilotTestProvider
|
||||
static override readonly type = CopilotProviderType.Test;
|
||||
override readonly availableModels = [
|
||||
'test',
|
||||
'gpt-4o',
|
||||
'fast-sdxl/image-to-image',
|
||||
'lcm-sd15-i2i',
|
||||
'clarity-upscaler',
|
||||
@@ -234,6 +235,15 @@ export async function chatWithTextStream(
|
||||
return chatWithText(app, userToken, sessionId, messageId, '/stream');
|
||||
}
|
||||
|
||||
export async function chatWithWorkflow(
|
||||
app: INestApplication,
|
||||
userToken: string,
|
||||
sessionId: string,
|
||||
messageId?: string
|
||||
) {
|
||||
return chatWithText(app, userToken, sessionId, messageId, '/workflow');
|
||||
}
|
||||
|
||||
export async function chatWithImages(
|
||||
app: INestApplication,
|
||||
userToken: string,
|
||||
|
||||
Reference in New Issue
Block a user