-
Notifications
You must be signed in to change notification settings - Fork 18
Upgrades langchain package to latest versions. #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,8 @@ | ||
| import { useCallback, useEffect, useRef, useState } from "react"; | ||
| import { View, Platform, KeyboardAvoidingView, ScrollView } from "react-native"; | ||
| import { Image } from "expo-image"; | ||
| import * as Clipboard from "expo-clipboard"; | ||
| import { Image } from "expo-image"; | ||
| import { fetch } from "expo/fetch"; | ||
| import { useCallback, useEffect, useRef, useState } from "react"; | ||
| import { KeyboardAvoidingView, Platform, ScrollView, View } from "react-native"; | ||
| import { useSafeAreaInsets } from "react-native-safe-area-context"; | ||
| //import AsyncStorage from "@react-native-async-storage/async-storage"; | ||
| import { | ||
|
|
@@ -11,17 +11,18 @@ import { | |
| } from "@dkg/plugin-dkg-essentials/utils"; | ||
|
|
||
| import { useMcpClient } from "@/client"; | ||
| import useMcpToolsSession from "@/hooks/useMcpToolsSession"; | ||
| import useColors from "@/hooks/useColors"; | ||
| import usePlatform from "@/hooks/usePlatform"; | ||
| import Page from "@/components/layout/Page"; | ||
| import Container from "@/components/layout/Container"; | ||
| import Header from "@/components/layout/Header"; | ||
| import { useAlerts } from "@/components/Alerts"; | ||
| import Chat from "@/components/Chat"; | ||
| import { SourceKAResolver } from "@/components/Chat/Message/SourceKAs/CollapsibleItem"; | ||
| import Container from "@/components/layout/Container"; | ||
| import Header from "@/components/layout/Header"; | ||
| import Page from "@/components/layout/Page"; | ||
| import Markdown from "@/components/Markdown"; | ||
| import { useAlerts } from "@/components/Alerts"; | ||
| import useColors from "@/hooks/useColors"; | ||
| import useMcpToolsSession from "@/hooks/useMcpToolsSession"; | ||
| import usePlatform from "@/hooks/usePlatform"; | ||
|
|
||
| import useSettings from "@/hooks/useSettings"; | ||
| import { | ||
| type ChatMessage, | ||
| type ToolCall, | ||
|
|
@@ -30,23 +31,22 @@ import { | |
| makeStreamingCompletionRequest, | ||
| toContents, | ||
| } from "@/shared/chat"; | ||
| import { toError } from "@/shared/errors"; | ||
| import { | ||
| FileDefinition, | ||
| parseFilesFromContent, | ||
| serializeFiles, | ||
| uploadFiles, | ||
| } from "@/shared/files"; | ||
| import { toError } from "@/shared/errors"; | ||
| import useSettings from "@/hooks/useSettings"; | ||
| import { | ||
| isThinkingVisible, | ||
| shouldStopGenerating, | ||
| } from "@/shared/thinkingIndicator"; | ||
| import { | ||
| type ToolExecutionMode, | ||
| toToolExecutionMode, | ||
| toToolExecutionSettings, | ||
| } from "@/shared/toolExecutionMode"; | ||
| import { | ||
| isThinkingVisible, | ||
| shouldStopGenerating, | ||
| } from "@/shared/thinkingIndicator"; | ||
|
|
||
| function normalizeStreamingMarkdown(content: string): string { | ||
| const fencePattern = /^(`{3,})[^`]*$/gm; | ||
|
|
@@ -118,7 +118,10 @@ export default function ChatPage() { | |
|
|
||
| const s = toToolExecutionSettings(mode); | ||
| await settings.set("autoApproveMcpTools", s.autoApproveMcpTools); | ||
| await settings.set("showMcpToolExecutionPanels", s.showMcpToolExecutionPanels); | ||
| await settings.set( | ||
| "showMcpToolExecutionPanels", | ||
| s.showMcpToolExecutionPanels, | ||
| ); | ||
| await settings.reload(); | ||
| }, | ||
| [settings, tools], | ||
|
|
@@ -180,8 +183,7 @@ export default function ChatPage() { | |
| continue; | ||
| } | ||
|
|
||
| const existingId = | ||
| typeof tc.id === "string" ? tc.id.trim() : ""; | ||
| const existingId = typeof tc.id === "string" ? tc.id.trim() : ""; | ||
| normalizedToolCalls.push({ | ||
| ...tc, | ||
| id: existingId || `local-tool-call-${localToolCallIdCounter.current++}`, | ||
|
|
@@ -637,7 +639,7 @@ export default function ChatPage() { | |
| const text: string[] = []; | ||
|
|
||
| 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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 Bug: This now only handles |
||
| images.push({ uri: c.image_url }); | ||
| continue; | ||
| } | ||
|
|
@@ -658,7 +660,7 @@ export default function ChatPage() { | |
| continue; | ||
| } | ||
|
|
||
| text.push(c.text); | ||
| text.push(c.text as string); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -667,7 +669,8 @@ export default function ChatPage() { | |
| const allToolCallsHidden = | ||
| hasToolCalls && | ||
| m.tool_calls!.every((tc) => { | ||
| const isAutoApproved = autoApproveTools || tools.isAllowedForSession(tc.name); | ||
| const isAutoApproved = | ||
| autoApproveTools || tools.isAllowedForSession(tc.name); | ||
| return isAutoApproved && !showToolExecutionPanels; | ||
| }); | ||
|
|
||
|
|
@@ -792,7 +795,10 @@ export default function ChatPage() { | |
| lastUserMessageYRef.current = y; | ||
| if (scrollPendingRef.current) { | ||
| scrollPendingRef.current = false; | ||
| scrollTargetRef.current = Math.max(0, y - SCROLL_TOP_GAP); | ||
| scrollTargetRef.current = Math.max( | ||
| 0, | ||
| y - SCROLL_TOP_GAP, | ||
| ); | ||
| setContentMinHeight(y + messagesViewHeight); | ||
| } | ||
| }} | ||
|
|
@@ -804,11 +810,15 @@ export default function ChatPage() { | |
|
|
||
| return <View key={i}>{messageContent}</View>; | ||
| })} | ||
| {isThinkingVisible(isGenerating, streamingContent) && <Chat.Thinking />} | ||
| {isThinkingVisible(isGenerating, streamingContent) && ( | ||
| <Chat.Thinking /> | ||
| )} | ||
| {streamingContent !== null && ( | ||
| <Chat.Message icon="assistant"> | ||
| <Markdown> | ||
| {normalizeStreamingMarkdown(stripThinkTags(streamingContent))} | ||
| {normalizeStreamingMarkdown( | ||
| stripThinkTags(streamingContent), | ||
| )} | ||
| </Markdown> | ||
| </Chat.Message> | ||
| )} | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 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_urlblocks and non-string/missing text fields so migration regressions are caught.