Daily Tech Briefing
AI 科技速览

每天 5 分钟内学习 AI。获取最新的人工智能新闻,理解其重要性,并学习如何将其应用于您的工作。

AI 快讯
Dev.to AI · 2026/8/5 03:31:46

Introduction to Multimodal Reasoning

AI 中文解读
这个AI新闻介绍了如何开发一个能“看图说话”的智能诊断助手。这项技术的核心突破在于跨模态推理:让人工智能同时理解屏幕截图和文字描述,不再局限于单一的信息源,而是像一位经验丰富的工程师那样,将视觉信息与语言信息结合起来进行综合分析。 简单来说,这项技术让电脑程序学会了“眼观六路,耳听八方”。以前,报告软件出错就像报修时只说“我的电话坏了,电话线可能有问题,请检查”,维修师傅还得自己跑一趟实地查看;现在,你可以直接提交一张模糊的屏幕截图,加上一句简单的描述,程序就能自己分析,判断故障根源到底是网络连接、代码漏洞还是界面设计问题,甚至还能给出具体的修复建议。而且,这一整套分析过程都在本地或私有化环境中完成,用户的数据隐私更有保障。 对普通人来说,这意味着未来我们使用软件时的“报错体验”会得到显著改善。当遇到网页打不开、应用闪退等问题时,不再需要向技术支持人员艰难描述技术细节,只需提交截图,后台的AI就能自动完成初步的故障排查并生成清晰的报告。这不仅能让日常工作中的IT支持响应更快,也为企业节省了宝贵的人力成本,让技术人员能集中精力处理那些真正复杂的棘手难题。
<p>We are building a visual diagnosis agent that consumes screenshots and user descriptions to reason about UI bugs and system errors. It combines vision and language understanding to generate structured incident reports without sending your data to closed-source platforms. Frontend teams and SREs can use it to triage issues faster by automating the first pass of root-cause analysis.</p> <h2 id="what-youll-need">What you'll need</h2> <ul> <li>Python 3.10 or newer.</li> <li>An Oxlo.ai API key from <a href="https://portal.oxlo.ai" rel="noopener noreferrer">https://portal.oxlo.ai</a>.</li> <li>The OpenAI SDK: <code>pip install openai</code>.</li> <li>A sample image file named <code>error_screenshot.png</code> in your working directory.</li> </ul> <h2 id="step-1">Step 1: Instantiate the Oxlo.ai client</h2> <p>I keep the client in a dedicated module so I do not repeat boilerplate. The base URL points to Oxlo.ai, and I use <code>kimi-k2.6</code> because it handles both vision and long-context reasoning in a single request.</p> <pre><code>from openai import OpenAI import os client = OpenAI( base_url="https://api.oxlo.ai/v1", api_key=os.environ.get("OXLO_API_KEY", "YOUR_OXLO_API_KEY") )</code></pre> <h2 id="step-2">Step 2: Encode the image</h2> <p>Vision models on Oxlo.ai accept base64-encoded PNG and JPEG data inline. This helper reads a local file and returns the data URI string.</p> <pre><code>import base64 def encode_image(image_path): with open(image_path, "rb") as f: return base64.b64encode(f.read()).decode("utf-8")</code></pre> <h2 id="step-3">Step 3: Define the reasoning system prompt</h2> <p>I want the model to separate observation from inference. The prompt forces it to reason aloud before concluding and to output strict JSON.</p> <pre><code>SYSTEM_PROMPT = """You are a senior site-reliability engineer with expertise in frontend systems. When given a screenshot and a user report, reason step by step: 1. Observe what is visibly wrong in the image (errors, blank states, layout issues, console messages). 2. Correlate those observations with the user's text description. 3. Hypothesize the most likely root cause. 4. Propose an immediate fix and a prevention step. Respond in valid JSON with keys: observation, correlation, root_cause, immediate_fix, prevention."""</code></pre> <h2 id="step-4">Step 4: Build the multimodal request</h2> <p>The user message is an array of content blocks. One block carries the base64 image, the other carries the text query. Because Oxlo.ai uses request-based pricing, sending a large screenshot and a verbose system prompt does not inflate cost the way token-based inference does. You can compare plans at <a href="https://oxlo.ai/pricing" rel="noopener noreferrer">https://oxlo.ai/pricing</a>.</p> <pre><code>def diagnose_issue(image_path, user_description): b64_image = encode_image(image_path) response = client.chat.completions.create( model="kimi-k2.6", messages=[ {"role": "system", "content": SYSTEM_PROMPT}, { "role": "user", "content": [ { "type": "image_url", "image_url": { "url": f"data:image/png;base64,{b64_image}" } }, { "type": "text", "text": f"User report: {user_description}" } ] } ], response_format={"type": "json_object"} ) return response.choices[0].message.content</code></pre> <h2 id="step-5">Step 5: Parse and display the result</h2> <p>The raw response is a JSON string. I load it and print each reasoning stage so the output is readable in a terminal.</p> <pre><code>import json def run_diagnosis(image_path, user_description): raw = diagnose_issue(image_path, user_description) result = json.
分享
阅读原文