用多模式AI代理解锁产品成分的秘密! 厌倦了解密的复杂成分列表?本文向您展示了如何使用Gemini 2.0,Phidata和Tavily Web搜索来构建功能强大的产品成分分析仪。 告别耗时的个人成分搜索,并向即时,可行的见解!
键学习成果
设计多模式AI代理体系结构利用Phidata和Gemini 2.0进行视觉语言任务。
>本文是数据科学博客马拉松的一部分。
了解多模式系统
>多模式系统旨在同时处理和解释多种数据类型,包括文本,图像,音频和视频。诸如Gemini 2.0 Flash,GPT-4O,Claude Sonnet 3.5和Pixtral-12b Excel之类的视觉语言模型在识别这些模式之间的复杂关系,从而从复杂的输入中提取了宝贵的知识。 本文重点介绍了分析图像并生成文本解释的视觉模型。 这些系统无缝将计算机视觉和自然语言处理融合,以根据用户提示来解释视觉信息。
现实世界多模式应用
多模式系统正在彻底改变各种行业:
财务:
>向多模式剂的转变代表了AI相互作用的显着进步。 这就是为什么它们如此有效:
构建产品成分分析仪代理>
> 我们需要:
gemini 2.0 Flash:用于强大的多模式处理。
!pip install phidata google-generativeai tavily-python streamlit pillow从:
获取API键 Gemini API键:
https://www.php.cn/link/link/feacyc4a1c91eb74bfce13cb7c052c2c233btavily api键:
from phi.agent import Agent from phi.model.google import Gemini # needs a api key from phi.tools.tavily import TavilyTools # also needs a api key import os TAVILY_API_KEY = "<replace-your-api-key>" GOOGLE_API_KEY = "<replace-your-api-key>" os.environ['TAVILY_API_KEY'] = TAVILY_API_KEY os.environ['GOOGLE_API_KEY'] = GOOGLE_API_KEY</replace-your-api-key></replace-your-api-key>>
步骤4:定义代理对象>
> Phidata代理被配置为根据系统提示和说明进行处理和操作。 Gemini 2.0 Flash用作推理模型,并且集成了Tavily搜索以进行有效的Web搜索。
SYSTEM_PROMPT = """ You are an expert Food Product Analyst specialized in ingredient analysis and nutrition science. Your role is to analyze product ingredients, provide health insights, and identify potential concerns by combining ingredient analysis with scientific research. You utilize your nutritional knowledge and research works to provide evidence-based insights, making complex ingredient information accessible and actionable for users. Return your response in Markdown format. """ INSTRUCTIONS = """ * Read ingredient list from product image * Remember the user may not be educated about the product, break it down in simple words like explaining to 10 year kid * Identify artificial additives and preservatives * Check against major dietary restrictions (vegan, halal, kosher). Include this in response. * Rate nutritional value on scale of 1-5 * Highlight key health implications or concerns * Suggest healthier alternatives if needed * Provide brief evidence-based recommendations * Use Search tool for getting context """>
步骤5:多模式图像处理
提供图像路径或URL以及提示来启动分析。 使用两种方法的示例在原始文章中提供了。 步骤6&7:简化Web应用程序开发agent = Agent( model = Gemini(), tools = [TavilyTools()], markdown=True, system_prompt = SYSTEM_PROMPT, instructions = INSTRUCTIONS )(原始文章中的详细代码)
> 创建一个简化的应用程序,以提供一个用户友好的接口,以进行图像上传,分析和结果显示。 该应用程序包括示例产品,图像上传和实时照片捕获的选项卡。 图像调整大小和缓存是为最佳性能实施的。
基本链接
完整代码:[insert github链接在此处]
>部署的应用程序:[插入部署的应用链接在此处]
结论
多模式AI代理正在改变我们与复杂信息的互动和理解的方式。 产品成分分析仪展示了将视觉,语言和网络搜索相结合以提供可访问的,可操作的见解的力量。
>常见问题
以上是建立用于产品成分分析的多模式代理的详细内容。更多信息请关注PHP中文网其他相关文章!