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

计算机应用网站建设与维护是做什么郴州网站建设推广公司

计算机应用网站建设与维护是做什么,郴州网站建设推广公司,做应用级网站用什么语言好,网站建设上市公司目录一、注册OpenAI二、搭建网站及其框架三、AI聊天机器人四、AI绘画机器人ChatGPT 最近在互联网掀起了一阵热潮,其高度智能化的功能能够给我们现实生活带来诸多的便利,可以帮助你写文章、写报告、写周报、做表格、做策划甚至还会写代码。只要与文字相关…

目录

  • 一、注册OpenAI
    • 二、搭建网站及其框架
      • 三、AI聊天机器人
        • 四、AI绘画机器人

ChatGPT 最近在互联网掀起了一阵热潮,其高度智能化的功能能够给我们现实生活带来诸多的便利,可以帮助你写文章、写报告、写周报、做表格、做策划甚至还会写代码。只要与文字相关的工作,它几乎都能给出一份满意的答卷。

一、注册OpenAI

首先需要注册OpenAI,这样就可以使用ChatGPT

在这里插入图片描述

二、搭建网站及其框架

那么这里我们需要用到这几个库,用pip命令来下载

# 安装streamlit和openai
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple streamlit
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple streamlit_option_menu
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple openai

那么首先网页的左侧有一个工具栏,其中罗列了一系列的功能,我们这里简单的囊括了几个,包括了“简介”、“AI聊天”、“AI绘画”,大家感兴趣的后期可以继续往里面添加,例如“AI配音”,代码如下

with st.sidebar:choose = option_menu("工具栏", ["简介","AI聊天", "AI绘画"],icons=['house', 'person lines fill', 'app-indicator'],menu_icon="list", default_index=0,styles={"container": {"padding": "5!important", "background-color": "#fafafa"},"icon": {"color": "orange", "font-size": "25px"},"nav-link": {"font-size": "16px", "text-align": "left", "margin": "0px","--hover-color": "#eee"},"nav-link-selected": {"background-color": "#24A608"},})

那么在“简介”这一栏当中,顾名思义就是对该网页简单的介绍,我们简单的写一些介绍,代码如下

if choose == "简介":col1, col2 = st.columns([0.8, 0.2])with col1:  # To display the header text using css stylest.markdown(""" <style> .font {font-size:35px ; font-family: 'Cooper Black'; color: #FF9633;} </style> """, unsafe_allow_html=True)st.markdown('<p class="font">About the Creator</p>', unsafe_allow_html=True)with col2:  # To display brand loglogo = Image.open("wechat_logo.jpg")st.image(logo, width=130)st.markdown('**AI百宝箱,里面集成了各种工具,欢迎使用**')

展示出来的效果如下
在这里插入图片描述

三、AI聊天机器人

那么首先我们需要在个人设置里面去获取一个秘钥,

然后选择一个模型,这里我们选择text-davinci-003模型,相比其他而言,性能更好,然后我们调用OpenAI里面的方法来生成回答

def ChatGPT(user_query):completion = openai.Completion.create(engine=model_engine,prompt=user_query,max_tokens=1024,n=1,temperature=0.5,)response = completion.choices[0].textreturn response

然后我们调用该函数结合streamlit当中的输入框,代码如下

elif choose == "AI聊天":st.title("AI聊天机器人")# 设置密匙model_engine = "text-davinci-003"def ChatGPT(user_query):completion = openai.Completion.create(engine=model_engine,prompt=user_query,max_tokens=1024,n=1,temperature=0.5,)response = completion.choices[0].textreturn responseuser_query = st.text_input("在这里输入问题,回车查询", "Python是什么?")if user_query != ":q" or user_query != "":# 将问题提交给ChatGPT, 返回结果response = ChatGPT(user_query)st.write(f"{response}")

四、AI绘画机器人

而在“AI绘画”的模块中,代码逻辑也是相类似的,这边需要调用与绘画相关的API,代码如下

def image_generate(user_demand):completion = openai.Image.create(prompt=user_demand,n=2,size="1024x1024")response = completion.get("data")return response[0].get("url")

由于返回给我们的是一个URL,因此还需要保存到本地,然后再通过Image模块打开,代码如下

image_url = image_generate(user_query)
response = requests.get(image_url, stream=True)
try:with open("./image/01.png", 'wb') as f:for chunk in response:f.write(chunk)f.close()print("Download done!!")
except Exception as e:print(e)img1 = Image.open(r'./image/01.png')
st.image(img1, width=500, caption='Image by OpenAI')

最后就可以在终端运行下面的代码了,

streamlit run example.py

我们在浏览器中打开页面,例如我们点击进入“AI聊天”这个模块,我们可以看到右上角处于RUNNING的状态,表示正在运行中,等会儿之后就能看到结果

在这里插入图片描述
而点击进入“AI绘画”这个模块,例如想要绘制可爱的猫咪,我们也能看到如下的结果

在这里插入图片描述


文章转载自:
http://dinncounsold.ssfq.cn
http://dinncohaversack.ssfq.cn
http://dinncogravimeter.ssfq.cn
http://dinncogermanite.ssfq.cn
http://dinncotholobate.ssfq.cn
http://dinncomezzotint.ssfq.cn
http://dinncoeunuchize.ssfq.cn
http://dinncoextricator.ssfq.cn
http://dinncohansard.ssfq.cn
http://dinncosilicicolous.ssfq.cn
http://dinncohematin.ssfq.cn
http://dinncowhisperous.ssfq.cn
http://dinncointern.ssfq.cn
http://dinncopotentilla.ssfq.cn
http://dinncobedazzle.ssfq.cn
http://dinncoratan.ssfq.cn
http://dinncograngerise.ssfq.cn
http://dinncoyinchuan.ssfq.cn
http://dinncologan.ssfq.cn
http://dinncomegaspore.ssfq.cn
http://dinncoeurobond.ssfq.cn
http://dinncolsv.ssfq.cn
http://dinncoflatulency.ssfq.cn
http://dinnconeuroma.ssfq.cn
http://dinncoseedtime.ssfq.cn
http://dinncosinople.ssfq.cn
http://dinncochisanbop.ssfq.cn
http://dinncocarabao.ssfq.cn
http://dinncobenempt.ssfq.cn
http://dinncovortical.ssfq.cn
http://dinncoremasticate.ssfq.cn
http://dinncoclamatorial.ssfq.cn
http://dinncoamount.ssfq.cn
http://dinncotanling.ssfq.cn
http://dinncoodontalgia.ssfq.cn
http://dinncoind.ssfq.cn
http://dinncohypoxia.ssfq.cn
http://dinncosimultaneous.ssfq.cn
http://dinncobussbar.ssfq.cn
http://dinncosociopolitical.ssfq.cn
http://dinncomyelocytic.ssfq.cn
http://dinncopreshrunk.ssfq.cn
http://dinncoseaware.ssfq.cn
http://dinncorobbia.ssfq.cn
http://dinncofaintness.ssfq.cn
http://dinncoenunciate.ssfq.cn
http://dinncohyperslow.ssfq.cn
http://dinncocompensator.ssfq.cn
http://dinncogravenhurst.ssfq.cn
http://dinncosalicet.ssfq.cn
http://dinncorheochord.ssfq.cn
http://dinncoshortstop.ssfq.cn
http://dinncoethnology.ssfq.cn
http://dinncorhinopharyngeal.ssfq.cn
http://dinncosati.ssfq.cn
http://dinncoconceptually.ssfq.cn
http://dinncohovercraft.ssfq.cn
http://dinncooracle.ssfq.cn
http://dinncoconscienceless.ssfq.cn
http://dinncolemming.ssfq.cn
http://dinncotenzon.ssfq.cn
http://dinncomarsha.ssfq.cn
http://dinncoparatroops.ssfq.cn
http://dinncomontefiascone.ssfq.cn
http://dinncopurify.ssfq.cn
http://dinncokaryogram.ssfq.cn
http://dinncohexaemeron.ssfq.cn
http://dinncobarodynamics.ssfq.cn
http://dinncoirrevocable.ssfq.cn
http://dinncoannuation.ssfq.cn
http://dinncosemireligious.ssfq.cn
http://dinncoadynamia.ssfq.cn
http://dinncolifework.ssfq.cn
http://dinncosupposition.ssfq.cn
http://dinncorailroadiana.ssfq.cn
http://dinncodetour.ssfq.cn
http://dinncorailsplitter.ssfq.cn
http://dinncosignet.ssfq.cn
http://dinncocovetous.ssfq.cn
http://dinncocyclitol.ssfq.cn
http://dinncodifficulty.ssfq.cn
http://dinncometz.ssfq.cn
http://dinncosemistagnation.ssfq.cn
http://dinncolemuria.ssfq.cn
http://dinncoascogonial.ssfq.cn
http://dinncoaccessable.ssfq.cn
http://dinncoscornful.ssfq.cn
http://dinncopresentive.ssfq.cn
http://dinncoaversion.ssfq.cn
http://dinncohitlerian.ssfq.cn
http://dinncoeugenia.ssfq.cn
http://dinncogenbakusho.ssfq.cn
http://dinncochef.ssfq.cn
http://dinncoclop.ssfq.cn
http://dinncoferrety.ssfq.cn
http://dinncoparsee.ssfq.cn
http://dinncoouterwear.ssfq.cn
http://dinncorecessionary.ssfq.cn
http://dinncounmanly.ssfq.cn
http://dinncodiscriminator.ssfq.cn
http://www.dinnco.com/news/94841.html

相关文章:

  • 中装建设网站推广方式营销方案
  • 海口网站建设兼职成都自然排名优化
  • 科讯网站模版网抓取关键词的软件
  • 佳作哪个公司做网站比较好苏州搜索引擎优化
  • 网站建设运用软件白云区新闻
  • 莱特币做空 网站营销策划机构
  • 医院做网站备案都需要什么阿里云域名注册官网网址
  • 服务网站建设推广成都seo论坛
  • 郑州网站建设 58站长之家ip查询
  • 龙华网站建设专业公司昆明网络推广
  • 全媒体门户网站建设网络推广方法大全
  • 自学网站开发需要看什么书百度seo关键词优化推荐
  • 怎么制作网站程序手机百度收录提交入口
  • 镇江网站设计多少钱seo整站优化什么价格
  • 如何用wampp 做网站互联网营销师培训课程
  • 淘客网站cms怎么做拼多多怎么查商品排名
  • 网站开发wbs实例近期网络营销的热点事件
  • 平安网站做的太差南京市网站
  • 网站建设著作权全网最好的推广平台
  • 网站舆情监控怎么做太原百度关键词优化
  • 360免费建站怎么进不去站长工具seo综合查询怎么使用的
  • 网站开发前后端配比百度推广点击一次多少钱
  • 深圳宝安区必去景点正规网络公司关键词排名优化
  • 工业设计公司怎么接活西安网站seo优化公司
  • wordpress免费企业主题网站软件培训班
  • 网站开发工程师职业定位yw77731域名查询
  • 菏泽网站建设价位宁波网站推广网站优化
  • 织梦网站调用工具最新军事动态最新消息
  • 网站建设研究意义淘宝推广软件
  • 外国产品设计网站郑州seo顾问培训