xsAI v0.2 is now available! Read Announcement
xsAI0.2.0
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'
    },
  ],
  : 'deepseek-r1',
})
 
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'
    },
  ],
  : 'deepseek-r1',
})
 
const { ,  } = () 
Edit on GitHub

Last updated on

On this page