At first, I’m sorry that I cannot share the prompt messages I used for the input.
For some prompts, the contents of response only consists of lot’s of spaces and new lines. It doesn’t happens everytime, but sometimes without control.
Q1. Why is this happens
Q2. How to prevent from this situation?
I’m trying to build a Python script to feed information to chatGPT using the following script
from openai import OpenAI
Blockquote
from openai import OpenAI
client = OpenAI()
response = client.chat.completions.create(
model=“gpt-3.5-turbo-0125”,
response_format={ “type”: “json_object” },
messages=[{“role”: “system”, “content”: “You are a young and intelligent software engineer assigned to the task to identify ambiguities in the system requirements JSON”},
{“role”: “user”, “content”: “Identify ambiguities in the following software requirement”},
{“role”: “user”, “content”: “Once borrower clicks on the Payment Request link sent to their email address we need to retrieve the Payment Request Information and return it to the borrower.”}],
temperature=1,
top_p=1
)
print(response)
We are experiencing the same problem - 5-10 times a day this one specific prompt (running on gpt-4-turbo-preview) will return a table header, then 20-70kB of whitespace. Already deployed code to check for that scenario and rerun (most of the time it is fine on rerun)
Sometimes at the end will be some repeating mandarin characters too!
Try adding the assistant’s response in between your user messages.
This gives me a sane output:
usemodel="gpt-3.5-turbo-0125"
client = OpenAI()
response = client.chat.completions.create(
model=usemodel,
response_format={ "type": "json_object" },
messages=[{"role": "system", "content": "You are a young and intelligent software engineer assigned to the task to identify ambiguities in the system requirements and output it in JSON"},
{"role": "user", "content": "Identify ambiguities in the following software requirement"},
{"role": "assistant", "content": "To help you identify ambiguities, I'll need to see the specific software requirement you're referring to. Could you please provide the requirement text?"},
{"role": "user", "content": "Once borrower clicks on the Payment Request link sent to their email address we need to retrieve the Payment Request Information and return it to the borrower."}],
temperature=1,
top_p=1
)
print(response)
[{‘role’: ‘system’, ‘content’: ‘I want you to create a simple AWS Athena queries query based on my query and remember you have to always create sql query to fetch correct data from database and always limit data length to 10000 rows and whenever year is provided in the table fetch it in query ,Also make accurate queries using your memory\r\n \r\n### Rules to Follow:\r\n \r\n0. Do not use Distinct anytime and Avoid Over-Filtering with NULL Checks:\r\n1 do not do calculation like percentages,total or any others even if asked just provide me the data I will do calculations by my own\r\n2 Ensure you do not use COUNT(*) when calculating percentages, as it includes all rows instead of just the relevant subset, leading to inaccurate results.\r\n3 Always try to accumulate all the years for same data and try to get year if present in data unless users specify \r\n4 Whenever using a WHERE condition, always use lower() for string-type values to ensure case-insensitive matching.\r\n5 Always use aggregate queries with the GROUP BY clause whenever aggregating values. \r\n6 When creating aggregate queries with a GROUP BY clause, ensure that any non-aggregate fields present in the SELECT or ORDER BY clauses are also included in the GROUP BY clause to avoid aggregation errors.\r\n7 When using an ORDER BY clause in a query that contains aggregation (SUM, COUNT, etc.), ensure that any fields used for ordering are also included in the GROUP BY clause if they are not part of an aggregate function\r\n8 Do not include any column in the GROUP BY clause if it is not available in the SELECT or ORDER BY clauses.\r\n9 Try to get column important columns along which could be useful to understand data\r\n10 Whenever using a WHERE condition, always use lower() for string-type values to ensure case-insensitive matching.\r\n11 Always include the years. never leave out “fiscal_year” [string]\r\n12 Always Include year, fiscal_year, and term columns in SELECT only when available in the table information. If another date column is available, bring that column instead.\r\n13. use joins when more than two tables are given to you\r\n \r\n \r\nUSE BELOW TABLE\n\n"table_name is 'field_of_study' and columns are 'country' [string], 'business_mgmt' [double], 'education' [double], 'engineering' [double], 'fine_applied_arts' [double], 'health_professions' [double], 'humanities' [double], 'intensive_english' [double], 'math_computer_science' [double], 'physical_life_sciences' [double], 'social_sciences' [double], 'other_fields_of_study' [double], 'undeclared' [double], 'countrycode' [string], 'continent' [string], 'continentcode' [string], 'sub_continent' [string], 'sub_continentcode' [string], 'fiscal_year' [string].'\n'Instruction for this table':\n'1. this table includes data by percentages NOT scores of students from the top 25 leading countries, keep as percentages using 'fiscal_year', \n2. 'business_mgmt' or 'education' or 'engineering' or 'fine_applied_arts' or 'health_professions' or 'humanities' or 'intensive_english' or 'math_computer_science' or 'physical_life_sciences' or 'social_sciences' or 'other_fields_of_study' or 'undeclared' are percentages."\n\nImportant \n\n Always provide me Output in json format with key name 'query'’}, {‘role’: ‘user’, ‘content’: ‘what are some recruitment strategy for Vietnam’}, {‘role’: ‘assistant’, ‘content’: ‘sql query’}, {‘role’: ‘user’, ‘content’: ‘what are some recruitment strategy for Vietnam’}]