New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
InvalidRequestError: Invalid URL (POST /v1/engines/gpt-3.5-turbo/chat/completions)
#391
Comments
Hi @hemangjoshi37a, thanks for writing in. If I had to guess, it looks like you're trying to change an existing openai.Completion call to openai.ChatCompletion. There are a couple major differences:
Hpoe this helps! |
Same issue, trying to use text-ada-001.
|
Thanks for your insights. It seems there was a confusion with the OpenAI's GPT-3.5-turbo model's API usage. I was trying to use the To use the GPT-3.5-turbo model, I should indeed be utilizing the Here is the corrected version of my function: def classify_tokens_gpt3_5_turbo_multiple_parts(email_text: str) -> list:
# Define the system message
system_message = (
"Given the request for quotation email below, identify and classify the following information for each part: "
"email_Subject_Phrase, RFQ_number, Manufacturer_Part_Number, Qty_Required, Manufacturer_name, "
"Customer_Part_Number, Product_Description, Target_Price, Lead_Time_days, Date_Code, Packaging_Type, "
"Dispatch_Date, Comments, Currency, min_ord_qty, STD_PACK_QTY, SENDER_NAME, SENDER_POSITION, SENDER_COMPANY, SENDER_MOBILE, "
"SENDER_EMAIL, SENDER_ADDRESS, SENDER_COUNTRY, SENDER_PINCODE, SENDER_CITY, SENDER_STATE."
)
# Create the messages list
messages = [
{"role": "system", "content": system_message},
{"role": "user", "content": f"Email:\n{email_text}\n\n"}
]
# Call the GPT-3.5-turbo API
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=messages,
max_tokens=1024,
n=1,
temperature=0.1,
)
# Extract the generated answer from the API response
answer = response.choices[0].message['content'].strip()
print(f'{answer=}')
# Split the answer into a list of parts
parts = re.split(r'\n\s*\n', answer)
# Parse the individual parts into a list of dictionaries
classified_tokens_list = []
for part in parts:
classified_tokens = {}
for line in part.split('\n'):
if ':' in line:
key, value = line.split(':', 1)
classified_tokens[key.strip()] = value.strip()
classified_tokens_list.append(classified_tokens)
return classified_tokens_list Thanks for your patience and guidance on this matter. Best, |
Describe the bug
command :
ERROR :
To Reproduce
SEE THE DESCRIBE PART
Code snippets
OS
LINUX-UBUNTU-LATEST
Python version
PYTHON3.11
Library version
LATEST PYPI VERSION
The text was updated successfully, but these errors were encountered: