Questions tagged [openai-api]

OpenAI makes several AI products, including ChatGPT, Dall-E, Whisper. Use for questions about the OpenAI API, and not for general support.

Use for questions about using the OpenAI API. All question should be according to the scope of Stack Overflow and following the How to ask a good question and Expected Behavior guidelines.

Before asking a question, read the documentation.

If you will include non-original code, be sure to provide proper attribution.

Don't use for questions about using ChatGPT as an end-user. Don't use for questions about responses given by ChatGPT that aren't directly related to a programming issue using the OpenAI API.

Related tags:


OpenAI Community

https://community.openai.com/

1620 questions
6
votes
1 answer

OpenAI GPT-3 API: How to extend length of the TL;DR output?

I'd like to produce a 3-6 sentence summary from a 2-3 page article, using OpenAI's TLDR. I've pasted the article text but the output seems to stay between 1 and 2 sentences only.
psone
  • 95
  • 8
6
votes
9 answers

openai command not found (mac)

I'm trying to follow the fine tuning guide for Openai here. I ran: pip install --upgrade openai Which install without any errors. But even after restarting my terminal, i still get zsh: command not found: openai Here is the output of echo…
Nick
  • 1,864
  • 5
  • 27
  • 49
6
votes
4 answers

Issue with OpenAI API key while using it in Windows

I have to fine-tune the OpenAI model on my custom dataset. I have created the dataset in jsonl format. I use the following commands on windows command line: set OPENAI_API_KEY= openai tools fine_tunes.prepare_data -f "train_data.jsonl" The…
6
votes
3 answers

OpenAI API: How do I specify the maximum number of words a completion should return?

How can I specify the number of words the Open AI completion should return? E.g imagine I ask the AI the question Who is Elon Musk? What parameter can I use to make sure the AI sends back results less than or equal to 300 words? I was thinking the…
ololo
  • 1,326
  • 2
  • 14
  • 47
6
votes
1 answer

How can I use GPT 3 for my text classification?

I am wondering if I can be able to use OpenAI GPT-3 for transfer learning in a text classification problem? If so, how can I get start on it using Tensorflow, Keras.
5
votes
1 answer

define an output schema for a nested json in langchain

Whats the recommended way to define an output schema for a nested json, the method I use doesn't feel ideal. # adding to planner -> from langchain.experimental.plan_and_execute import load_chat_planner refinement_response_schemas = [ …
Zizi96
  • 459
  • 1
  • 6
  • 23
5
votes
1 answer

In LangChain, how to save the verbose output to a variable?

I tried executing a langchain agent. I want to save the output from verbose into a variable, but all I can access from the agent.run is only the final answer. How can I save the verbose output to a variable so that I can use later? My code: import…
Troyanovsky
  • 53
  • 1
  • 3
5
votes
1 answer

How to train ChatGPT with custom data

I want to create a chatbot on my website with ChatGPT. I have some pre-defined question-answers like the below: Question: What is the price of ...? Answer: $100 Question: How this help ..? Anwer: 1) Improve... 2) Better... 3) More... When the…
cyz3a5c0v1
  • 119
  • 1
  • 5
5
votes
1 answer

OpenAI api - asynchronous API calls

I work with the OpenAI API. I have extracted slides text from a PowerPoint presentation, and written a prompt for each slide. Now, I want to make asynchronous API calls, so that all the slides are processed at the same time. this is the code from…
DanielG
  • 217
  • 2
  • 6
5
votes
2 answers

How to incorporate context/chat history in OpenAI ChatBot using ChatGPT and langchain in Python?

Please bear with me as this is literally the first major code I have ever written and its for OpenAI's ChatGPT API. What I intend to do with this code is load a pdf document or a group of pdf documents. Then split them up so as to not use up my…
Ali Q
  • 51
  • 4
5
votes
1 answer

Stream a response from LangChain's OpenAI with Pyton Flask API

I am using Python Flask app for chat over data. So in the console I am getting streamable response directly from the OpenAI since I can enable streming with a flag streaming=True. The problem is, that I can't “forward” the stream or “show” the strem…
devZ
  • 606
  • 1
  • 7
  • 23
5
votes
1 answer

OpenAI Completion Stream with Node.js and Express.js

I'm trying to build a ChatGPT website clone and now I need to make the stream completion effect that shows the result word-per-word. My server is a TypeScript Node.js app that uses the Express.js framework. Here's the route: import express, {…
Alexxino
  • 557
  • 2
  • 16
5
votes
0 answers

How to use StuffDocumentsChain with ConversationChain in LangChain?

I want to use StuffDocumentsChain but with behaviour of ConversationChain the suggested example in the documentation doesn't work as I want: import fs from 'fs'; import path from 'path'; import { OpenAI } from "langchain/llms/openai"; import {…
Arsenius
  • 4,972
  • 4
  • 26
  • 39
5
votes
2 answers

is there any way to stream response word by word of chatgpt api directly in react native (with javascript)

I want to use Chat GPT Turbo api directly in react native (expo) with word by word stream here is working example without stream fetch(`https://api.openai.com/v1/chat/completions`, { body: JSON.stringify({ model: 'gpt-3.5-turbo', …
Ibad Ur Rehman
  • 696
  • 1
  • 9
  • 16
5
votes
2 answers

How to get token usage for each openAI ChatCompletion API call in streaming mode?

According to openAI's documentation, https://platform.openai.com/docs/guides/chat/chat-vs-completions you should get token usage from the response. However, I am currently working making the API call with stream set to True. The response doesn't…
user2501096
  • 91
  • 1
  • 3