adds attachment support
This commit is contained in:
@@ -4,6 +4,7 @@ import { z } from "zod";
|
||||
import { env } from "../env.js";
|
||||
import { exaClient } from "../search/exa.js";
|
||||
import { searchSearxng } from "../search/searxng.js";
|
||||
import { buildOpenAIConversationMessage } from "./message-content.js";
|
||||
import type { ChatMessage } from "./types.js";
|
||||
|
||||
const MAX_TOOL_ROUNDS = 4;
|
||||
@@ -250,23 +251,7 @@ function extractHtmlTitle(html: string) {
|
||||
}
|
||||
|
||||
function normalizeIncomingMessages(messages: ChatMessage[]) {
|
||||
const normalized = messages.map((m) => {
|
||||
if (m.role === "tool") {
|
||||
const name = m.name?.trim() || "tool";
|
||||
return {
|
||||
role: "user",
|
||||
content: `Tool output (${name}):\n${m.content}`,
|
||||
};
|
||||
}
|
||||
if (m.role === "assistant" || m.role === "system" || m.role === "user") {
|
||||
const out: any = { role: m.role, content: m.content };
|
||||
if (m.name && (m.role === "assistant" || m.role === "user")) {
|
||||
out.name = m.name;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
return { role: "user", content: m.content };
|
||||
});
|
||||
const normalized = messages.map((message) => buildOpenAIConversationMessage(message));
|
||||
|
||||
return [{ role: "system", content: CHAT_TOOL_SYSTEM_PROMPT }, ...normalized];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user