New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@pkgai/fetch-sse

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pkgai/fetch-sse

<!-- automd:badges color="orange" license licenseBranch bundlephobia packagephobia name="@pkgai/fetch-sse" -->

latest
Source
npmnpm
Version
0.0.3
Version published
Maintainers
0
Created
Source

@pkgai/fetch-sse

npm version npm downloads bundle size install size license

EventSource fetch 实现版

安装

# ✨ Auto-detect
npx nypm install @pkgai/fetch-sse

# npm
npm install @pkgai/fetch-sse

# yarn
yarn add @pkgai/fetch-sse

# pnpm
pnpm install @pkgai/fetch-sse

# bun
bun install @pkgai/fetch-sse

# deno
deno install @pkgai/fetch-sse

简单使用

import { fetch } from '@pkgai/fetch-sse'

const response = await fetch('https://openai-like/v1/chat/completions',{
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    Authorization: 'Bearer {API_KEY}',
  },
  body: JSON.stringify({
    model: 'qwq-32b',
    messages: [
      {
        role: 'user',
        content: '9.9和9.11谁大',
      },
    ],
    stream: true,
    stream_options: {
      include_usage: true,
    },
  })
})

for await (const chunk of response) {
  console.log(chunk)
  // data: 
  console.log(chunk.data)
  // event:
  console.log(chunk.event)
}

贡献者

Published under the MIT license. Made by @Colourlessglow and community 💛

🤖 auto updated with automd

Keywords

event-source

FAQs

Package last updated on 18 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts