openai-api

AttributeError: module 'openai' has no attribute 'Embedding'

AttributeError: module 'openai' has no attribute 'Embedding' Question: According to OpenAi’s documentation and a large number of demonstrations I found online, the following code should run without a problem in Python: import openai response = openai.Embedding.create( input="porcine pals say", model="text-embedding-ada-002" ) However, when I run this code on my local Jupyter instance, I receive the …

Total answers: 1

Remembering the previous conversation of a chatbot

Remembering the previous conversation of a chatbot Question: I have created a basic ChatBot using OpenAI with the following code: import openai openai.api_key = "sk-xxx" while True: prompt = input("User:") response = openai.Completion.create( model="text-davinci-003", prompt=prompt, max_tokens=50, temperature=0, ) print(response.choices[0].text) This is the input and output: And in text form: User:What is python Python is a …

Total answers: 1

Ren'Py : ModuleNotFoundError: No module named 'netrc'

Ren'Py : ModuleNotFoundError: No module named 'netrc' Question: Trying to plug openai’s API to Ren’Py (to make characters answer to the player) I installed the openai python module in Ren’Py using this pip command : pip install –target /Users/…../GameName/game/python-packages netrc And then inside the game I use this to import the module (as expalined in …

Total answers: 3

OpenAI fine-tune with python return null model

OpenAI fine-tune with python return null model Question: I am trying to get fine-tune model from OpenAI GPT-3 using python with following code #upload training data upload_response = openai.File.create( file=open(file_name, "rb"), purpose=’fine-tune’ ) file_id = upload_response.id print(f’nupload training data respond:nn {upload_response}’) OpenAI respond with data { "bytes": 380, "created_at": 1675789714, "filename": "file", "id": "file-lKSQushd8eABcfiBVwhxBMOJ", "object": …

Total answers: 2

No module named 'openai_secret_manager'

No module named 'openai_secret_manager' Question: I asked ChatGPT about my CSV data, and ChatGPT answered: "Here is an example of how you can read a CSV file using pandas, and then use the data to train or fine-tune GPT-3 using the OpenAI API:" import pandas as pd import openai_secret_manager # Read the CSV file df …

Total answers: 2

OpenAI GPT-3 API error: "InvalidRequestError: Unrecognized request argument supplied"

OpenAI GPT-3 API error: "InvalidRequestError: Unrecognized request argument supplied" Question: import openai # Set the API key openai.api_key = "YOUR API KEY" # Define the conversation memory conversation_memory = { "previous_question": "What is the capital of France?", "previous_answer": "The capital of France is Paris." } # Make the API request response = openai.Completion.create( model="text-davinci-003", prompt="Where …

Total answers: 1

Setting Environment variables in .venv

Setting Environment variables in .venv Question: I am using .venv to create a virtual environment to use for a project. Within this project, I need to access the OpenAI GPT3 environment. For this, i have an API key, but I want to store it as an environment variable. Because I use windows and VS-Code to …

Total answers: 3

How to work with OpenAI maximum context length is 2049 tokens?

How to work with OpenAI maximum context length is 2049 tokens? Question: I’d like to send the text from various PDF’s to OpenAI’s API. Specifically the Summarize for a 2nd grader or the TL;DR summarization API’s. I can extract the text from PDF’s using PyMuPDF and prepare the OpenAI prompt. Question: How best to prepare …

Total answers: 2