Prompting for Raw Data
Request a Specific Format: Start by clearly instructing ChatGPT to provide the information in a raw format.
JSON: To get structured data, ask, "Provide the following information in a well-formed JSON format".
Plain Text: For simpler, unformatted text, ask, "Please output the following as plain text, without any markdown or special formatting".
Custom Format: You can even define a custom structure by providing an example of the desired output format in your prompt.
Extracting the Data
1. Using the API:
If you are using the OpenAI API, you can use the with_raw_response method with the client.chat.completions object to get the raw API response, which can then be processed, according to the OpenAI Developer Community.
2. Using Code to Parse:
The most efficient way to get raw data is to use code.
In Python: Use the json library to parse a JSON-formatted response. For raw text, you can split the response by lines and remove extraneous characters.
Frameworks: Libraries like LangChain can automate the process of breaking down inputs, generating sections, and stitching together the final raw data.