mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
feat(core): add seed to fal (#6712)
This commit is contained in:
@@ -158,9 +158,14 @@ export class CopilotClient {
|
||||
}
|
||||
|
||||
// Text or image to images
|
||||
imagesStream(messageId: string, sessionId: string) {
|
||||
return new EventSource(
|
||||
`${this.backendUrl}/api/copilot/chat/${sessionId}/images?messageId=${messageId}`
|
||||
imagesStream(messageId: string, sessionId: string, seed?: string) {
|
||||
const url = new URL(
|
||||
`${this.backendUrl}/api/copilot/chat/${sessionId}/images`
|
||||
);
|
||||
url.searchParams.set('messageId', messageId);
|
||||
if (seed) {
|
||||
url.searchParams.set('seed', seed);
|
||||
}
|
||||
return new EventSource(url);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,10 @@ export type TextToTextOptions = {
|
||||
signal?: AbortSignal;
|
||||
};
|
||||
|
||||
export type ToImageOptions = TextToTextOptions & {
|
||||
seed?: string;
|
||||
};
|
||||
|
||||
export function createChatSession({
|
||||
workspaceId,
|
||||
docId,
|
||||
@@ -175,8 +179,9 @@ export function toImage({
|
||||
content,
|
||||
attachments,
|
||||
params,
|
||||
seed,
|
||||
timeout = TIMEOUT,
|
||||
}: TextToTextOptions) {
|
||||
}: ToImageOptions) {
|
||||
return {
|
||||
[Symbol.asyncIterator]: async function* () {
|
||||
const { messageId, sessionId } = await createSessionMessage({
|
||||
@@ -188,7 +193,7 @@ export function toImage({
|
||||
params,
|
||||
});
|
||||
|
||||
const eventSource = client.imagesStream(messageId, sessionId);
|
||||
const eventSource = client.imagesStream(messageId, sessionId, seed);
|
||||
for await (const event of toTextStream(eventSource, { timeout })) {
|
||||
if (event.type === 'attachment') {
|
||||
yield event.data;
|
||||
|
||||
Reference in New Issue
Block a user