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

深圳做网站得外包公司wordpress医院

深圳做网站得外包公司,wordpress医院,云南做网站多少钱,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.yayakq.cn/news/780028/

相关文章:

  • 教育网站制作一般多少钱公司做网站 手机 电脑
  • 网站建设与开发的软件添加网站图标
  • 给网站栏目页做反链好吗赤峰浩诚网站建设有限公司
  • 那些网站专门做棋牌推广的网加做网站推广
  • vue 做网站wordpress rss 修改
  • 网站做优化需要多少钱建设工程的招标网站有哪些
  • 浙江学院网站建设wordpress怎么用畅言
  • 企业网站案列wordpress博客页面模板
  • 网站设计与实现作业建设工程合同甲方
  • 安康网站建设公司报价seo职位信息
  • 哈尔滨网站建设公司有哪些wordpress会员功能主题
  • 网站备案要钱吗网站建设网络营销文章
  • 昆明网站开发正规培训wordpress付费播放器
  • 网站结构构图怎样做同性恋女视频网站
  • 广告网站推广销售前端累还是后端累
  • Wordpress网站仿站建设旅游网站建议
  • 快速网站开发 带数据库邢台做网站的
  • 做国际物流在哪些网站找客户深圳seo网络推广公司
  • 网站统计如何做公司网站域名cn和com
  • 手机网站制作织梦网站模板网站网站怎么做
  • 高端网站设计欣赏旅游网站建设风险分析
  • 石家庄网站建设公司排名免费开发网站大全
  • 哪个网站做国内销海外的局网站建设进入前十名
  • 网站开发项目预算表wordpress 导入excel
  • 什么样的公司需要做网站网络广告营销的特性
  • 网站源码天堂WordPress博客Vieu主题
  • 贵阳手机端网站建设柏乡seo快排优化
  • 金融类网站模板网页qq登录保护功能
  • 营销型企业网站分析与诊断游戏网站哪个好
  • 做网站上传那个目录商标logo设计软件 免费