当前位置: 首页 > news >正文

做网站公司推荐网站推广的案例

做网站公司推荐,网站推广的案例,wordpress自动同步,网站建设规划书主题文章目录 一. 提示词怎么写二. 完整代码三. 基于事实的prompt GPT-4和ChatGPT等LLM专用于生成文本。我们可以使用GPT-4和ChatGPT在各种场景中生成文本,举例如下。 电子邮件合同或正式文档创意写作逐步行动计划头脑风暴广告职位描述 对于本项目,我们将创建…

文章目录

    • 一. 提示词怎么写
    • 二. 完整代码
    • 三. 基于事实的prompt

GPT-4和ChatGPT等LLM专用于生成文本。我们可以使用GPT-4和ChatGPT在各种场景中生成文本,举例如下。

  • 电子邮件
  • 合同或正式文档
  • 创意写作
  • 逐步行动计划
  • 头脑风暴
  • 广告
  • 职位描述

对于本项目,我们将创建一个工具,它可以根据一系列事实生成新闻稿。我们可以根据目标媒体和受众选择新闻稿的篇幅、语调和风格。

一. 提示词怎么写

这里主要描述prompt(提示词)的构建逻辑,因为大模型可以根据prompt的规定生成符合要求的文档。

  1. 给AI模型分配一个角色,并尽可能精确地描述任务。如下给AI模型分配的角色是记者助手:
prompt_role = "You are an assistant for journalists. \Your task is to write articles, based on the FACTS that are \given to you. \You should respect the instructions: the TONE, the LENGTH, \and the STYLE"
  1. 其他规定
  • prompt_role:角色的描述,以便大模型能够按照角色回答
  • FACTS:基于给定的事实数据来回答
  • TONE:回答风格:这里是informal
  • LENGTH:回答的单词数
  • STYLE:生成的文本格式:这里是blogpost
# 拼装messages,规定了prompt的格式:  
# prompt_role:角色的描述,以便大模型能够按照角色回答  
# FACTS:基于给定的事实数据来回答  
# TONE:回答风格:这里是informal  
# LENGTH:回答的单词数  
# STYLE:生成的文本格式:这里是blogpost  
def assist_journalist(  facts: List[str], tone: str, length_words: int, style: str  
):  facts = ", ".join(facts)  prompt = f"{prompt_role} \  FACTS: {facts} \  TONE: {tone} \  LENGTH: {length_words} words \  STYLE: {style}"  return ask_chatgpt([{"role": "user", "content": prompt}])

 

二. 完整代码

import os  import openai  
from typing import List  openai.api_key = os.getenv('OPENAI_API_KEY')  # 调用openai api  
def ask_chatgpt(messages):  response = openai.ChatCompletion.create(  model="gpt-3.5-turbo", messages=messages  )  return response["choices"][0]["message"]["content"]  # prompt_role描述  
prompt_role = "You are an assistant for journalists. \  Your task is to write articles, based on the FACTS that are \  given to you. \  You should respect the instructions: the TONE, the LENGTH, \  and the STYLE"  # 拼装messages,规定了prompt的格式:  
# prompt_role:角色的描述,以便大模型能够按照角色回答  
# FACTS:基于给定的事实数据来回答  
# TONE:回答风格:这里是informal  
# LENGTH:回答的单词数  
# STYLE:生成的文本格式:这里是blogpost  
def assist_journalist(  facts: List[str], tone: str, length_words: int, style: str  
):  facts = ", ".join(facts)  prompt = f"{prompt_role} \  FACTS: {facts} \  TONE: {tone} \  LENGTH: {length_words} words \  STYLE: {style}"  return ask_chatgpt([{"role": "user", "content": prompt}])  print(  assist_journalist(  ["The sky is blue", "The grass is green"], "informal", \  100, "blogpost"  )  
)

 

输出如下


"Hey, everyone! Did you know that the sky is blue and the grass is green?
I mean, it's something we see every day and probably take for granted,
but it's still pretty amazing if you think about it! The sky appears
blue to us because of something called Rayleigh scattering – basically,
the molecules in the Earth's atmosphere scatter sunlight in all different
directions. Blue light has a shorter wavelength, so it gets scattered
more than the other colors in the spectrum. That's why the sky looks
blue most of the time! As for the grass being green... that's due to
chlorophyll, the pigment that helps plants capture sunlight to make
their food. Chlorophyll absorbs red and blue light, but reflects
green light, which is why we see plants as green.It's pretty cool how science explains these things we take for granted,
don't you think? Next time you're outside, take a moment to appreciate
the color palette around you!"

 

三. 基于事实的prompt

通过明确facts数据,让GPT基于事实来回答。

print(assist_journalist(# 这里让facts=["A book on ChatGPT has been published last week","The title is Developing Apps with GPT-4 and ChatGPT","The publisher is O'Reilly.",],tone="excited",length_words=50,style="news flash",)
)

结果如下:

Exciting news for tech enthusiasts! O'Reilly has just published a
new book on ChatGPT called "Developing Apps with GPT-4 and ChatGPT".
Get ready to delve into the world of artificial intelligence and learn
how to develop apps using the latest technology. Don't miss out on this
opportunity to sharpen your skills!

 

http://www.khdw.cn/news/10568.html

相关文章:

  • 微信分销网站建设费用百度竞价推广出价技巧
  • 新疆网站域名注册培训方案怎么做
  • 年度网站信息化建设工作计划seo网站优化工具大全
  • 品牌网站建设小8a蝌蚪优化网站界面的工具
  • 网站建设需要学习哪些在线识别图片来源
  • 网站seo啥意思怎么做搭建网站平台
  • 大连住房和建设局网站seo 深圳
  • 12306网站是哪家公司做开发的百度排名工具
  • 邯郸网站建设的企业北京seo软件
  • 建设网站需要多长时间凡科网免费建站官网
  • jsp做的网站带数据库百度网站站长工具
  • 网络设计是什么工作正规seo关键词排名哪家专业
  • 用drupal做的网站网络黄页推广大全
  • 网站ns记录广州市新闻最新消息
  • ssh框架做的家政服务网站国内十大搜索引擎排名
  • 营销网站搭建考研培训班集训营
  • 中小企业网站提供了什么市场调研方案怎么写
  • 管理网站建设源代码程序电商网站策划
  • 洛阳建设厅网站百度推广竞价是什么意思
  • 小公司管理软件郑州关键词seo
  • 网站没有做适配 怎么办站外推广方式
  • 个人微信小程序开店福建网络seo关键词优化教程
  • 湛江电子商务网站建设平板电视seo优化关键词
  • 做网站推广的工作内容app下载
  • 软件开发用什么软件百度seo新算法
  • 怎么让网站被百度搜到优化网站的步骤
  • 北京建设网站去哪里找需要推广的app
  • 手机网站免费做app公司推广发帖网站怎么做
  • 前端web网站开发网页设计个人主页
  • 正规网站建设费用优化设计七年级上册语文答案