Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: plugin-letzai #2960

Merged
merged 3 commits into from
Jan 29, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions packages/plugin-letzai/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ else
async function pollLetzAiImageStatus(
id: string,
letzAiApiKey: string,
callback: any,
callback: (response: { text: string; attachments?: Array<{ id: string; url: string; title: string; source: string; description: string; contentType: string; text: string; }> }) => void,
maxPolls = 40,
pollIntervalMs = 3000 // 3 seconds
) {
Expand Down Expand Up @@ -63,13 +63,13 @@ async function pollLetzAiImageStatus(

if (!finalUrl) {
callback({
text: `Image is ready, but no final URL found.`,
text: 'Image is ready, but no final URL found.',
});
return;
}

callback({
text: `Your image is ready!`,
text: 'Your image is ready!',
attachments: [
{
id,
Expand All @@ -83,9 +83,9 @@ async function pollLetzAiImageStatus(
],
});
}
} catch (err: any) {
} catch (err: unknown) {
callback({
text: `Error while polling LetzAI: ${err.message}`,
text: `Error while polling LetzAI: ${err instanceof Error ? err.message : "Unknown error"}`,
});
return;
}
Expand All @@ -104,7 +104,7 @@ export const letzAiImageGeneration = {
description: "Generate an image via LetzAI API (with polling).",
suppressInitialMessage: true,

validate: async (_runtime: any, _message: any, _state: any) => {
validate: async (_runtime: IAgentRuntime, _message: Memory, _state: State) => {
// Provide a default validate() that simply returns true
return true;
},
Expand Down Expand Up @@ -164,10 +164,10 @@ export const letzAiImageGeneration = {
customSystemPrompt: IMAGE_SYSTEM_PROMPT,
});*/

let imagePrompt = `${userPrompt}`.trim();
let imagePrompt = userPrompt.trim();

//Prepend our Models from the .env config to make sure characters, styles and objects are respected
imagePrompt = letzAiModels + ", " + imagePrompt;
imagePrompt = `${letzAiModels}, ${imagePrompt}`;
const prompt = imagePrompt;

elizaLogger.log("Image prompt received:", imagePrompt);
Expand Down Expand Up @@ -201,17 +201,17 @@ export const letzAiImageGeneration = {



// 3) Let the user know weve started generating
// 3) Let the user know we've started generating
const { id, status, progress } = createData;
callback({
text: `Started generating your image. (ID: ${id}, status: ${status}, progress: ${progress}%)`,
});

// 4) Begin polling every 5s
await pollLetzAiImageStatus(id, letzAiApiKey, callback, /* maxPolls */ 20, /* pollIntervalMs */ 5000);
} catch (error: any) {
} catch (error: unknown) {
callback({
text: `Error while requesting LetzAI: ${error.message}`,
text: `Error while requesting LetzAI: ${error instanceof Error ? error.message : "Unknown error"}`,
});
}
},
Expand Down
Loading