Home/Tools/@tpmjs/tools-faq-from-text

faqFromTextTool

@tpmjs/tools-faq-from-text

Extract Q&A pairs from text that looks like FAQ format. Detects question patterns (?, "Q:", "Question:", numbered questions, etc.) and pairs them with their answers. Returns an array of FAQ objects with question and answer fields.

Official
doc
v0.2.0
MIT

Interactive Playground

Test @tpmjs/tools-faq-from-text (faqFromTextTool) with AI-powered execution

0/2000 characters

Installation & Usage

Install this tool and use it with the AI SDK

1. Install the package

npm install @tpmjs/tools-faq-from-text
pnpm add @tpmjs/tools-faq-from-text
yarn add @tpmjs/tools-faq-from-text
bun add @tpmjs/tools-faq-from-text
deno add npm:@tpmjs/tools-faq-from-text

2. Import the tool

import { faqFromTextTool } from '@tpmjs/tools-faq-from-text';

3. Use with AI SDK

import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { faqFromTextTool } from '@tpmjs/tools-faq-from-text';

const result = await generateText({
  model: openai('gpt-4o'),
  tools: { faqFromTextTool },
  prompt: 'Your prompt here...',
});

console.log(result.text);

Parameters

Available configuration options

Auto-extracted
text
Required
Type: string

Text containing FAQ-style content with questions and answers

Schema extracted: 1/1/2026, 8:18:12 AM

README

@tpmjs/tools-faq-from-text

Extract Q&A pairs from text that looks like FAQ format. Detects question patterns and pairs them with their answers.

Installation

npm install @tpmjs/tools-faq-from-text ai

Usage

import { faqFromTextTool } from '@tpmjs/tools-faq-from-text';

const result = await faqFromTextTool.execute({
  text: `
    Q: What is TPMJS?
    A: TPMJS is a package manager for AI tools.

    Q: How do I install it?
    A: Run npm install @tpmjs/core

    Question: Is it free?
    Answer: Yes, it's open source and free to use.
  `,
});

console.log(result);
// {
//   faqs: [
//     { question: "What is TPMJS?", answer: "TPMJS is a package manager for AI tools." },
//     { question: "How do I install it?", answer: "Run npm install @tpmjs/core" },
//     { question: "Is it free?", answer: "Yes, it's open source and free to use." }
//   ],
//   count: 3
// }

Features

  • Detects multiple question formats:
    • Questions ending with ?
    • Q: or Question: prefixes
    • Numbered questions (1., 1), etc.)
    • Common question words (What, Why, How, etc.)
  • Automatically pairs questions with their answers
  • Cleans up common prefixes (Q:, A:, numbers)
  • Filters out invalid pairs

Parameters

  • text (string, required) - Text containing FAQ-style content with questions and answers

Returns

{
  faqs: Array<{
    question: string;
    answer: string;
  }>;
  count: number;
}

Example Input Formats

The tool recognizes various FAQ formats:

Q: What is this?
A: This is an answer.

Question: Another question?
Answer: Another answer.

1. Numbered question?
   The answer follows.

What about bare questions?
They work too!

License

MIT

Statistics

Downloads/month

0

Quality Score

0%

Bundle Size

NPM Keywords

tpmjs
doc
ai
faq
documentation

Maintainers

thomasdavis(thomasalwyndavis@gmail.com)

Frameworks

vercel-ai