-
Notifications
You must be signed in to change notification settings - Fork 86
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
Question: dealing with duplicate named objects #548
Comments
Your data do not seem to be correctly coded. Try:
json-fortran should be able to build its tree. |
Thanks for your reply.
That is an example of a response from the OpenAI API. |
While duplicated keys are not prohibited in JSON, you still need to quote keys and put commas to separate objects. I took a brief look at ForOpenAI's documentation, but I couldn't find a procedure that returns json-formatted result. Are you sure that ForOpenAI is supposed to give you JSON data? |
There is never enough time to improve documentation;). The documentation is very basic, automatically generated using FORD. If you have an OpenAI API key and want to test it:
The problem is I can't modify the response from OpenAI. I have to somehow deserialize it. Now I don't even know if that response in the above format is a JSON standard or if json-fortran is unable to read it. |
Sorry, I misunderstood your situation. I was not aware that you were the author of ForOpenAI. While I don't have time to try your work, I made a quick experiment with chatgpt. I visited chatgpt.com and entered a question: Can you list good asian grocery markets in manhattan island. Give me your answer in the JSON format. ChatGPT's answer was
This output is syntactically valid. Also, I found the following subsection in the chat section of the ChatGPT document. The italicized parts might be of some use for you. response_format Optional Setting to { "type": "json_object" } enables JSON mode, which guarantees the message the model generates is valid JSON. Important: when using JSON mode, you must also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if finish_reason="length", which indicates the generation exceeded max_tokens or the conversation exceeded the max context length. |
Your foropenapi.json has no "response_format" in the "CharCompletion" section. I am wondering if it has something to do with the problem you described. (Well, I know very little about ChatGTP. :-) ) When I added By the way, json-fortran is very good at detecting syntactical errors in JSON data and giving informative error messages. It is probably next to impossibility that it deserializes malformed JSON data. You might want to resolve your issue with ChatGPT or its community. Good luck! |
So... I'm not sure what is being asked here. The original question included text that was not valid JSON, so json-fortran is not going to be able to parse that. Not sure what else to say about that. |
Hi @jacobwilliams,
I'm currently using json-fortran in the ForOpenAI project. I've encountered a situation where I receive a single string in the following format that contains multiple objects with the same name, 'data':
Usually, when dealing with a single JSON object and without the object name 'data', json-fortran is easily usable:
However, I am uncertain whether json-fortran supports extracting content from multiple 'data' objects in this format. Could you please provide guidance or suggestions on how to handle this scenario using json-fortran?
Thank you,
Ali
The text was updated successfully, but these errors were encountered: