当我使用GPT3的playground时,我经常得到带有编号列表和段落格式的结果,如下所示:
Here's what the above class is doing:
1. It creates a directory for the log file if it doesn't exist.
2. It checks that the log file is newline-terminated.
3. It writes a newline-terminated JSON object to the log file.
4. It reads the log file and returns a dictionary with the following
- list 1
- list 2
- list 3
- list 4
然而,当我直接使用他们的API并从json result中提取响应时,我得到的是非常难以阅读的填鸭式文本版本,如下所示:
Here's what the above class is doing:1. It creates a directory for the log file if it doesn't exist.2. It checks that the log file is newline-terminated.3. It writes a newline-terminated JSON object to the log file.4. It reads the log file and returns a dictionary with the following-list 1-list 2-list 3- list4
我的问题是,人们如何保持GPT结果的格式,使它们以更整洁,更可读的方式显示?
2条答案
按热度按时间xqkwcwgp1#
选项一:Edits endpoint
如果运行
test.py
,OpenAI API将返回以下完成:test.py
选项二:加工
自己处理从Completions endpoint得到的补全(即编写Python代码)。
tzcvj98z2#
最好的答案是提供一个你想要的输出的例子。例子中的数据并不重要,只要显示你想要的结构就行了。