Skip to content

Outdated examples #189

@wathika-eng

Description

@wathika-eng

I noticed in the JavaScript docs, some references e.g PdfParser example is outdated:

Page: https://genkit.dev/docs/rag/#define-your-indexer-flow

This will cause a bug:

"error": "Please provide binary data as `Uint8Array`, rather than `Buffer`."

A fix for it:

export async function extractTextFromPdf(filePath: string) {
  if (filePath.trim() === '') {
    throw new Error('File path cannot be empty');
  }
  const pdfFile = path.resolve(filePath);

  const buffer = await fs.readFile(pdfFile); // Buffer
  const uint8Array = new Uint8Array(buffer); // real Uint8Array

  const data = await new PDFParse(uint8Array);
  return data.getText();
}

Also I couldn't find the .chat method on the AI: https://genkit.dev/docs/tutorials/chat-with-pdf/#6-implement-the-ui

Image

Also in Go, maybe you might consider adding import _ "github.com/joho/godotenv/autoload" so as to autoload the .env variable key, https://genkit.dev/docs/get-started/?lang=go#create-your-first-application

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions