Skip to content

Commit

Permalink
feat(core): add seed to fal (#6712)
Browse files Browse the repository at this point in the history
  • Loading branch information
fundon committed Apr 26, 2024
1 parent b639e52 commit 7584ab4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
Expand Up @@ -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);
}
}
Expand Up @@ -31,6 +31,10 @@ export type TextToTextOptions = {
signal?: AbortSignal;
};

export type ToImageOptions = TextToTextOptions & {
seed?: string;
};

export function createChatSession({
workspaceId,
docId,
Expand Down Expand Up @@ -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({
Expand All @@ -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;
Expand Down

0 comments on commit 7584ab4

Please sign in to comment.