Hello there, I read the docs and ref many times and i realized the Completions API are limited for certain models, and as the docs said We generally recommend that you use either gpt-4 or gpt-3.5-turbo
I'm trying to use the chat completion API for putting prompt into the content param but failed for invaild content, I'll be appreciate if somebody could explain how it works
The code i wrote for Completions API (works)
def txt2report_openapi(ocr_result):
ocr_result_str = ''.join(ocr_result)
prompt = """I have a OCR'd report. It appears that there might be some formatting and OCR errors in the text,
and please convert it into the actual report , Omit those text that are not related to the report and omit those gross findings with measurement in sizes (such as cm)
\n The ocr'd content: """ + ocr_result_str,
res = client.completions.create(
model="text-davinci-003",
prompt=prompt,
max_tokens=2024,
temperature=0.1
)
print('txt2report_openapi: ' +
res.choices[0].text) # type: ignore
The code i wrote for Chat Completions API (works) ( failed for invaild content,open ai Error code: 400 - {'error': {'message': "'$.messages[1].content' is invalid)
def txt2report_openapi(ocr_result):
ocr_result_str = ''.join(ocr_result)
prompt = """I have a OCR'd report. It appears that there might be some formatting and OCR errors in the text,
and please convert it into the actual report , Omit those text that are not related to the report and omit those gross findings with measurement in sizes (such as cm)
\n The ocr'd content: """ + ocr_result_str,
res = client.chat.completions.create(
model="gpt-4-1106-preview",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": prompt}
]
)
print('txt2report_openapi: ' +
res.choices[0].text) # type: ignore
