Giter Club home page Giter Club logo

openai-fetch's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

openai-fetch's Issues

No methods for calling the model endpoint ?

Thanks for this API wrapper !

Calls to the model endpoint (i.e. call GET https://api.openai.com/v1/models) is not included in this wrapper.

It's not critical, but could be nice (type safety and error management).

which npm package ? What is @bytemain/openai-fetch ?

Wanted to run API calls from edge, and had to find fetch-based client.

Stumbled upon this repo, but when searching npmjs.org, I found 2 packages pointing to this repo: openai-fetch and @bytemain/openai-fetch. Found this a bit strange/questioning.

Production ready?

Nice!

Can this be relied upon for production, or might anything break it at the openai end?

Thanks

Request with a Request object that has already been used (Next.js 13)

Capture 2023-01-09 - 000687

Seeing the following error when trying to load an Open AI completion from a Next.js 13 page (server component).

import createOpenAiClient from '~/lib/openai';

async function getData() {
  const data = await createOpenAiClient().createCompletion({
    prompt: `List some cool objects in a room`,
    model: 'text-curie-001',
    temperature: 0,
    frequency_penalty: 0.1,
    max_tokens: 256,
  });

  console.log(JSON.stringify(data.response, null, 2));

  return data.completion;
}

export default async function Page() {
  const response = await getData();

To create the client, I originally used the code cited in the README. However, after seeing this error, I tried to create the client on-demand:

import { OpenAIClient } from 'openai-fetch';

function createOpenAiClient() {
  return new OpenAIClient({ apiKey: process.env.OPENAI_API_KEY });
}

export default createOpenAiClient;

But to no avail.

I noticed you're using ky. A cursory search yielded a seemingly related issue: sindresorhus/ky#479

Add support for fine tune model apis

Currently, the library doesn't support any interaction with fine tunings.

The following is a list of wanted methods to be included:

  • retrieveFineTune
  • listFineTunes
  • createFineTune
  • cancelFineTune
  • listFineTuneEvents

Thanks for your efforts.

The official openai package no longer uses axios

The README on this project says this:

Unfortunately, the official openai-node uses Axios, which only supports Node and is bloated.

Reasons to consider using openai-fetch:
Supports all envs with native fetch: Node 18+, browsers, Deno, Cloudflare Workers, etc

As of https://github.com/openai/openai-node/releases/tag/v4.0.0, openai uses the native fetch by default in Deno, Cloudflare workers, etc. It does use node-fetch in Node 18+, though may be moving to undici there soon.

The package download size stats may have changed as well, though most of the size of the official package is types, sourcemaps, etc which aren't imported at runtime. The runtime impact is usually around 25kb (still larger than this package).

Please can you elaborate more on this phrase in readme?

Please can you elaborate more on this phrase in readme?

Unfortunately, the official [openai-node](https://github.com/openai/openai-node) uses Axios, which only supports Node and is bloated.

I got curious why you say that the axios and nodejs client is "bloated"

Uncaught (in promise) ReferenceError: process is not defined

Hi, first of all, thanks for great lib

These lines would cause an error in environments where process is not available (ex. Cloudflare or browsers) in case if apiKey or organizationId is not specified

Error I get when trying to run in Cloudflare worker

โœ˜ [ERROR] Uncaught (in promise) ReferenceError: process is not defined

  const organizationId = opts.organizationId || process.env.OPENAI_ORG_ID;
                                                ^
      at OpenAIClient
  (/root/dev/app/node_modules/openai-fetch/src/openai-client.ts:62:50)
      at fetch (/root/dev/app/src/worker.ts:32:17)

As lib claims it supports all environments, including browsers, process should not be used as fallback

add option to pass fetch lib as argument

Is it possible to extend API configuration to pass a specific fetch library?

It might solve some issues related to the different hosting environments.

something like that:

const client = new OpenAIClient({ apiKey: '<your api key>', fetch: myFetch });

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.