Patch UI bug with agent skill web-search and sql-connector ()

* Patch UI bug with agent skill

* wrap call in try/catch for failures
res?. optional call for settings since null is default

* uncheck
This commit is contained in:
Timothy Carambat 2024-09-13 17:46:24 -07:00 committed by GitHub
parent b557a289fe
commit 644a35a32a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 7 deletions
frontend/src/pages/Admin/Agents
SQLConnectorSelection
WebSearchSelection

View file

@ -1,21 +1,26 @@
import React, { useState } from "react";
import React, { useEffect, useState } from "react";
import DBConnection from "./DBConnection";
import { Plus, Database } from "@phosphor-icons/react";
import NewSQLConnection from "./NewConnectionModal";
import { useModal } from "@/hooks/useModal";
import SQLAgentImage from "@/media/agents/sql-agent.png";
import Admin from "@/models/admin";
export default function AgentSQLConnectorSelection({
skill,
settings,
settings, // unused.
toggleSkill,
enabled = false,
setHasChanges,
}) {
const { isOpen, openModal, closeModal } = useModal();
const [connections, setConnections] = useState(
settings?.preferences?.agent_sql_connections || []
);
const [connections, setConnections] = useState([]);
useEffect(() => {
Admin.systemPreferencesByFields(["agent_sql_connections"])
.then((res) => setConnections(res?.settings?.agent_sql_connections ?? []))
.catch(() => setConnections([]));
}, []);
return (
<>
<div className="p-2">

View file

@ -1,4 +1,5 @@
import React, { useEffect, useRef, useState } from "react";
import Admin from "@/models/admin";
import AnythingLLMIcon from "@/media/logo/anything-llm-icon.png";
import GoogleSearchIcon from "./icons/google.png";
import SearchApiIcon from "./icons/searchapi.png";
@ -119,8 +120,12 @@ export default function AgentWebSearchSelection({
}, [searchQuery, selectedProvider]);
useEffect(() => {
setSelectedProvider(settings?.preferences?.agent_search_provider ?? "none");
}, [settings?.preferences?.agent_search_provider]);
Admin.systemPreferencesByFields(["agent_search_provider"])
.then((res) =>
setSelectedProvider(res?.settings?.agent_search_provider ?? "none")
)
.catch(() => setSelectedProvider("none"));
}, []);
const selectedSearchProviderObject = SEARCH_PROVIDERS.find(
(provider) => provider.value === selectedProvider