Generative & RagRag With Generative Search

RAG With Generative Search

Unbody gives you various ways to perform RAG - from generating insights from single documents to analyzing multiple sources at once.

Generate from every single document

When you need AI-generated insights from a specific document, use .generate.fromOne(). For example, create quick summaries from PDF files with direct references to the content.

const {
  data: { payload }
} = await unbody.get
                .textDocument
                .where({ mimeType: "application/pdf" })
                .generate.fromOne("Summarize this: {text}")
                .select("title", "originalName")
                .exec();

Generate from every single document with options

Fine-tune your generated content by adding parameters to .generate.fromOne(). Adjust creativity levels, response length, and other settings to get exactly the output you need. Learn more about options.

const {
  data: { payload }
} = await unbody.get
                .textDocument
                .where({ mimeType: "text/markdown" })
                .generate.fromOne({
                  prompt: "Create a short report for these: {text}",
                  options: {
                    model: "gpt-4",
                    topP: 0.7,
                    maxTokens: 1000,
                    temperature: 0.7,
                    presencePenalty: 0,
                    frequencyPenalty: 0
                  }
                })
                .select("originalName")
                .exec();

Generate from multiple documents

Have information spread across several documents? You can combine specific fields from multiple sources to create a unified summary or analysis by using .generate.fromMany().

const {
  data: { payload }
} = await unbody.get
                .textDocument
                .generate.fromMany("Create a 100 words summary:", ["text", "title"])
                .select("title", "originalName")
                .exec();

Generate from multiple documents with options

When you need both multi-document analysis and precise output control, use advanced multi-document generation with options. This combines document properties while letting you fine-tune the AI’s response.

const {
  data: { payload }
} = await unbody.get
                .textDocument
                .where({ mimeType: "text/markdown" })
                .generate.fromMany({
                  task: "Write a short report based on these topics:",
                  properties: ["title", "text", "tags"],
                  options: {
                    model: "gpt-4",
                    topP: 0.7,
                    maxTokens: 1000,
                    temperature: 0.7,
                    presencePenalty: 0,
                    frequencyPenalty: 0
                  }
                })
                .select("originalName", "title")
                .exec();

Learn more about generative search in detail in our Generative Search Guide.

©2024 Unbody