xsAI v0.3 "future base" is now available! Read Announcement
xsAI0.4.0-beta.1
Utils

Reasoning

install sizeminified sizeminzipped size
npm i @xsai/utils-reasoning

Examples

extractReasoning

extracts XML-tagged reasoning sections from text.

import {  } from '@xsai/generate-text'
import {  } from '@xsai/utils-reasoning'
import {  } from 'node:process'

const { :  } = await ({
  : 'http://localhost:11434/v1/',
  : [
    {
      : 'You\'re a helpful assistant.',
      : 'system'
    },
    {
      : 'Why is the sky blue?',
      : 'user'
    },
  ],
  : 'qwen3',
})

const { ,  } = (!) 

extractReasoningStream

extracts XML-tagged reasoning sections from text stream.

import {  } from '@xsai/stream-text'
import {  } from '@xsai/utils-reasoning'
import {  } from 'node:process'

const { :  } = await ({
  : 'http://localhost:11434/v1/',
  : [
    {
      : 'You\'re a helpful assistant.',
      : 'system'
    },
    {
      : 'Why is the sky blue?',
      : 'user'
    },
  ],
  : 'qwen3',
})

const { ,  } = ()