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

网站后台html模板南京中企动力有限公司

网站后台html模板,南京中企动力有限公司,wordpress静态化首页,opencart zencart网站建设文章目录 一、如何直接将多模态数据传输给模型二、如何使用 mutimodal prompts 一、如何直接将多模态数据传输给模型 在这里,我们演示了如何将多模式输入直接传递给模型。对于其他的支持多模态输入的模型提供者,langchain 在类中提供了内在逻辑来转化为期…

文章目录

  • 一、如何直接将多模态数据传输给模型
  • 二、如何使用 mutimodal prompts


一、如何直接将多模态数据传输给模型

 在这里,我们演示了如何将多模式输入直接传递给模型。对于其他的支持多模态输入的模型提供者,langchain 在类中提供了内在逻辑来转化为期待的格式。
 传入图像最常用的方法是将其作为字节字符串传入。这应该适用于大多数模型集成。

import base64
import httpximage_url = "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"
image_data = base64.b64encode(httpx.get(image_url).content).decode("utf-8")message = HumanMessage(content=[{"type": "text", "text": "describe the weather in this image"},{"type": "image_url","image_url": {"url": f"data:image/jpeg;base64,{image_data}"},},],
)
response = model.invoke([message]) # 自己定义一个 model
print(response.content)
"""
The weather in the image appears to be clear and pleasant. The sky is mostly blue with scattered, light clouds, suggesting a sunny day with minimal cloud cover. There is no indication of rain or strong winds, and the overall scene looks bright and calm. The lush green grass and clear visibility further indicate good weather conditions.
"""

 我们可以直接在 “image_URL” 类型的内容块中提供图像 URL。但是注意,只有一些模型提供程序支持此功能。

message = HumanMessage(content=[{"type": "text", "text": "describe the weather in this image"},{"type": "image_url", "image_url": {"url": image_url}},],
)
response = model.invoke([message])
print(response.content)

 我们也可以传多个图片。

message = HumanMessage(content=[{"type": "text", "text": "are these two images the same?"},{"type": "image_url", "image_url": {"url": image_url}},{"type": "image_url", "image_url": {"url": image_url}},],
)
response = model.invoke([message])
print(response.content)
"""
Yes, the two images are the same. They both depict a wooden boardwalk extending through a grassy field under a blue sky with light clouds. The scenery, lighting, and composition are identical.
"""

二、如何使用 mutimodal prompts

 在这里,我们将描述一下怎么使用 prompt templates 来为模型格式化 multimodal imputs。

import base64
import httpx
from langchain_core.prompts import ChatPromptTemplateimage_url = "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"
image_data = base64.b64encode(httpx.get(image_url).content).decode("utf-8")prompt = ChatPromptTemplate.from_messages([("system", "Describe the image provided"),("user",[{"type": "image_url","image_url": {"url": "data:image/jpeg;base64,{image_data}"},}],),]
)chain = prompt | modelresponse = chain.invoke({"image_data": image_data})
print(response.content)
"""
The image depicts a sunny day with a beautiful blue sky filled with scattered white clouds. The sky has varying shades of blue, ranging from a deeper hue near the horizon to a lighter, almost pale blue higher up. The white clouds are fluffy and scattered across the expanse of the sky, creating a peaceful and serene atmosphere. The lighting and cloud patterns suggest pleasant weather conditions, likely during the daytime hours on a mild, sunny day in an outdoor natural setting.
"""

 我们也可以给模型传入多个图片。

prompt = ChatPromptTemplate.from_messages([("system", "compare the two pictures provided"),("user",[{"type": "image_url","image_url": {"url": "data:image/jpeg;base64,{image_data1}"},},{"type": "image_url","image_url": {"url": "data:image/jpeg;base64,{image_data2}"},},],),]
)chain = prompt | modelresponse = chain.invoke({"image_data1": image_data, "image_data2": image_data})
print(response.content)
"""
The two images provided are identical. Both images feature a wooden boardwalk path extending through a lush green field under a bright blue sky with some clouds. The perspective, colors, and elements in both images are exactly the same.
"""
http://www.yayakq.cn/news/351360/

相关文章:

  • 鄂州商城网站建设关键词优化过程
  • 怎么上不到建设银行网站小程序开发 深圳
  • 哪个网站做汽车保养比较好网站搭建上海
  • 山东省建设监理协会网站打不开宁波门户网站建设
  • 做网站公司有哪些纺织品做外贸一般在哪个网站上
  • 做营销策划要用到哪些网站网站建设项目描述范文
  • 品牌网站建设找顺的iis一个文件夹配置多个网站
  • 网站建设人员组成wordpress自定义界面
  • 爱站长尾关键词挖掘工具中国五百强企业排名表
  • 石家庄网站建设技术支持金华职院优质校建设网站
  • 英文网站建设的问题东莞网站建设(信科网络)
  • 深圳建站公司模板高德是中国的还是外国的
  • 网站 竞争分析深圳海洋网络做网站
  • 济南哪里做网站机械设计最好的三维软件
  • 国内网站不备案厦门网站推广公司
  • wordpress 导航站模板下载地址网站如何百度收入
  • 邯郸网站建设开发公司视觉冲击力的网站设计
  • 国外空间设计网站中国建筑总公司官网首页
  • 能打开各种网站的浏览器下载合集免费网络课程
  • 无锡网站排名系统邢台做网站咨询
  • 广州网站导航wordpress仿百度文件
  • 杭州外贸网站制作网站开发需要的准备
  • 做网站如何防止被骗温州网站设计平台
  • 织梦网站登录阎良建设局 网站
  • 网站建设安全制度图片ui设计与艺术设计区别
  • 网站源代码怎么放入 dede网站后台千锋python培训
  • 网站备案的影响全国做网站哪家好
  • 安徽网站建设 网新集团网站建设招标
  • dede网站不能够生成做SEO用dede还是wordpress
  • 广州外贸营销网站建设公司wordpress 后台样式修改