MCPcopy Create free account
hub / github.com/pollinations/pollinations / sendMessage

Function sendMessage

apps/chat/src/utils/api.js:289–493  ·  view source on GitHub ↗
(
    messages,
    onChunk,
    onComplete,
    onError,
    modelId,
    generationConfig = {},
)

Source from the content-addressed store, hash-verified

287};
288
289export const sendMessage = async (
290 messages,
291 onChunk,
292 onComplete,
293 onError,
294 modelId,
295 generationConfig = {},
296) => {
297 const selectedModelId = modelId || "openai-large";
298 const { maxTokens = 2000, temperature = 0.7, topP = 1 } = generationConfig;
299 const isClaude = selectedModelId.includes("claude");
300 const finalTemperature = isClaude ? 1 : temperature;
301 const chartRequested = containsChartRequest(messages);
302
303 const tools = [
304 {
305 type: "function",
306 function: {
307 name: "create_chart",
308 description:
309 "Create a chart or graph visualization from data points.",
310 parameters: {
311 type: "object",
312 properties: {
313 title: {
314 type: "string",
315 description: "Title displayed above the chart.",
316 },
317 data: {
318 type: "array",
319 items: { type: "object" },
320 description: "Array of data objects.",
321 },
322 series: {
323 type: "array",
324 items: {
325 type: "object",
326 properties: {
327 key: { type: "string" },
328 name: { type: "string" },
329 color: { type: "string" },
330 },
331 required: ["key", "name"],
332 },
333 },
334 xKey: { type: "string" },
335 xLabel: { type: "string" },
336 yLabel: { type: "string" },
337 },
338 required: ["title", "data", "series", "xKey"],
339 },
340 },
341 },
342 ];
343
344 try {
345 if (abortController) abortController.abort();
346 abortController = new AbortController();

Callers 2

testFunctionCallingFunction · 0.90
AppFunction · 0.90

Calls 14

containsChartRequestFunction · 0.85
formatMessagesForAPIFunction · 0.85
getApiTokenFunction · 0.85
onCompleteFunction · 0.85
stringifyMethod · 0.80
getReaderMethod · 0.80
popMethod · 0.80
sliceMethod · 0.80
parseMethod · 0.80
pushMethod · 0.80
parseApiErrorFunction · 0.70
abortMethod · 0.65

Tested by

no test coverage detected