Skip to content

搞英语 → 看世界

翻译英文优质信息和名人推特

Menu
  • 首页
  • 作者列表
  • 独立博客
  • 专业媒体
  • 名人推特
  • 邮件列表
  • 关于本站
Menu

llm-mistral 0.14

Posted on 2025-05-29

llm-mistral 0.14

我今天在我的插件中添加了工具支持,以便从 LLM 访问 Mistral API,并支持 Mistral 的新Codestral Embed嵌入模型。

这里一个有趣的挑战是,我没有使用llm-mistral的官方客户端库——我使用 Florimond Manca 的httpx-sse库,在其流式 HTTP API 之上构建了自己的客户端。这是一种与流式 API 交互非常便捷的方式——以下是我的代码,它完成了大部分工作。

我遇到的问题是,Mistral 的函数调用 API 文档中有 Python 和 TypeScript 的示例,但不包含curl或其 HTTP 端点的直接文档!

我需要 HTTP 级别的文档。我可以直接从 Mistral 的官方 Python 库中提取吗?

事实证明我可以。我首先克隆了 repo:

 git 克隆 https://github.com/mistralai/client-python cd客户端-python/src/mistralai 文件提示。 | ttok

我的ttok工具给出了 212,410 个令牌计数(使用 OpenAI 的标记器进行计数,但这通常是一个足够接近的估计值) – Mistral 的模型的输出为 128,000 个,因此我切换到 Gemini 2.5 Flash,它可以轻松处理这么多。

我运行了这个:

文件到提示符-c . > /tmp/mistral.txt  llm -f /tmp/mistral.txt \   -m gemini-2.5-flash-preview-05-20 \   -s '生成全面的 HTTP API 文档,显示 函数调用的工作原理,包括每个步骤的示例 curl 命令'

结果非常精彩!Gemini 2.5 Flash 提供了我需要交互的 HTTP API 的详细描述,以及我应该传递给它们的 JSON 格式。

为了让工具在新模型中运行,需要一系列步骤,如LLM 插件作者文档中所述。我开始手动完成这些步骤……后来我偷懒了,决定看看能不能找一个模型帮我完成。

这次我尝试了新的 Claude Opus 4。我输入了三个文件:我现有的、未完成的llm_mistral.py 、一份完整的llm_gemini.py及其工作工具实现,以及一份 Gemini 之前为我编写的 API 文档。我输入了:

I need to update this Mistral code to add tool support. I've included examples of that code for Gemini, and a detailed README explaining the Mistral format.

Claude 不停地为我编写代码,满足了我大部分的需求。我尝试了各种不同的场景,并将问题反馈回 Claude 看看会发生什么,最终我接手并完成了剩下的代码。以下是完整的代码记录。

我有点难过,我没有使用 Mistral 来编写支持 Mistral 的代码,但我很高兴在支持 LLM 工具使用的列表中添加了另一个模型系列。

标签: gemini 、 llm 、插件、 llm-tool-use 、 ai 、 llms 、 mistral 、 generative-ai 、项目、 ai-assisted-programming 、 claude 、 claude-4 、 httpx 、 python

原文: https://simonwillison.net/2025/May/29/llm-mistral-014/#atom-everything

本站文章系自动翻译,站长会周期检查,如果有不当内容,请点此留言,非常感谢。
  • Abhinav
  • Abigail Pain
  • Adam Fortuna
  • Alberto Gallego
  • Alex Wlchan
  • Answer.AI
  • Arne Bahlo
  • Ben Carlson
  • Ben Kuhn
  • Bert Hubert
  • Bits about Money
  • Brian Krebs
  • ByteByteGo
  • Chip Huyen
  • Chips and Cheese
  • Christopher Butler
  • Cool Infographics
  • Dan Sinker
  • David Walsh
  • Dmitry Dolzhenko
  • Dustin Curtis
  • Elad Gil
  • Ellie Huxtable
  • Ethan Marcotte
  • Exponential View
  • FAIL Blog
  • Founder Weekly
  • Geoffrey Huntley
  • Geoffrey Litt
  • Greg Mankiw
  • Henrique Dias
  • Hypercritical
  • IEEE Spectrum
  • Investment Talk
  • Jaz
  • Jeff Geerling
  • Jonas Hietala
  • Josh Comeau
  • Lenny Rachitsky
  • Lou Plummer
  • Luke Wroblewski
  • Matt Baer
  • Matt Stoller
  • Matthias Endler
  • Mert Bulan
  • Mostly metrics
  • News Letter
  • NextDraft
  • Non_Interactive
  • Not Boring
  • One Useful Thing
  • Phil Eaton
  • Product Market Fit
  • Readwise
  • ReedyBear
  • Robert Heaton
  • Ruben Schade
  • Sage Economics
  • Sam Altman
  • Sam Rose
  • selfh.st
  • Shtetl-Optimized
  • Simon schreibt
  • Slashdot
  • Small Good Things
  • Taylor Troesh
  • Telegram Blog
  • The Macro Compass
  • The Pomp Letter
  • thesephist
  • Thinking Deep & Wide
  • Tim Kellogg
  • Understanding AI
  • 英文媒体
  • 英文推特
  • 英文独立博客
©2025 搞英语 → 看世界 | Design: Newspaperly WordPress Theme