Compare commits
8 Commits
added-code
...
refactor/A
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
924276d4b9 | ||
|
|
438392f705 | ||
|
|
c925f9f39c | ||
|
|
71effb1a66 | ||
|
|
e3acd18c07 | ||
|
|
d14a063302 | ||
|
|
a36426ef54 | ||
|
|
edcac7669b |
@@ -32,11 +32,15 @@ class AzureAISearch extends Tool {
|
||||
fields.AZURE_AI_SEARCH_SERVICE_ENDPOINT,
|
||||
'AZURE_AI_SEARCH_SERVICE_ENDPOINT',
|
||||
);
|
||||
this.indexName = this._initializeField(
|
||||
// Get the indexes as a comma-separated string
|
||||
this.indexNames = this._initializeField(
|
||||
fields.AZURE_AI_SEARCH_INDEX_NAME,
|
||||
'AZURE_AI_SEARCH_INDEX_NAME',
|
||||
);
|
||||
this.apiKey = this._initializeField(fields.AZURE_AI_SEARCH_API_KEY, 'AZURE_AI_SEARCH_API_KEY');
|
||||
this.apiKey = this._initializeField(
|
||||
fields.AZURE_AI_SEARCH_API_KEY,
|
||||
'AZURE_AI_SEARCH_API_KEY',
|
||||
);
|
||||
this.apiVersion = this._initializeField(
|
||||
fields.AZURE_AI_SEARCH_API_VERSION,
|
||||
'AZURE_AI_SEARCH_API_VERSION',
|
||||
@@ -58,7 +62,7 @@ class AzureAISearch extends Tool {
|
||||
);
|
||||
|
||||
// Check for required fields
|
||||
if (!this.override && (!this.serviceEndpoint || !this.indexName || !this.apiKey)) {
|
||||
if (!this.override && (!this.serviceEndpoint || !this.indexNames || !this.apiKey)) {
|
||||
throw new Error(
|
||||
'Missing AZURE_AI_SEARCH_SERVICE_ENDPOINT, AZURE_AI_SEARCH_INDEX_NAME, or AZURE_AI_SEARCH_API_KEY environment variable.',
|
||||
);
|
||||
@@ -68,12 +72,25 @@ class AzureAISearch extends Tool {
|
||||
return;
|
||||
}
|
||||
|
||||
// Create SearchClient
|
||||
this.client = new SearchClient(
|
||||
this.serviceEndpoint,
|
||||
this.indexName,
|
||||
new AzureKeyCredential(this.apiKey),
|
||||
{ apiVersion: this.apiVersion },
|
||||
// Split the indexNames by comma to support multiple indexes, trim whitespace,
|
||||
// convert to lowercase, and filter out any empty strings.
|
||||
const indexes = this.indexNames
|
||||
.split(',')
|
||||
.map(index => index.trim().toLowerCase())
|
||||
.filter(index => index.length > 0);
|
||||
|
||||
if (indexes.length === 0) {
|
||||
throw new Error('No valid index names provided in AZURE_AI_SEARCH_INDEX_NAME.');
|
||||
}
|
||||
|
||||
// Create a client for each index.
|
||||
this.clients = indexes.map(index =>
|
||||
new SearchClient(
|
||||
this.serviceEndpoint,
|
||||
index,
|
||||
new AzureKeyCredential(this.apiKey),
|
||||
{ apiVersion: this.apiVersion },
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -88,12 +105,21 @@ class AzureAISearch extends Tool {
|
||||
if (this.select) {
|
||||
searchOption.select = this.select.split(',');
|
||||
}
|
||||
const searchResults = await this.client.search(query, searchOption);
|
||||
const resultDocuments = [];
|
||||
for await (const result of searchResults.results) {
|
||||
resultDocuments.push(result.document);
|
||||
}
|
||||
return JSON.stringify(resultDocuments);
|
||||
|
||||
// Query all indexes concurrently
|
||||
const searchPromises = this.clients.map(async (client) => {
|
||||
const resultDocuments = [];
|
||||
const searchResults = await client.search(query, searchOption);
|
||||
for await (const result of searchResults.results) {
|
||||
resultDocuments.push(result.document);
|
||||
}
|
||||
return resultDocuments;
|
||||
});
|
||||
|
||||
// Wait for all search promises to complete and flatten the results
|
||||
const resultsByIndex = await Promise.all(searchPromises);
|
||||
const combinedResults = resultsByIndex.flat();
|
||||
return JSON.stringify(combinedResults);
|
||||
} catch (error) {
|
||||
logger.error('Azure AI Search request failed', error);
|
||||
return 'There was an error with Azure AI Search.';
|
||||
@@ -101,4 +127,4 @@ class AzureAISearch extends Tool {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = AzureAISearch;
|
||||
module.exports = AzureAISearch;
|
||||
@@ -26,6 +26,7 @@ function loadTurnstileConfig(config, configDefaults) {
|
||||
options: customTurnstile.options ?? defaults.options,
|
||||
});
|
||||
|
||||
|
||||
const enabled = Boolean(loadedTurnstile.siteKey);
|
||||
|
||||
if (enabled) {
|
||||
@@ -36,6 +37,7 @@ function loadTurnstileConfig(config, configDefaults) {
|
||||
logger.info('Turnstile is DISABLED (no siteKey provided).');
|
||||
}
|
||||
|
||||
|
||||
return loadedTurnstile;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ type TLoginFormProps = {
|
||||
const LoginForm: React.FC<TLoginFormProps> = ({ onSubmit, startupConfig, error, setError }) => {
|
||||
const localize = useLocalize();
|
||||
const { theme } = useContext(ThemeContext);
|
||||
|
||||
const {
|
||||
register,
|
||||
getValues,
|
||||
@@ -29,8 +28,10 @@ const LoginForm: React.FC<TLoginFormProps> = ({ onSubmit, startupConfig, error,
|
||||
const { data: config } = useGetStartupConfig();
|
||||
const useUsernameLogin = config?.ldap?.username;
|
||||
const validTheme = theme === 'dark' ? 'dark' : 'light';
|
||||
|
||||
const requireCaptcha = Boolean(startupConfig.turnstile?.siteKey);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
if (error && error.includes('422') && !showResendLink) {
|
||||
setShowResendLink(true);
|
||||
@@ -150,6 +151,7 @@ const LoginForm: React.FC<TLoginFormProps> = ({ onSubmit, startupConfig, error,
|
||||
</a>
|
||||
)}
|
||||
|
||||
|
||||
{requireCaptcha && (
|
||||
<div className="my-4 flex justify-center">
|
||||
<Turnstile
|
||||
|
||||
@@ -32,7 +32,6 @@ const Registration: React.FC = () => {
|
||||
const queryParams = new URLSearchParams(location.search);
|
||||
const token = queryParams.get('token');
|
||||
const validTheme = theme === 'dark' ? 'dark' : 'light';
|
||||
|
||||
// only require captcha if we have a siteKey
|
||||
const requireCaptcha = Boolean(startupConfig?.turnstile?.siteKey);
|
||||
|
||||
@@ -179,6 +178,7 @@ const Registration: React.FC = () => {
|
||||
})}
|
||||
|
||||
{startupConfig?.turnstile?.siteKey && (
|
||||
|
||||
<div className="my-4 flex justify-center">
|
||||
<Turnstile
|
||||
siteKey={startupConfig.turnstile.siteKey}
|
||||
@@ -198,6 +198,7 @@ const Registration: React.FC = () => {
|
||||
disabled={
|
||||
Object.keys(errors).length > 0 ||
|
||||
isSubmitting ||
|
||||
|
||||
(requireCaptcha && !turnstileToken)
|
||||
}
|
||||
type="submit"
|
||||
|
||||
@@ -53,6 +53,7 @@ export default function AgentFooter({
|
||||
const showButtons = activePanel === Panel.builder;
|
||||
|
||||
return (
|
||||
|
||||
<div className="mb-1 flex w-full flex-col gap-2">
|
||||
{showButtons && <AdvancedButton setActivePanel={setActivePanel} />}
|
||||
{showButtons && agent_id && <VersionButton setActivePanel={setActivePanel} />}
|
||||
|
||||
Reference in New Issue
Block a user