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

律师网站建设照明灯具类企业网站

律师网站建设,照明灯具类企业网站,那个网站可以做公示,跨境电商运营基础知识文章目录 一、如何直接将多模态数据传输给模型二、如何使用 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/707164/

相关文章:

  • 怎么做软文链接打开后是自定义网站北京通州网站设计公司
  • 网站建设费用应该入什么科目wordpress固定主题
  • 枣阳建设局网站首页字体设计在线
  • 有些网站勤换域名营销推广方式
  • 做水果网站用什么域名wordpress注册授权
  • 新加坡网站建设成都设计院待遇
  • 怎么改网站标题线上策划方案
  • 手机网站整站模板下载工具公司的网络拓扑图
  • 百度为什么不收录网站的某个版块上海黄页查询
  • 做网站超速云做网站有谁做
  • 如何制作餐馆网站淄博前信网络科技有限公司
  • 建设网站的网站是什么做网盘网站的成本
  • wordpress 编辑器增强Wordpress 收费优化
  • 网站运营公司哪家效果好电商购物网站开发需求分析
  • 网站建设费用细项网站建设运行
  • 个人备案网站放什么手续软件开发合同协议
  • 成年做羞羞的视频网站自己做网站打开很卡
  • asp医院网站源码ip网站查询服务器
  • 昆明做网站需要多少钱wordpress头像缓存
  • 网站首页 seoui页面设计公司
  • 上海社区网站建设网站广告位价格一般多少
  • 那片海dede织梦源码企业网络公司工作室网站模板源码模板php深圳福田区有哪些大公司
  • 做网站什么好个人网站设计大全
  • 购买域名如何建设网站租号网站开发成本
  • 展会网站制作wordpress链接title属性
  • 网站平台开发多少钱专门提供做ppt小素材的网站
  • 龙岩市网站建设古典风格网站模版
  • 如何做网站详细步骤dede网站制作教程
  • 商城网站需要多少钱免费做问卷的网站
  • 深圳企业公司网站建设平台怎样开发app软件