Упрощение: общие хелперы, команды и упоминания по entities, фото только для моделей со зрением
- Одна formatUtc и один displayName(profile) вместо копий в разных слоях
- commandOf/mentionsUser/textWithoutMention работают по entities для текста и подписей;
убраны askInCaption, regex-поиск упоминаний и отдельный composer.command("ask")
- Фото скачиваются только если модель их видит; пустой вопрос с картинкой формулирует промпт
- Поддержка фото задаётся явно для моделей по умолчанию, для своей AI_MODEL — через AI_IMAGE_INPUT
- Активность участников считается по сохранённой истории, а не отдельными счётчиками;
один хендлер для message и edited_message, упоминания не пишутся дважды
- SQLite: synchronous = NORMAL для WAL
- Кнопки не-админов отклоняются через bot.drop(isAdmin)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -22,14 +22,12 @@ interface AssistantServiceDeps {
|
||||
|
||||
const MAX_AGENT_STEPS = 6;
|
||||
|
||||
/** Сообщение пользователя для модели: текст вопроса и, если модель умеет, картинки. */
|
||||
const buildUserMessage = (question: Question, imageInput: boolean) => ({
|
||||
/** Сообщение пользователя для модели: текст вопроса и скачанные картинки. */
|
||||
const buildUserMessage = (question: Question) => ({
|
||||
role: "user" as const,
|
||||
content: [
|
||||
{ type: "text" as const, text: buildPrompt(question, imageInput) },
|
||||
...(imageInput
|
||||
? question.images.map((image) => ({ type: "image" as const, image: image.data, mimeType: image.mimeType }))
|
||||
: []),
|
||||
{ type: "text" as const, text: buildPrompt(question) },
|
||||
...question.images.map((image) => ({ type: "image" as const, image: image.data, mimeType: image.mimeType })),
|
||||
],
|
||||
});
|
||||
|
||||
@@ -59,7 +57,7 @@ export const createAssistantService = ({
|
||||
|
||||
requestContext.set("chatId", question.chatId);
|
||||
|
||||
const result = await agent.generate([buildUserMessage(question, imageInput)], {
|
||||
const result = await agent.generate([buildUserMessage(question)], {
|
||||
instructions: buildInstructions(systemRules, question, persona),
|
||||
requestContext,
|
||||
maxSteps: MAX_AGENT_STEPS,
|
||||
@@ -68,7 +66,8 @@ export const createAssistantService = ({
|
||||
return result.text.trim();
|
||||
};
|
||||
|
||||
return { answer };
|
||||
/** Боту стоит скачивать фото, только если модель умеет их смотреть. */
|
||||
return { answer, canSeeImages: imageInput };
|
||||
};
|
||||
|
||||
export type AssistantService = ReturnType<typeof createAssistantService>;
|
||||
|
||||
Reference in New Issue
Block a user