Фото в вопросах, Gemini 3.8 Flash по умолчанию, команды /context и /clear
- Бот смотрит фото: подпись с упоминанием, /ask в подписи или ответом на фото, фото в личке - Картинки скачиваются через Bot API и передаются модели байтами (ссылка с токеном наружу не уходит) - OpenRouter по умолчанию — openrouter/google/gemini-3.8-flash; AI_IMAGE_INPUT для явного выбора - Модель без зрения получает пометку, что фото есть, но она его не видит - /context: сколько бот помнит и видит ли всю переписку (privacy mode / админ) - /clear: очистка сохранённой переписки чата с подтверждением Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -14,13 +14,31 @@ export type { Question } from "./prompts.js";
|
||||
|
||||
interface AssistantServiceDeps {
|
||||
model: string;
|
||||
/** Умеет ли модель смотреть изображения; если нет — фото ей не отправляем. */
|
||||
imageInput: boolean;
|
||||
chatHistoryService: ChatHistoryService;
|
||||
chatMemberService: ChatMemberService;
|
||||
}
|
||||
|
||||
const MAX_AGENT_STEPS = 6;
|
||||
|
||||
export const createAssistantService = ({ model, chatHistoryService, chatMemberService }: AssistantServiceDeps) => {
|
||||
/** Сообщение пользователя для модели: текст вопроса и, если модель умеет, картинки. */
|
||||
const buildUserMessage = (question: Question, imageInput: boolean) => ({
|
||||
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 }))
|
||||
: []),
|
||||
],
|
||||
});
|
||||
|
||||
export const createAssistantService = ({
|
||||
model,
|
||||
imageInput,
|
||||
chatHistoryService,
|
||||
chatMemberService,
|
||||
}: AssistantServiceDeps) => {
|
||||
const systemRules = readPrompt("system.md");
|
||||
|
||||
const agent = new Agent({
|
||||
@@ -41,7 +59,7 @@ export const createAssistantService = ({ model, chatHistoryService, chatMemberSe
|
||||
|
||||
requestContext.set("chatId", question.chatId);
|
||||
|
||||
const result = await agent.generate(buildPrompt(question), {
|
||||
const result = await agent.generate([buildUserMessage(question, imageInput)], {
|
||||
instructions: buildInstructions(systemRules, question, persona),
|
||||
requestContext,
|
||||
maxSteps: MAX_AGENT_STEPS,
|
||||
|
||||
Reference in New Issue
Block a user