mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-04-07 00:15:23 +02:00
Merge d4edaafcf7 into 8ed0bcf5ca
This commit is contained in:
commit
cfc4cc788c
5 changed files with 26 additions and 10 deletions
|
|
@ -838,6 +838,8 @@ OPENWEATHER_API_KEY=
|
|||
# JINA_API_KEY=your_jina_api_key
|
||||
# or
|
||||
# COHERE_API_KEY=your_cohere_api_key
|
||||
# Optional: Custom Cohere API URL (defaults to https://api.cohere.ai/v1)
|
||||
# COHERE_API_URL=http://litellm:8000/v1
|
||||
|
||||
#======================#
|
||||
# MCP Configuration #
|
||||
|
|
|
|||
|
|
@ -1959,30 +1959,33 @@ export enum ForkOptions {
|
|||
}
|
||||
|
||||
/**
|
||||
* Enum for Cohere related constants
|
||||
* Cohere related constants
|
||||
*/
|
||||
export enum CohereConstants {
|
||||
export const CohereConstants = {
|
||||
/**
|
||||
* Cohere API Endpoint, for special handling
|
||||
* Uses COHERE_API_URL environment variable if set, otherwise defaults to official API
|
||||
*/
|
||||
API_URL = 'https://api.cohere.ai/v1',
|
||||
get API_URL(): string {
|
||||
return process.env.COHERE_API_URL || 'https://api.cohere.ai/v1';
|
||||
},
|
||||
/**
|
||||
* Role for "USER" messages
|
||||
*/
|
||||
ROLE_USER = 'USER',
|
||||
ROLE_USER: 'USER' as const,
|
||||
/**
|
||||
* Role for "SYSTEM" messages
|
||||
*/
|
||||
ROLE_SYSTEM = 'SYSTEM',
|
||||
ROLE_SYSTEM: 'SYSTEM' as const,
|
||||
/**
|
||||
* Role for "CHATBOT" messages
|
||||
*/
|
||||
ROLE_CHATBOT = 'CHATBOT',
|
||||
ROLE_CHATBOT: 'CHATBOT' as const,
|
||||
/**
|
||||
* Title message as required by Cohere
|
||||
*/
|
||||
TITLE_MESSAGE = 'TITLE:',
|
||||
}
|
||||
TITLE_MESSAGE: 'TITLE:' as const,
|
||||
} as const;
|
||||
|
||||
export enum SystemCategories {
|
||||
ALL = 'sys__all__sys',
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ describe('loadWebSearchConfig', () => {
|
|||
jinaApiKey: '${JINA_API_KEY}',
|
||||
jinaApiUrl: '${JINA_API_URL}',
|
||||
cohereApiKey: '${COHERE_API_KEY}',
|
||||
cohereApiUrl: '${COHERE_API_URL}',
|
||||
safeSearch: SafeSearchTypes.MODERATE,
|
||||
});
|
||||
});
|
||||
|
|
@ -154,6 +155,7 @@ describe('loadWebSearchConfig', () => {
|
|||
expect(result?.searxngInstanceUrl).toBe('${SEARXNG_INSTANCE_URL}');
|
||||
expect(result?.firecrawlApiUrl).toBe('${FIRECRAWL_API_URL}');
|
||||
expect(result?.jinaApiUrl).toBe('${JINA_API_URL}');
|
||||
expect(result?.cohereApiUrl).toBe('${COHERE_API_URL}');
|
||||
});
|
||||
|
||||
it('should preserve custom URLs', () => {
|
||||
|
|
@ -161,6 +163,7 @@ describe('loadWebSearchConfig', () => {
|
|||
searxngInstanceUrl: 'https://custom-searxng.com',
|
||||
firecrawlApiUrl: 'https://custom-firecrawl.com',
|
||||
jinaApiUrl: 'https://custom-jina.com',
|
||||
cohereApiUrl: 'https://custom-cohere.com',
|
||||
};
|
||||
|
||||
const result = loadWebSearchConfig(config);
|
||||
|
|
@ -168,6 +171,7 @@ describe('loadWebSearchConfig', () => {
|
|||
expect(result?.searxngInstanceUrl).toBe('https://custom-searxng.com');
|
||||
expect(result?.firecrawlApiUrl).toBe('https://custom-firecrawl.com');
|
||||
expect(result?.jinaApiUrl).toBe('https://custom-jina.com');
|
||||
expect(result?.cohereApiUrl).toBe('https://custom-cohere.com');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -30,7 +30,11 @@ export const webSearchAuth = {
|
|||
/** Optional (0) */
|
||||
jinaApiUrl: 0 as const,
|
||||
},
|
||||
cohere: { cohereApiKey: 1 as const },
|
||||
cohere: {
|
||||
cohereApiKey: 1 as const,
|
||||
/** Optional (0) */
|
||||
cohereApiUrl: 0 as const,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
|
|
@ -72,6 +76,7 @@ export function loadWebSearchConfig(
|
|||
const jinaApiKey = config?.jinaApiKey ?? '${JINA_API_KEY}';
|
||||
const jinaApiUrl = config?.jinaApiUrl ?? '${JINA_API_URL}';
|
||||
const cohereApiKey = config?.cohereApiKey ?? '${COHERE_API_KEY}';
|
||||
const cohereApiUrl = config?.cohereApiUrl ?? '${COHERE_API_URL}';
|
||||
const safeSearch = config?.safeSearch ?? SafeSearchTypes.MODERATE;
|
||||
|
||||
return {
|
||||
|
|
@ -80,6 +85,7 @@ export function loadWebSearchConfig(
|
|||
jinaApiKey,
|
||||
jinaApiUrl,
|
||||
cohereApiKey,
|
||||
cohereApiUrl,
|
||||
serperApiKey,
|
||||
searxngApiKey,
|
||||
firecrawlApiKey,
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@ export type TWebSearchKeys =
|
|||
| 'firecrawlVersion'
|
||||
| 'jinaApiKey'
|
||||
| 'jinaApiUrl'
|
||||
| 'cohereApiKey';
|
||||
| 'cohereApiKey'
|
||||
| 'cohereApiUrl';
|
||||
|
||||
export type TWebSearchCategories =
|
||||
| SearchCategories.PROVIDERS
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue