memfreeme / memfree

MemFree - Hybrid AI Search Engine & AI UI Generator
https://www.memfree.me
MIT License
886 stars 133 forks source link

Auto generate the meaning title for the message use the AI #92

Open ahaapple opened 2 hours ago

ahaapple commented 2 hours ago

in the frontend/lib/tools/auto.ts

You can initiate a request to gpt-4o-mini to summarize user questions in parallel.

import { generateText } from 'ai';

const { text } = await generateText({
  model: yourModel,
  system:
    'You are a professional writer. ' +
    'You write simple, clear, and concise content.',
  prompt: `Summarize the following article in 3-5 sentences: ${article}`,
});

The summary title and answer can then be streamed back to the client

   await streamResponse({ sources: texts, title: title }, onStream);

Finally, when savingMessages, also pass in the AI ​​generated title

      await saveMessages(userId, messages, fullAnswer, texts, images, videos, fullRelated);
github-actions[bot] commented 2 hours ago

Thank you for creating this issue! 🎉 We'll look into it as soon as possible. In the meantime, please make sure to provide all the necessary details and context. If you have any questions or additional information, feel free to add them here. Your contributions are highly appreciated! 😊

You can also check our CONTRIBUTING.md for guidelines on contributing to this project.