Upgrades langchain package to latest versions.#41
Upgrades langchain package to latest versions.#41Balki-OriginTrail wants to merge 2 commits intomainfrom
Conversation
…s linting which is why we have so many changed files....-.-
There was a problem hiding this comment.
This PR is mostly formatting and documentation churn, but it also includes a major LangChain dependency migration and a chat content parsing change. There is a blocker in the chat renderer path: an unsafe cast can pass object-shaped image payloads as string URIs and break image rendering at runtime. Maintainability in the touched parsing logic is slightly worsened because type assertions are used instead of explicit normalization/guards. Aside from that, the rest of the code diffs are largely cosmetic.
| for (const c of toContents(m.content)) { | ||
| if (c.type === "image_url") { | ||
| images.push({ uri: c.image_url }); | ||
| images.push({ uri: c.image_url as string }); |
There was a problem hiding this comment.
🔴 Bug: c.image_url as string can pass an object payload through as uri at runtime (e.g. { url: ... }), which breaks image rendering. Normalize explicitly (typeof c.image_url === 'string' ? c.image_url : c.image_url?.url) and only push when a string URL exists; same unsafe-cast pattern appears at line 663 for c.text.
| "@langchain/mistralai": "^0.2.1", | ||
| "@langchain/openai": "^0.6.3", | ||
| "@langchain/xai": "^0.1.0", | ||
| "@langchain/anthropic": "^1.3.22", |
There was a problem hiding this comment.
🟡 Issue: This upgrades LangChain packages across major versions, but the PR does not add regression coverage for the changed content-shape handling in chat parsing. Add tests for both string/object image_url blocks and non-string/missing text fields so migration regressions are caught.
There was a problem hiding this comment.
This PR is largely formatting and documentation churn, plus a significant LangChain dependency upgrade in apps/agent. I found one blocker in the chat rendering path: image content parsing now drops one valid image_url shape, which can remove images from messages. Maintainability in the touched chat parsing area is slightly worsened because it now diverges from existing message-content handling logic for the same content type.
|
|
||
| for (const c of toContents(m.content)) { | ||
| if (c.type === "image_url") { | ||
| if (c.type === "image_url" && typeof c.image_url === "string") { |
There was a problem hiding this comment.
🔴 Bug: This now only handles image_url when it is a string, but LangChain message blocks can also provide image_url as an object ({ url: ... }), so those images are silently dropped. Normalize both shapes (e.g. string or c.image_url?.url) before pushing to images.
Cursor also always runs linting which is why we have so many changed files....-.-