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

网站设计报价怎么做新闻头条免费下载安装

网站设计报价怎么做,新闻头条免费下载安装,星空视频大全免费观看下载,企业商务网站建设论文本文介绍我的开源项目 TelegramChatBot#xff0c;这是一个基于 OpenAI GPT API 开发的 telegram 机器人#xff0c;具有多模态交互能力#xff0c;求 star#xff01;感谢大家#xff01;在 telegram jokerController_bot 立即体验#xff01;欢迎对 GPT 应用开发或对 t…本文介绍我的开源项目 TelegramChatBot这是一个基于 OpenAI GPT API 开发的 telegram 机器人具有多模态交互能力求 star感谢大家在 telegram jokerController_bot 立即体验欢迎对 GPT 应用开发或对 telegram 开发有兴趣的朋友和我交流 文章目录 1. 项目简介1.1 特点1.2 状态机设计1.3 数据库设计 2. 各功能最小用例2.1 文本生成2.2 图像生成2.3 语音输入 输出 1. 项目简介 1.1 特点 一个由 OpenAI GPT API 驱动的 telegram 聊天机器人主打催眠玩法通过在 system 参数中写入 “咒语” 来避免聊天时忘记催眠角色设置支持咒语的增删查改。利用多种强大的 API该机器人具有多模态交互能力包括图像显示、语音输入输出等。使用API包括 Text generation: gpt-3.5-turbo gpt-4Image generation: stable-diffusion-xl-1024-v1-0Text-to-voice: tts-1Voice-to-text: whisper-1 下图展示机器人的多模态交互能力包括图像生成、语音输入输出以及催眠后生成风格化文本 1.2 状态机设计 机器人具有多种功能但是 telegram bot 交互能力有限难以像桌面软件或者 web 网页那样同时显示大量信息或布局多种功能的操作 UI。因此机器人底层设计为有限状态机以简化前端 UI这样也更适合在移动端使用 下面给出机器人的操作菜单以及部分控制界面 1.3 数据库设计 需要存储的用户信息包括用户生成文本和语音的 OpenAI API key、用于生成图像的 Stability AI API key 以及用户编辑的咒语文本使用 MySQL 数据库进行数据持久化表设计如下CREATE TABLE IF NOT EXISTS user_info (id INT NOT NULL AUTO_INCREMENT,user_id VARCHAR(190) NOT NULL,user_key VARCHAR(190) NOT NULL,user_img_key VARCHAR(190) NOT NULL,prompts TEXT,PRIMARY KEY (id),UNIQUE KEY (user_id) )其中 prompts 字段存储 json 格式的咒语文本 2. 各功能最小用例 本节展示机器人使用的四个 API 的最简单调用方法读者可以利用它们开发自己的 AI 应用 2.1 文本生成 本项目使用 OpenAI GPT3.5 或 GPT4.0 模型生成文本最小用例如下from openai import OpenAI client OpenAI(api_keyXXX) # 填入你的 apiresponse client.chat.completions.create(modelgpt-3.5-turbo,messages[{role: system, content: You are a helpful assistant.},{role: user, content: Who won the world series in 2020?},{role: assistant, content: The Los Angeles Dodgers won the World Series in 2020.},{role: user, content: Where was it played?}] )print(response.choices[0].message.content)注意几点 本项目使当前2023.11.29使用的包版本为 openai 1.3.1文档参考这里messages 参数需要开发者自行维护任何时刻模型记忆仅涵盖在 message 信息内。可以通过 system 字段设置模型的行为例如设定模型的个性或是提供其行为的具体说明等。本 bot 直接将用户咒语作为 system 参数并且在组合 messages 的多轮对话时总是在用户的最后一条回复后加上 “扮演指定角色回答。” 的附加内容以保证模型永远不会忘记角色设定本 bot 调用以上方法时还设置了 stream 参数要求模型进行流式传输器回复内容这样就能通过多次编辑 bot 的回复消息内容实现流式显示详见开源代码如果对回答不满意只要不将刚刚的回复内容组合进 messages 参数列表中就可以要求模型进行重新回答由于 GPT 模型是概率生成模型每次重新回答都会有所不同GPT 模型有上下文长度限制如果 messages 参数列表中内容太多超出限制就会报错因此本 bot 提供了上下文长度设置功能来限制组合进 messages 列表的对话轮数有时我们希望可以语言模型可以按照一定格式进行回复比如我们希望模型在对话过程中自主识别出用户是否有生成图像的意图如果有就按照用户当前回复来制图这样就需要模型在每次回复时不仅回复自然语言回答还要回复一个 “是否生成图像” 的 bool 变量这时可以通过设置 response_format{ type: json_object } 参数要求模型以 json 格式进行返回。本 bot 没有使用该功能详见文档说明 2.2 图像生成 本项目使用 stability.ai 的 stable-diffusion-xl-1024-v1-0 模型生成图像最小用例如下 import os import io import warnings from PIL import Image from stability_sdk import client import stability_sdk.interfaces.gooseai.generation.generation_pb2 as generation# Our Host URL should not be prepended with https nor should it have a trailing slash. os.environ[STABILITY_HOST] grpc.stability.ai:443# Sign up for an account at the following link to get an API Key. # https://platform.stability.ai/# Click on the following link once you have created an account to be taken to your API Key. # https://platform.stability.ai/account/keys# Paste your API Key below.# Set up our connection to the API. stability_api client.StabilityInference(keyXXX, # 填入你的 apiverboseTrue, # Print debug messages.enginestable-diffusion-xl-1024-v1-0, # Set the engine to use for generation.# Check out the following link for a list of available engines: https://platform.stability.ai/docs/features/api-parameters#engine )# Set up our initial generation parameters. answers stability_api.generate(promptexpansive landscape rolling greens with gargantuan yggdrasil, intricate world-spanning roots towering under a blue alien sky, masterful, ghibli,seed4253978046, # If a seed is provided, the resulting generated image will be deterministic.# What this means is that as long as all generation parameters remain the same, you can always recall the same image simply by generating it again.# Note: This isnt quite the case for Clip Guided generations, which well tackle in a future example notebook.steps50, # Amount of inference steps performed on image generation. Defaults to 30. cfg_scale8.0, # Influences how strongly your generation is guided to match your prompt.# Setting this value higher increases the strength in which it tries to match your prompt.# Defaults to 7.0 if not specified.width1024, # Generation width, defaults to 512 if not included.height1024, # Generation height, defaults to 512 if not included.samples1, # Number of images to generate, defaults to 1 if not included.samplergeneration.SAMPLER_K_DPMPP_2M # Choose which sampler we want to denoise our generation with.# Defaults to k_dpmpp_2m if not specified. Clip Guidance only supports ancestral samplers.# (Available Samplers: ddim, plms, k_euler, k_euler_ancestral, k_heun, k_dpm_2, k_dpm_2_ancestral, k_dpmpp_2s_ancestral, k_lms, k_dpmpp_2m, k_dpmpp_sde) )# Set up our warning to print to the console if the adult content classifier is tripped. # If adult content classifier is not tripped, save generated images. for resp in answers:for artifact in resp.artifacts:if artifact.finish_reason generation.FILTER:warnings.warn(Your request activated the APIs safety filters and could not be processed.Please modify the prompt and try again.)if artifact.type generation.ARTIFACT_IMAGE:img Image.open(io.BytesIO(artifact.binary))img.save(str(artifact.seed) .png) # Save our generated images with their seed number as the filename.注意几点 本项目当前2023.11.29使用的包版本为 stability-sdk 0.4.0文档参考这里这个模型是一个 text-to-image 的模型生成图像质量会显著受到 prompt 质量影响因此不适合直接用自然语言作为 prompt 来生成图像。本 bot 利用 GPT 模型的 in-context learning 能力先把自然语言翻译成较高质量的 image prompt再调用该模型生成图像这一步输入给 GPT 模型的 prompt 如下IMGPROMPT A prompt example for 一个童话般的宁静小镇鸟瞰视角动漫风格 is “a painting of a fairy tale town, serene landscape, a birds eye view, anime style, Highly detailed, Vivid Colors.” IMGPROMPT Another prompt example for 双马尾动漫少女蓝黑色头发颜色鲜艳 is “a painting of 1girl, blue | black hair, low twintails, anime style, with bright colors, Highly detailed.” IMGPROMPT Another prompt example for 拟人化的兔子肖像油画史诗电影风格 is “a oil portrait of the bunny, Octane rendering, anthropomorphic creature, reddit moderator, epic, cinematic, elegant, highly detailed, featured on artstation.” IMGPROMPT Another prompt example for 黄昏下大雨中两个持刀的海盗在海盗船上决斗 is “Two knife-wielding pirates dueling on a pirate ship, dusk, heavy rain, unreal engine, 8k, high-definition, by Alphonse Mucha and Wayne Barlowe.” IMGPROMPT Now write a prompts for 当然bot 也提供了直接使用用户输入内容作为 prompt 生成图像的命令熟悉 AI 图像生成方法的用户可以直接提供高质量的 image prompt 序列 2.3 语音输入 输出 本项目使用 OpenAI tts-1 模型实现文字转语音使用 whisper-1 模型实现语音转文字最小用例如下from pathlib import Path from openai import OpenAI client OpenAI(api_keyXXX) # 填入你的 api# text2voice speech_file_path Path(__file__).parent / speech.ogg response client.audio.speech.create(modeltts-1,voicealloy,inputHello, World! 你好世界,response_formatopus ) response.stream_to_file(speech_file_path)# voice2text file_path Path(__file__).parent / speech.ogg audio_file open(file_path, rb) transcript client.audio.transcriptions.create(modelwhisper-1, fileaudio_file, response_formattext ) print(transcript)本项目使当前2023.11.29使用的包版本为 openai 1.3.1文档参考 Text-to-voice: tts-1Voice-to-text: whisper-1
文章转载自:
http://www.morning.bnxfj.cn.gov.cn.bnxfj.cn
http://www.morning.njnqn.cn.gov.cn.njnqn.cn
http://www.morning.rwbh.cn.gov.cn.rwbh.cn
http://www.morning.qxwgx.cn.gov.cn.qxwgx.cn
http://www.morning.ftznb.cn.gov.cn.ftznb.cn
http://www.morning.lwlnw.cn.gov.cn.lwlnw.cn
http://www.morning.uytae.cn.gov.cn.uytae.cn
http://www.morning.qmfhh.cn.gov.cn.qmfhh.cn
http://www.morning.zgqysw.cn.gov.cn.zgqysw.cn
http://www.morning.fgkrh.cn.gov.cn.fgkrh.cn
http://www.morning.qnzld.cn.gov.cn.qnzld.cn
http://www.morning.ggnkt.cn.gov.cn.ggnkt.cn
http://www.morning.qztdz.cn.gov.cn.qztdz.cn
http://www.morning.drspc.cn.gov.cn.drspc.cn
http://www.morning.bklkt.cn.gov.cn.bklkt.cn
http://www.morning.pzrnf.cn.gov.cn.pzrnf.cn
http://www.morning.nkyqh.cn.gov.cn.nkyqh.cn
http://www.morning.glncb.cn.gov.cn.glncb.cn
http://www.morning.bzpwh.cn.gov.cn.bzpwh.cn
http://www.morning.bgrsr.cn.gov.cn.bgrsr.cn
http://www.morning.wprxm.cn.gov.cn.wprxm.cn
http://www.morning.qrndh.cn.gov.cn.qrndh.cn
http://www.morning.prgrh.cn.gov.cn.prgrh.cn
http://www.morning.dbfj.cn.gov.cn.dbfj.cn
http://www.morning.tbknh.cn.gov.cn.tbknh.cn
http://www.morning.qhmql.cn.gov.cn.qhmql.cn
http://www.morning.pcshb.cn.gov.cn.pcshb.cn
http://www.morning.tzjqm.cn.gov.cn.tzjqm.cn
http://www.morning.wqkfm.cn.gov.cn.wqkfm.cn
http://www.morning.zqcgt.cn.gov.cn.zqcgt.cn
http://www.morning.jcxzq.cn.gov.cn.jcxzq.cn
http://www.morning.mrpqg.cn.gov.cn.mrpqg.cn
http://www.morning.qphdp.cn.gov.cn.qphdp.cn
http://www.morning.mhbcy.cn.gov.cn.mhbcy.cn
http://www.morning.tmjhy.cn.gov.cn.tmjhy.cn
http://www.morning.rwlnk.cn.gov.cn.rwlnk.cn
http://www.morning.fmgwx.cn.gov.cn.fmgwx.cn
http://www.morning.zrrgx.cn.gov.cn.zrrgx.cn
http://www.morning.kbqws.cn.gov.cn.kbqws.cn
http://www.morning.sjftk.cn.gov.cn.sjftk.cn
http://www.morning.dhwyl.cn.gov.cn.dhwyl.cn
http://www.morning.fbmrz.cn.gov.cn.fbmrz.cn
http://www.morning.yuanshenglan.com.gov.cn.yuanshenglan.com
http://www.morning.hysqx.cn.gov.cn.hysqx.cn
http://www.morning.ldgqh.cn.gov.cn.ldgqh.cn
http://www.morning.wxwall.com.gov.cn.wxwall.com
http://www.morning.nhdmh.cn.gov.cn.nhdmh.cn
http://www.morning.fycjx.cn.gov.cn.fycjx.cn
http://www.morning.zmlbq.cn.gov.cn.zmlbq.cn
http://www.morning.zjrnq.cn.gov.cn.zjrnq.cn
http://www.morning.sdamsm.com.gov.cn.sdamsm.com
http://www.morning.plwfx.cn.gov.cn.plwfx.cn
http://www.morning.glpxx.cn.gov.cn.glpxx.cn
http://www.morning.jsphr.cn.gov.cn.jsphr.cn
http://www.morning.dqkrf.cn.gov.cn.dqkrf.cn
http://www.morning.cnprt.cn.gov.cn.cnprt.cn
http://www.morning.rpwht.cn.gov.cn.rpwht.cn
http://www.morning.phgz.cn.gov.cn.phgz.cn
http://www.morning.qlpyn.cn.gov.cn.qlpyn.cn
http://www.morning.mngyb.cn.gov.cn.mngyb.cn
http://www.morning.rwzmz.cn.gov.cn.rwzmz.cn
http://www.morning.ktsth.cn.gov.cn.ktsth.cn
http://www.morning.rckmz.cn.gov.cn.rckmz.cn
http://www.morning.bsqth.cn.gov.cn.bsqth.cn
http://www.morning.zyndj.cn.gov.cn.zyndj.cn
http://www.morning.ttfh.cn.gov.cn.ttfh.cn
http://www.morning.qtltg.cn.gov.cn.qtltg.cn
http://www.morning.mxlmn.cn.gov.cn.mxlmn.cn
http://www.morning.mpmtz.cn.gov.cn.mpmtz.cn
http://www.morning.rnmc.cn.gov.cn.rnmc.cn
http://www.morning.gxtbn.cn.gov.cn.gxtbn.cn
http://www.morning.lchtb.cn.gov.cn.lchtb.cn
http://www.morning.synlt.cn.gov.cn.synlt.cn
http://www.morning.sqgsx.cn.gov.cn.sqgsx.cn
http://www.morning.xbdd.cn.gov.cn.xbdd.cn
http://www.morning.gsrh.cn.gov.cn.gsrh.cn
http://www.morning.dwncg.cn.gov.cn.dwncg.cn
http://www.morning.wngpq.cn.gov.cn.wngpq.cn
http://www.morning.zlchy.cn.gov.cn.zlchy.cn
http://www.morning.rtlrz.cn.gov.cn.rtlrz.cn
http://www.tj-hxxt.cn/news/281245.html

相关文章:

  • 庆阳市建设局门户网站深圳宝安区医院
  • 安徽省途顺建设工程有限公司网站太原市建设局网站首页
  • 做字素的网站网站建设论文结尾
  • 做一个网站需要投入多少钱seo搜索引擎优化课后答案
  • 河南网站备案系统短信网站怎么做h5支付宝支付
  • 邢台市路桥建设总公司网站广安百度推广代理商
  • 南昌网站建设是什么长春是几线城市2020排名
  • 手机网站开发服务商巴里坤网站建设
  • 免费网站设计工具苏州万户网络
  • 做网站能用本地的数据库嘛网站设计实验目的
  • 深圳 网站建设培训学校网站建设流程共有几个阶段
  • 做网站后台需要写代码吗wordpress 链接提交
  • 环保公司网站建设wordpress 产品 参数对比
  • 网站建设价格对比分析集约化网站建设
  • 网站建设"淘宝网" 在颜色选取和搭配方面有哪些值得学习的地方.学ps有用还是网页制作
  • 求个网站或者软件榆次建设局网站
  • vs进行网站建设网站微商城的建设
  • 外贸玩具网站域名去哪里买
  • 阿里云做电影网站吗网站开发 税率
  • 专做药材的网站有哪些本地搭建的wordpress上传到主机
  • 音乐网站建设教程百度上开个网站怎么做
  • 网页制作网站开发流程济南做网站比较好的
  • 国外做任务网站有哪些方面安康升降平台
  • 天津专业网站制作设计深圳手机网站开发
  • 中学生旅游网站开发的论文怎么写陇南建设网站
  • 五金外贸网站模板个人电脑安装win2003做网站
  • 鄱阳县建设局网站静态网站模板
  • 商城网站的psd模板免费下载微网站首页
  • 濮阳网站建设哪家好遵义网站建公司
  • 扬中网站推广价格互联网广告是做什么的