mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-04-07 00:15:23 +02:00
feat: simple COHERE_BASE_URL support using environment variable
Replace enum with dynamic getter to enable runtime environment variable lookup. CohereConstants.API_URL now automatically uses COHERE_BASE_URL if set, otherwise defaults to https://api.cohere.ai/v1. This enables using custom Cohere endpoints (like LiteLLM proxy) for web search reranking by simply setting the COHERE_BASE_URL environment variable. Usage: export COHERE_BASE_URL=http://litellm:8000/v1 export COHERE_API_KEY=your_api_key The change is backwards compatible and requires no configuration changes.
This commit is contained in:
parent
00a99aca0a
commit
d0c0602edb
2 changed files with 13 additions and 10 deletions
|
|
@ -814,7 +814,8 @@ OPENWEATHER_API_KEY=
|
|||
# JINA_API_KEY=your_jina_api_key
|
||||
# or
|
||||
# COHERE_API_KEY=your_cohere_api_key
|
||||
# COHERE_BASE_URL=your_custom_cohere_base_url
|
||||
# Optional: Custom Cohere API base URL (defaults to https://api.cohere.ai/v1)
|
||||
# COHERE_BASE_URL=http://litellm:8000/v1
|
||||
|
||||
#======================#
|
||||
# MCP Configuration #
|
||||
|
|
|
|||
|
|
@ -836,7 +836,6 @@ export const webSearchSchema = z.object({
|
|||
jinaApiKey: z.string().optional().default('${JINA_API_KEY}'),
|
||||
jinaApiUrl: z.string().optional().default('${JINA_API_URL}'),
|
||||
cohereApiKey: z.string().optional().default('${COHERE_API_KEY}'),
|
||||
cohereBaseUrl: z.string().optional().default('${COHERE_BASE_URL}'),
|
||||
searchProvider: z.nativeEnum(SearchProviders).optional(),
|
||||
scraperProvider: z.nativeEnum(ScraperProviders).optional(),
|
||||
rerankerType: z.nativeEnum(RerankerTypes).optional(),
|
||||
|
|
@ -1820,30 +1819,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_BASE_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_BASE_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',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue