Matterway
    Preparing search index...

    Function askFile

    • Processes a file by running OCR on supported file types (PDF or image) and then extracting a question based on a prompt. For other file types, the file’s content is sent directly to the AI helper.

      Parameters

      • ctx: Context

        The context object

      • file: MwFile

        The SDK file to be processed.

      • options: AskFileOptions

        Options including the prompt, OCR configuration (if needed), and any AI options such as provider, model, and config.

      Returns Promise<
          | { object: unknown; text?: undefined }
          | { object?: undefined; text: string },
      >

      A promise resolving to the AI response.

      const response = await askFile(ctx, file, {
      prompt: 'What is the main question in this document?',
      provider: SkillSecretType.OpenAi,
      config: { openAiApiKey: 'your-api-key' },
      model: 'gpt-4o-mini',
      ocrOptions: {
      endpoint: 'https://{YOUR_ENDPOINT}.cognitiveservices.azure.com/',
      key: 'YOUR_OCR_KEY'
      }
      });
      console.log(response.text);