- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
GPT-3 很棒,但是解析它的结果有点头疼,或者我在这里遗漏了什么?例如,我要求 GPT-3 写一些关于“数字营销”的东西,它返回了一些有趣的东西:
\n\n1. Topic: The Benefits of Digital Marketing \nHeadlines: \na. Unlocking the
Potential of Digital Marketing \nb. Harnessing the Power of Digital Marketing for
Your Business \nc. How to Maximize Your Return on Investment with Digital Marketing
\nd. Exploring the Benefits of a Comprehensive Digital Marketing Strategy \ne.
Leveraging Technology to Take Your Business to the Next Level with Digital Marketing
\n\n2. Topic: Social Media Strategies for Effective Digital Marketing \nHeadlines:
\na. Crafting an Engaging Social Media Presence for Maximum Impact \nb. How to Reach
and Engage Your Target Audience Through Social Media Platforms \nc. Optimizing Your
Content Strategy for Maximum Reach on Social Media Platforms \nd. Utilizing Paid
Advertising Strategies on Social Media Platforms \t\t\t\t\t\t\t e .Analyzing
and Improving Performance Across Multiple Social Networks\n\n3. Topic: SEO Best
Practices for Effective Digital Marketing Headlines: a .Understanding Search
Engine Algorithms and Optimizing Content Accordingly b .Developing an Effective
SEO Strategy That Delivers Results c .Leveraging Keywords and Metadata For Maximum
Visibility d .Exploring Advanced SEO Techniques To Increase Traffic e .Analyzing
Performance Data To Improve Rankings\n\n4Topic : Email Campaigns For Successful
Digital Marketin g Headlines : a .Creating Compelling Email Campaigns That Drive
Results b .Optimizing Email Deliverability For Maximum Impact c .Utilizing Automation
Tools To Streamline Email Campaign Management d .Measuring Performance And Analyzing
Data From Email Campaigns e .Exploring Creative Ways To Increase Open Rates On
Emails\n\n5Topic : Mobile Advertising Strategies For Effective Digita l Marketin g
Headlines : a ..Maximizing Reach With Mobile Ads b ..Understanding User Behavior On
Mobile Devices c ..Optimizing Ads For Different Screen Sizes d ..Leveraging Location-
Based Targeting To Increase Relevance e ..Analyzing Performance Data From Mobile Ads
如您所见,它向我发回了与“数字营销”相关的主题列表以及一些标题(显然是从 a 到 e)。我在这里和那里看到一些换行符和表格。所以我的第一个 react 是在换行符处拆分文本,但看起来格式并不是到处都是一样的,因为响应的后半部分很少有换行符(这使得它不准确)。我想做的是重新格式化输出,这样我就可以得到一种主题和标题列表。像这样:
[
{"Topic 1": ["headline 1", "headline 2","..."]},
{"Topic 2": ["headline 1", "headline 2","..."]},
{"Topic 3": ["headline 1", "headline 2","..."]}
]
也许有一个参数可以随我的请求一起发送,但我没有在文档中找到任何内容。所以我想我最好的选择是使用 regex
重新格式化。在这里,我看到了 Topic:
和 Headlines:
模式,但情况并非总是如此。一致的是每个元素前面的数字 (如 Ì., II., 1., 2. 或 a., b.)
但有时它看起来像 a ..
(例如,您可以在响应末尾看到它。
知道怎么做吗? (我为此使用 python,但可以从另一种语言改编)
最佳答案
如果您运行 test.py
,OpenAI API 将返回以下完成信息:
1. Topic: The Benefits of Digital Marketing
Headlines:
* Unlocking the Potential of Digital Marketing
* Harnessing the Power of Digital Marketing for Your Business
* How to Maximize Your Return on Investment with Digital Marketing
* Exploring the Benefits of a Comprehensive Digital Marketing Strategy
* Leveraging Technology to Take Your Business to the Next Level with Digital Marketing
测试.py
import openai
openai.api_key = '<OPENAI_API_KEY>'
response = openai.Edit.create(
model = 'text-davinci-edit-001',
input = '\n\n1. Topic: The Benefits of Digital Marketing \nHeadlines: \na. Unlocking the Potential of Digital Marketing \nb. Harnessing the Power of Digital Marketing for Your Business \nc. How to Maximize Your Return on Investment with Digital Marketing \nd. Exploring the Benefits of a Comprehensive Digital Marketing Strategy \ne. Leveraging Technology to Take Your Business to the Next Level with Digital Marketing',
instruction = 'Make this readable'
)
content = response['choices'][0]['text']
print(content)
关于python - OpenAI GPT-3 API : How to parse the response into an ordered list or dictionary?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75429596/
我收到以下错误:模块“openai”没有属性“ChatCompletion” 我检查了其他帖子。都在说升级OpenAI Python包或者升级Python。我都做了,但没有修复它。 Python:3.
我收到以下错误:模块“openai”没有属性“ChatCompletion” 我检查了其他帖子。都在说升级OpenAI Python包或者升级Python。我都做了,但没有修复它。 Python:3.
我有一个用例,非常需要来自 OpenAI API 的完全确定性响应。然而,玩弄温度似乎无法产生完全的决定论。 import openai openai.organization = "org-..."
OpenAI api 包含一个微调服务,将任务分为“提示”和“完成” https://platform.openai.com/docs/guides/fine-tuning 文档说准确度指标是根据完成
我通过openai的text-davinci-003可以正常返回对话信息,但是目前无法实现上下文关联功能。我搜索了一下,发现有一个“conversation_id”参数,但是添加该参数后,API返回“
我有一个用例,非常需要来自 OpenAI API 的完全确定性响应。然而,玩弄温度似乎无法产生完全的决定论。 import openai openai.organization = "org-..."
OpenAI api 包含一个微调服务,将任务分为“提示”和“完成” https://platform.openai.com/docs/guides/fine-tuning 文档说准确度指标是根据完成
我通过openai的text-davinci-003可以正常返回对话信息,但是目前无法实现上下文关联功能。我搜索了一下,发现有一个“conversation_id”参数,但是添加该参数后,API返回“
我想使用 openai.embeddings_utils import get_embeddings所以已经安装了openai Name: openai Version: 0.26.5 Summary
当我使用 GPT3 的 playground 时,我经常得到带有编号列表和段落格式的结果,如下所示: Here's what the above class is doing: 1. It creat
当我使用 GPT3 的 playground 时,我经常得到带有编号列表和段落格式的结果,如下所示: Here's what the above class is doing: 1. It creat
我想使用 openai.embeddings_utils import get_embeddings所以已经安装了openai Name: openai Version: 0.26.5 Summary
OpenAI/chat GPT也支持docx/pdf文件上传吗?。我想上传多个文件到openAI/chatGPT。我在https://platform.openai.com/docs/api-refe
openAI/chatGPT也支持docx/pdf文件上传吗? 我想上传多个文件到 openAI/chatGPT。我尝试了 https://platform.openai.com/docs/api-r
openAI/chatGPT也支持docx/pdf文件上传吗? 我想上传多个文件到 openAI/chatGPT。我尝试了 https://platform.openai.com/docs/api-r
如果我们查看环境的预览,它们会在右下角的动画中显示剧集的增加。 https://gym.openai.com/envs/CartPole-v1/ .是否有明确显示的命令? 最佳答案 我认为 Ope
是否有人从使用 text-embedding-ada-002 的 Azure OpenAI 嵌入部署中获得的结果与 OpenAI 的结果不同?相同的文本,相同的模型,结果在向量空间中相差相当远。 对于
关闭。这个问题需要debugging details .它目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and th
我正在学习gpt微调 我成功运行了这个命令:pip install --upgrade openai 我无法运行此命令:export OPENAI_API_KEY="sk-xxxxxxxxxxxxxx
如何解决Openai API 不断输出的问题,比如让gpt api 写一篇文章。如果内容中断,可以继续提问,从而继续输出以上内容。这在ChatGPT中很容易做到,但是Openai API加上上面的提示
我是一名优秀的程序员,十分优秀!