eslint fix
This commit is contained in:
parent
8c142f89b7
commit
5172cf9069
7 changed files with 58 additions and 44 deletions
|
|
@ -127,7 +127,6 @@ function ChatPage() {
|
||||||
const [dropdownDismissed, setDropdownDismissed] = useState(false);
|
const [dropdownDismissed, setDropdownDismissed] = useState(false);
|
||||||
const [isUserInteracting, setIsUserInteracting] = useState(false);
|
const [isUserInteracting, setIsUserInteracting] = useState(false);
|
||||||
const [isForkingInProgress, setIsForkingInProgress] = useState(false);
|
const [isForkingInProgress, setIsForkingInProgress] = useState(false);
|
||||||
const [lastForkTimestamp, setLastForkTimestamp] = useState<number>(0);
|
|
||||||
const dragCounterRef = useRef(0);
|
const dragCounterRef = useRef(0);
|
||||||
const messagesEndRef = useRef<HTMLDivElement>(null);
|
const messagesEndRef = useRef<HTMLDivElement>(null);
|
||||||
const inputRef = useRef<HTMLTextAreaElement>(null);
|
const inputRef = useRef<HTMLTextAreaElement>(null);
|
||||||
|
|
@ -454,8 +453,15 @@ function ChatPage() {
|
||||||
content: string;
|
content: string;
|
||||||
timestamp?: string;
|
timestamp?: string;
|
||||||
response_id?: string;
|
response_id?: string;
|
||||||
chunks?: any[];
|
chunks?: Array<{
|
||||||
response_data?: any;
|
item?: { type?: string; tool_name?: string; id?: string; inputs?: unknown; results?: unknown; status?: string };
|
||||||
|
delta?: { tool_calls?: Array<{ id?: string; function?: { name?: string; arguments?: string }; type?: string }> };
|
||||||
|
type?: string;
|
||||||
|
result?: unknown;
|
||||||
|
output?: unknown;
|
||||||
|
response?: unknown;
|
||||||
|
}>;
|
||||||
|
response_data?: unknown;
|
||||||
}) => {
|
}) => {
|
||||||
const message: Message = {
|
const message: Message = {
|
||||||
role: msg.role as "user" | "assistant",
|
role: msg.role as "user" | "assistant",
|
||||||
|
|
@ -480,12 +486,12 @@ function ChatPage() {
|
||||||
const toolCall = chunk.item;
|
const toolCall = chunk.item;
|
||||||
console.log("Found Langflow tool call:", toolCall);
|
console.log("Found Langflow tool call:", toolCall);
|
||||||
functionCalls.push({
|
functionCalls.push({
|
||||||
id: toolCall.id,
|
id: toolCall.id || "",
|
||||||
name: toolCall.tool_name,
|
name: toolCall.tool_name || "unknown",
|
||||||
arguments: toolCall.inputs || {},
|
arguments: (toolCall.inputs as Record<string, unknown>) || {},
|
||||||
argumentsString: JSON.stringify(toolCall.inputs || {}),
|
argumentsString: JSON.stringify(toolCall.inputs || {}),
|
||||||
result: toolCall.results,
|
result: toolCall.results as Record<string, unknown> | ToolCallResult[],
|
||||||
status: toolCall.status || "completed",
|
status: (toolCall.status as "pending" | "completed" | "error") || "completed",
|
||||||
type: "tool_call",
|
type: "tool_call",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -494,10 +500,10 @@ function ChatPage() {
|
||||||
for (const toolCall of chunk.delta.tool_calls) {
|
for (const toolCall of chunk.delta.tool_calls) {
|
||||||
if (toolCall.function) {
|
if (toolCall.function) {
|
||||||
functionCalls.push({
|
functionCalls.push({
|
||||||
id: toolCall.id,
|
id: toolCall.id || "",
|
||||||
name: toolCall.function.name,
|
name: toolCall.function.name || "unknown",
|
||||||
arguments: toolCall.function.arguments ? JSON.parse(toolCall.function.arguments) : {},
|
arguments: toolCall.function.arguments ? JSON.parse(toolCall.function.arguments) : {},
|
||||||
argumentsString: toolCall.function.arguments,
|
argumentsString: toolCall.function.arguments || "",
|
||||||
status: "completed",
|
status: "completed",
|
||||||
type: toolCall.type || "function",
|
type: toolCall.type || "function",
|
||||||
});
|
});
|
||||||
|
|
@ -508,7 +514,7 @@ function ChatPage() {
|
||||||
if (chunk.type === "response.tool_call.result" || chunk.type === "tool_call_result") {
|
if (chunk.type === "response.tool_call.result" || chunk.type === "tool_call_result") {
|
||||||
const lastCall = functionCalls[functionCalls.length - 1];
|
const lastCall = functionCalls[functionCalls.length - 1];
|
||||||
if (lastCall) {
|
if (lastCall) {
|
||||||
lastCall.result = chunk.result || chunk;
|
lastCall.result = (chunk.result as Record<string, unknown> | ToolCallResult[]) || (chunk as Record<string, unknown>);
|
||||||
lastCall.status = "completed";
|
lastCall.status = "completed";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -562,6 +568,7 @@ function ChatPage() {
|
||||||
conversationData,
|
conversationData,
|
||||||
isUserInteracting,
|
isUserInteracting,
|
||||||
isForkingInProgress,
|
isForkingInProgress,
|
||||||
|
setPreviousResponseIds,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Handle new conversation creation - only reset messages when placeholderConversation is set
|
// Handle new conversation creation - only reset messages when placeholderConversation is set
|
||||||
|
|
@ -1536,10 +1543,8 @@ function ChatPage() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set interaction state to prevent auto-scroll interference
|
// Set interaction state to prevent auto-scroll interference
|
||||||
const forkTimestamp = Date.now();
|
|
||||||
setIsUserInteracting(true);
|
setIsUserInteracting(true);
|
||||||
setIsForkingInProgress(true);
|
setIsForkingInProgress(true);
|
||||||
setLastForkTimestamp(forkTimestamp);
|
|
||||||
|
|
||||||
console.log("Fork conversation called for message index:", messageIndex);
|
console.log("Fork conversation called for message index:", messageIndex);
|
||||||
|
|
||||||
|
|
@ -1552,7 +1557,6 @@ function ChatPage() {
|
||||||
console.error("Fork button should only be on assistant messages");
|
console.error("Fork button should only be on assistant messages");
|
||||||
setIsUserInteracting(false);
|
setIsUserInteracting(false);
|
||||||
setIsForkingInProgress(false);
|
setIsForkingInProgress(false);
|
||||||
setLastForkTimestamp(0);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,14 @@ export default function ConnectorsPage() {
|
||||||
const { addTask } = useTask()
|
const { addTask } = useTask()
|
||||||
const [selectedFiles, setSelectedFiles] = useState<GoogleDriveFile[]>([]);
|
const [selectedFiles, setSelectedFiles] = useState<GoogleDriveFile[]>([]);
|
||||||
const [isSyncing, setIsSyncing] = useState<boolean>(false);
|
const [isSyncing, setIsSyncing] = useState<boolean>(false);
|
||||||
const [syncResult, setSyncResult] = useState<any>(null);
|
const [syncResult, setSyncResult] = useState<{
|
||||||
|
processed?: number;
|
||||||
|
total?: number;
|
||||||
|
status?: string;
|
||||||
|
error?: string;
|
||||||
|
added?: number;
|
||||||
|
errors?: number;
|
||||||
|
} | null>(null);
|
||||||
|
|
||||||
const handleFileSelection = (files: GoogleDriveFile[]) => {
|
const handleFileSelection = (files: GoogleDriveFile[]) => {
|
||||||
setSelectedFiles(files);
|
setSelectedFiles(files);
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ interface OneDriveFile {
|
||||||
webUrl?: string
|
webUrl?: string
|
||||||
driveItem?: {
|
driveItem?: {
|
||||||
file?: { mimeType: string }
|
file?: { mimeType: string }
|
||||||
folder?: any
|
folder?: unknown
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ interface OneDriveFile {
|
||||||
webUrl?: string
|
webUrl?: string
|
||||||
driveItem?: {
|
driveItem?: {
|
||||||
file?: { mimeType: string }
|
file?: { mimeType: string }
|
||||||
folder?: object
|
folder?: unknown
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -157,6 +157,14 @@ export default function UploadProviderPage() {
|
||||||
// You can add additional handling here like triggering sync, etc.
|
// You can add additional handling here like triggering sync, etc.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleGoogleDriveFileSelected = (files: GoogleDriveFile[]) => {
|
||||||
|
handleFileSelected(files)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleOneDriveFileSelected = (files: OneDriveFile[]) => {
|
||||||
|
handleFileSelected(files)
|
||||||
|
}
|
||||||
|
|
||||||
const handleSync = async (connector: CloudConnector) => {
|
const handleSync = async (connector: CloudConnector) => {
|
||||||
if (!connector.connectionId || selectedFiles.length === 0) return
|
if (!connector.connectionId || selectedFiles.length === 0) return
|
||||||
|
|
||||||
|
|
@ -323,7 +331,7 @@ export default function UploadProviderPage() {
|
||||||
<div className="max-w-3xl mx-auto">
|
<div className="max-w-3xl mx-auto">
|
||||||
{connector.type === "google_drive" && (
|
{connector.type === "google_drive" && (
|
||||||
<GoogleDrivePicker
|
<GoogleDrivePicker
|
||||||
onFileSelected={handleFileSelected}
|
onFileSelected={handleGoogleDriveFileSelected}
|
||||||
selectedFiles={selectedFiles as GoogleDriveFile[]}
|
selectedFiles={selectedFiles as GoogleDriveFile[]}
|
||||||
isAuthenticated={true}
|
isAuthenticated={true}
|
||||||
accessToken={accessToken || undefined}
|
accessToken={accessToken || undefined}
|
||||||
|
|
@ -332,7 +340,7 @@ export default function UploadProviderPage() {
|
||||||
|
|
||||||
{(connector.type === "onedrive" || connector.type === "sharepoint") && (
|
{(connector.type === "onedrive" || connector.type === "sharepoint") && (
|
||||||
<OneDrivePicker
|
<OneDrivePicker
|
||||||
onFileSelected={handleFileSelected}
|
onFileSelected={handleOneDriveFileSelected}
|
||||||
selectedFiles={selectedFiles as OneDriveFile[]}
|
selectedFiles={selectedFiles as OneDriveFile[]}
|
||||||
isAuthenticated={true}
|
isAuthenticated={true}
|
||||||
accessToken={accessToken || undefined}
|
accessToken={accessToken || undefined}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
import { useState, useEffect, useCallback } from "react"
|
import { useState, useEffect, useCallback } from "react"
|
||||||
import { Button } from "@/components/ui/button"
|
import { Button } from "@/components/ui/button"
|
||||||
import { Badge } from "@/components/ui/badge"
|
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogContent,
|
DialogContent,
|
||||||
|
|
@ -29,7 +28,7 @@ interface OneDriveFile {
|
||||||
webUrl?: string
|
webUrl?: string
|
||||||
driveItem?: {
|
driveItem?: {
|
||||||
file?: { mimeType: string }
|
file?: { mimeType: string }
|
||||||
folder?: any
|
folder?: unknown
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -61,7 +60,6 @@ export function CloudConnectorsDialog({
|
||||||
const [selectedFiles, setSelectedFiles] = useState<{[connectorId: string]: GoogleDriveFile[] | OneDriveFile[]}>({})
|
const [selectedFiles, setSelectedFiles] = useState<{[connectorId: string]: GoogleDriveFile[] | OneDriveFile[]}>({})
|
||||||
const [connectorAccessTokens, setConnectorAccessTokens] = useState<{[connectorType: string]: string}>({})
|
const [connectorAccessTokens, setConnectorAccessTokens] = useState<{[connectorType: string]: string}>({})
|
||||||
const [activePickerType, setActivePickerType] = useState<string | null>(null)
|
const [activePickerType, setActivePickerType] = useState<string | null>(null)
|
||||||
const [isGooglePickerOpen, setIsGooglePickerOpen] = useState(false)
|
|
||||||
|
|
||||||
const getConnectorIcon = (iconName: string) => {
|
const getConnectorIcon = (iconName: string) => {
|
||||||
const iconMap: { [key: string]: React.ReactElement } = {
|
const iconMap: { [key: string]: React.ReactElement } = {
|
||||||
|
|
@ -129,7 +127,7 @@ export function CloudConnectorsDialog({
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
const data = await response.json()
|
const data = await response.json()
|
||||||
const connections = data.connections || []
|
const connections = data.connections || []
|
||||||
const activeConnection = connections.find((conn: any) => conn.is_active)
|
const activeConnection = connections.find((conn: { connection_id: string; is_active: boolean }) => conn.is_active)
|
||||||
const isConnected = activeConnection !== undefined
|
const isConnected = activeConnection !== undefined
|
||||||
|
|
||||||
let hasAccessToken = false
|
let hasAccessToken = false
|
||||||
|
|
@ -152,7 +150,7 @@ export function CloudConnectorsDialog({
|
||||||
const errorData = await tokenResponse.json().catch(() => ({ error: 'Token unavailable' }))
|
const errorData = await tokenResponse.json().catch(() => ({ error: 'Token unavailable' }))
|
||||||
accessTokenError = errorData.error || 'Access token unavailable'
|
accessTokenError = errorData.error || 'Access token unavailable'
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch {
|
||||||
accessTokenError = 'Failed to fetch access token'
|
accessTokenError = 'Failed to fetch access token'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -260,12 +258,11 @@ export function CloudConnectorsDialog({
|
||||||
onFileSelected={(files) => {
|
onFileSelected={(files) => {
|
||||||
handleFileSelection(connector.id, files)
|
handleFileSelection(connector.id, files)
|
||||||
setActivePickerType(null)
|
setActivePickerType(null)
|
||||||
setIsGooglePickerOpen(false)
|
|
||||||
}}
|
}}
|
||||||
selectedFiles={selectedFiles[connector.id] as GoogleDriveFile[] || []}
|
selectedFiles={selectedFiles[connector.id] as GoogleDriveFile[] || []}
|
||||||
isAuthenticated={connector.status === "connected"}
|
isAuthenticated={connector.status === "connected"}
|
||||||
accessToken={connectorAccessTokens[connector.type]}
|
accessToken={connectorAccessTokens[connector.type]}
|
||||||
onPickerStateChange={setIsGooglePickerOpen}
|
onPickerStateChange={() => {}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ interface OneDriveFile {
|
||||||
webUrl?: string
|
webUrl?: string
|
||||||
driveItem?: {
|
driveItem?: {
|
||||||
file?: { mimeType: string }
|
file?: { mimeType: string }
|
||||||
folder?: any
|
folder?: unknown
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ interface OneDriveFile {
|
||||||
webUrl?: string
|
webUrl?: string
|
||||||
driveItem?: {
|
driveItem?: {
|
||||||
file?: { mimeType: string }
|
file?: { mimeType: string }
|
||||||
folder?: any
|
folder?: unknown
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -32,8 +32,8 @@ interface GraphResponse {
|
||||||
declare global {
|
declare global {
|
||||||
interface Window {
|
interface Window {
|
||||||
mgt?: {
|
mgt?: {
|
||||||
Providers: {
|
Providers?: {
|
||||||
globalProvider: any
|
globalProvider?: unknown
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -58,21 +58,19 @@ export function OneDrivePicker({
|
||||||
])
|
])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadMGT = async () => {
|
const loadMGT = async () => {
|
||||||
if (typeof window !== 'undefined' && !window.mgt) {
|
if (typeof window !== 'undefined' && !window.mgt) {
|
||||||
try {
|
try {
|
||||||
const mgtModule = await import('@microsoft/mgt-components')
|
await import('@microsoft/mgt-components')
|
||||||
const mgtProvider = await import('@microsoft/mgt-msal2-provider')
|
await import('@microsoft/mgt-msal2-provider')
|
||||||
|
|
||||||
// Initialize provider if needed
|
// For simplicity, we'll use direct Graph API calls instead of MGT components
|
||||||
if (!window.mgt?.Providers?.globalProvider && accessToken) {
|
// MGT provider initialization would go here if needed
|
||||||
// For simplicity, we'll use direct Graph API calls instead of MGT components
|
} catch {
|
||||||
}
|
console.warn('MGT not available, falling back to direct API calls')
|
||||||
} catch (error) {
|
|
||||||
console.warn('MGT not available, falling back to direct API calls')
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
loadMGT()
|
loadMGT()
|
||||||
}, [accessToken])
|
}, [accessToken])
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue