feat: model overload error

This commit is contained in:
Index 2025-11-09 22:23:39 -06:00
parent 2fbf412df4
commit 8ac057b80a
5 changed files with 21 additions and 11 deletions

View file

@ -6,7 +6,7 @@ services:
environment:
- "AUTHORIZED_USERS=${AUTHORIZED_USERS}"
- "SERVICE=${SERVICE:?https://bsky.social}"
- "DB_PATH=sqlite.db"
- DB_PATH=/data/sqlite.db
- "GEMINI_MODEL=${GEMINI_MODEL:-gemini-2.5-flash}"
- "DID=${DID:?}"
- "HANDLE=${HANDLE:?}"
@ -14,4 +14,7 @@ services:
- "GEMINI_API_KEY=${GEMINI_API_KEY:?}"
- "USE_JETSTREAM=${USE_JETSTREAM:-false}"
volumes:
- aero_db:/sqlite.db
- "aero_db:/data"
volumes:
aero_db:

View file

@ -63,6 +63,9 @@ export const ai = new GoogleGenAI({
export const QUOTA_EXCEEDED_MESSAGE =
"You have exceeded your daily message quota (15). Please wait 24 hours before trying again.";
export const ERROR_MESSAGE =
"Sorry, I ran into an issue analyzing that post. Please try again.";
export const UNAUTHORIZED_MESSAGE =
"I cant make sense of your noise just yet. Youll need to be whitelisted before I can help.";

View file

@ -174,12 +174,17 @@ export async function handler(message: ChatMessage): Promise<void> {
});
}
}
} catch (error) {
} catch (error: any) {
logger.error("Error in post handler:", error);
let errorMsg = c.ERROR_MESSAGE;
if (error.error.code == 503) {
errorMsg =
"Sorry, the AI model is currently overloaded. Please try again later.";
}
await conversation.sendMessage({
text:
"Sorry, I ran into an issue analyzing that post. Please try again.",
text: errorMsg,
});
}
}

View file

@ -8,7 +8,7 @@ import db from "../db";
import { conversations, messages } from "../db/schema";
import { and, eq } from "drizzle-orm";
import { env } from "../env";
import { bot, MAX_GRAPHEMES } from "../core";
import { bot, ERROR_MESSAGE, MAX_GRAPHEMES } from "../core";
import { parsePost, parsePostImages, traverseThread } from "./post";
/*
@ -137,8 +137,7 @@ export async function parseConversation(
};
} catch (e) {
convo.sendMessage({
text:
"Sorry, I ran into an issue analyzing that post. Please try again.",
text: ERROR_MESSAGE,
});
throw new Error("Failed to parse conversation");

View file

@ -42,8 +42,6 @@ async function parseQuote(post: Post) {
) return undefined;
const record = (post.embed as RecordEmbed || RecordWithMediaEmbed).record;
console.log("embed: ", post.embed);
console.log("record: ", record);
const embedPost = await c.bot.getPost(record.uri);
return await parsePost(embedPost, false);
@ -63,7 +61,9 @@ export function parsePostImages(post: Post) {
}
}
return images.map((image, idx) => parseImage(image, idx + 1));
return images.map((image, idx) => parseImage(image, idx + 1)).filter((img) =>
img.alt.length > 0
);
}
function parseImage(image: EmbedImage, index: number) {