* Add billing organization selection
Introduces support for selecting a billing organization for inference requests in HuggingChat. Adds a new billing section in application settings, updates user settings and API to store and validate the selected organization, and ensures requests are billed to the chosen organization by sending the X-HF-Bill-To header. Also updates environment and chart files to include the new OpenID scope required for billing.
* Update +page.svelte
* Remove billingOrganization from default settings
* Fix user settings creation and update test for findUser
The test for updateUser now passes a URL to findUser to match the updated function signature. Also, the updateUser function now inserts the full DEFAULT_SETTINGS object when creating default user settings, ensuring billingOrganization is included.
Refactor file handling for multimodal chat messages
Moved message and file preparation logic to a shared utility (prepareFiles.ts) for OpenAI-compatible multimodal payloads. Updated endpointOai and runMcpFlow to use the new prepareMessagesWithFiles function, improving code reuse and maintainability.
* Update ServerCard.svelte
feat(mcp): add Model Context Protocol integration with tool support
Improve MCP tools caching and server selection logic
Replaces single-entry MCP tools cache with a multi-keyed cache based on server configuration, improving cache accuracy for different server sets. Refactors server selection logic in runMcpFlow to better handle custom server lists and selected server names. Removes MCP flow from generate.ts, streamlining text generation logic.
* Add OAuth authentication for MCP servers
Introduces browser-based OAuth flow for MCP servers, including new auth helpers, localStorage management, and UI actions for authentication and sign-out. Server cards now support authentication, and enabled servers include persisted auth headers for API requests. Adds callback handler and route for OAuth completion.
* Add server authentication status and UI indicators
Introduces an 'authRequired' property to MCPServer and health check responses to indicate when authenti…
Handle empty system messages in preprocessing and OpenAI endpoint
Added logic to strip initial system messages with empty content during message preprocessing and normalized preprompt handling in the OpenAI endpoint. This prevents sending empty system prompts to providers and ensures preprompts are only prepended or inserted when non-empty.
* Replace file upload button with bits-ui DropdownMenu
Replaces the previous file upload button and tooltip with a DropdownMenu from bits-ui, providing a more modern UI for file/image uploads in ChatInput.svelte. Adds new dependencies to package.json for bits-ui and related packages.
* Add URL file fetch modal to chat input
Introduces UrlFetchModal.svelte for fetching files from HTTPS URLs and adds it to ChatInput.svelte. Updates file upload dropdown to support uploading text files from device or URL, and refines mime type handling in ChatWindow.svelte to always allow common text-like files and images for multimodal models.
* Copy shared files when creating conversation from share
Adds logic to duplicate files from a shared conversation to a new conversation when created from a share. Files are renamed and metadata is updated to associate them with the new conversation.
* Centralize MIME type allowlists and update usage
Introduces src/lib/constants/mime.ts to centralize text and…
* Add custom scrollbar class to Modal component
Applied the 'scrollbar-custom' class to the Modal's main container to enable custom scrollbar styling. This improves the appearance and consistency of scrollbars within modals.
* Add support for loading attachments from URLs
Implements the ability to load file attachments via URL parameters using a new utility (loadAttachmentsFromUrls) and a server-side proxy endpoint (/api/fetch-url) to securely fetch remote files. Updates chat and model pages to handle 'attachments' query parameters, injects file content into user messages, and improves multimodal message preparation. Also includes minor UI adjustments for file display and refactors Plausible analytics script initialization.
* Block redirects in fetch-url API endpoint
* Add custom scrollbar class to Modal component
Applied the 'scrollbar-custom' class to the Modal's main container to enable custom scrollbar styling. This improves the appearance and consistency of scrollbars within modals.
* Add support for loading attachments from URLs
Implements the ability to load file attachments via URL parameters using a new utility (loadAttachmentsFromUrls) and a server-side proxy endpoint (/api/fetch-url) to securely fetch remote files. Updates chat and model pages to handle 'attachments' query parameters, injects file content into user messages, and improves multimodal message preparation. Also includes minor UI adjustments for file display and refactors Plausible analytics script initialization.
Adds a 'User-Agent: huggingchat' header to OpenAI API requests when the PUBLIC_APP_NAME is 'HuggingChat', ensuring proper identification of requests from HuggingChat.
Reduce max image dimensions in OAI parameters schema
Lowered the maxWidth and maxHeight for images from 2048 to 1024 in the endpointOAIParametersSchema. This change restricts the allowed image size for uploads, possibly to improve performance or comply with new requirements.
Removes the logic that ignored stray </think> tags when no <think> was open, allowing <think> tags in content to pass through. This supports models like DeepSeek R1 that may include these tags in their output.
Add provider info to router metadata in chat messages
Extends router metadata to include a 'provider' field throughout the backend and frontend, allowing display of provider information alongside route and model in chat messages. Updates types, message update handling, and UI rendering to support and show provider details when available.
* Add AbortRegistry for user-initiated generation cancellation
Introduces an AbortRegistry singleton to track and manage AbortControllers for active conversation generations, enabling user-initiated cancellation of ongoing requests. Updates text generation and endpoint logic to support abort signals, and ensures proper cleanup and partial response handling when a generation is aborted. The stop-generating endpoint now triggers aborts via the registry.
* Remove 'continue message' feature from chat flow
Eliminated the 'continue message' functionality and related code, including the ContinueBtn component, associated props, and logic in both frontend and backend. This simplifies the message handling flow and removes unused parameters and UI elements.
Automatic login (#1900)
Eliott C.
Unverified signature
248183e
* Automatic login
* update debug message with correct port
* fix passing forward token
fix CI (#1884)
Eliott C.
Unverified signature
2883086
* fix CI
* add playwright as dev dep
* lint
* clean up spaces-config with community tools
* try to make mongo run?
Refactor token parameters to standardize naming across models and generation settings
* refactor: remove tokenizer-related functionality and dependencies
- Removed tokenizer dependencies from package.json.
- Deleted TokensCounter component and its usages across the application.
- Updated model configurations to exclude tokenizer properties.
- Refactored model processing logic to support only OpenAI-compatible endpoints.
- Adjusted API responses to omit tokenizer information.
- Cleaned up related utility functions and imports.
* Remove web search functionality and related components
- Deleted endpoints for various web search APIs (serpApi, serpStack, serper, webLocal, youApi).
- Removed generateQuery function and its usage in search.
- Eliminated web search related types and interfaces from the codebase.
- Updated Assistant and Conversation types to remove references to web search and embedding models.
- Cleaned up related utility functions and message updates for web search.
- Adjusted API routes and components to reflect the removal of web search features.
- Updated…
* feat(config): wip, make config controllable from DB, public side for now
* fix: build
* feat(config): add config manager env var toggle
* wip: make backend config use config manager
* fix: typechecks
* fix: circular import
* refactor: init hook sveltekit
* fix: disable config manager during tests
* refactor: use enum for semaphore, move delete from auto after 60s to separate `deleteAt` field
* feat: config manager checks for updates on requests
* fix: config script exit
* fix: remove top-level awaits
* fix: script await
* feat: filter config keys based on public environment variables for more security
* fix: change import to type for public environment variables
Fix system message handling to preserve user-configured system prompts (#1764)
stoXe+1: nsarrazin
Unverified signature
6370857
Previously, when a preprompt was provided, it would completely replace any user-configured system message instead of being prepended to it.
Co-authored-by: Nathan Sarrazin <sarrazin.nathan@gmail.com>
Add `toolId` to ToolCall and use it in tool results (#1787)
Kelig+1: Kelig LEFEUVRE
Unverified signature
6f95791
* Add `toolId` to ToolCall and use it in tool results
* Make `toolId` optional in ToolCall interface
---------
Co-authored-by: Kelig LEFEUVRE <klefeuvre@alpes-controles.fr>
fix(endpoints): fix for tool calling on hf inference with openai endpoint type (#1754)
* fix(openai): systemRoleSupported model configuration for openai endpoints
* feat(openai): max_completion_tokens now used over max_tokens for chat_completeions endpoint.
* fix: lint
* feat(docs): add o1 example
* fix: make parameter default to false and fix type checks
---------
Co-authored-by: Nathan Sarrazin <sarrazin.nathan@gmail.com>
Fix/oai parameters 1552 (#1557)
evalstate
Unverified signature
52dfa8c
* support temperature between 0 and 2
* added parsing of presence_penalty from model parameters. OAI endpoint now correctly uses (frequency penalty=parameters.repetition penalty) and (presence penalty=parameters.presence_penalty) for both chat and completion paths.
* added parsing of presence_penalty from model parameters. OAI endpoint now correctly uses (frequency penalty=parameters.repetition penalty) and (presence penalty=parameters.presence_penalty) for both chat and completion paths.
fix(endpoint): fallback to hf token for openai endpoint type
* feat(tools): Basic tool support for OpenAI models
* feat(tools): Basic tool support for OpenAI models
* fix: tools with document input (not image)
* fix: double yield of streaming tokens
* fix: boolean parameter processing error
took me a while to find this one lol
* feat: throw error if using tools in `completions` mode
* feat: fix image processing in tools mode
* fix: remove correlationKey and clean up types
---------
Co-authored-by: Jacob Gladish <jacob_gladish@comcast.com>
Co-authored-by: Nathan Sarrazin <sarrazin.nathan@gmail.com>
fix(openai): do not throw "Generation failed" when finish_reason="length" (#1429)
* Extend endpointOai.ts to allow usage of extra sampling parameters when calling vllm as an OpenAI compatible
* refactor : prettier endpointOai.ts
* Fix: Corrected type imports in endpointOai.ts
* Simplifies code a bit and adds `extraBody` to open ai endpooint
* Update zod schema to allow any type in extraBody
---------
Co-authored-by: Nathan Sarrazin <sarrazin.nathan@gmail.com>
* Add healthcheck route
* Add prom client with basic metrics
* wip: serve metrics on a different port
* exclude server from tsconfig
* latest
* refacto(all): use class & singleton
* refacto(all): use class & singleton
* refacto(all): add request logs
* Make all the env vars dynamic (#1092)
* Add truncate to task model (#1090)
* retry text area height (#1091)
* Make all the env vars dynamic
* only check for db at runtime
* remove secret from build step
* improve dockerfile
* Wrap db in singleton
* add .env.local to dockerignore
* changes to dockerfile
* lint
* aborted generations
* move collections build check
* Use a single dockerfile
* lint
* fixes
* lint
* don't return db during building
* remove dev
---------
Co-authored-by: Victor Muštar <victor.mustar@gmail.com>
* refacto(all): update default metrics port
* fix recursion error
* add version check
* revert vite preview
* Move request logs to debug level and add an env var to filter by log level in d…
Expose sampling controls in assistants (#955) (#959)
The api-version is a required query parameter for Azure OpenAI, by
supporting this we can support it without a gateway like portkey.
Co-authored-by: Nathan Sarrazin <sarrazin.nathan@gmail.com>
* work on branching
* branching
* work on input field
* wip
* wip
* helper stuff
* pass tests
* add type guards and clean up type requirements
* fixed shared conv type
* more helpers stuff
* clean up code
* addChildren helper
* addSibling
* add test for addSibling & refacto addChildren tests
* backend work pt. 1
* backend done
* add children property to messages for easier frontend rendering
* fix message id type rail
* front-end work on simple linear conversation
* fix title generation
* convert conversations on post
* server side retry works with branching
* clean up buttons
* fix retry feature backend
* Send new messages in any subtree
* make edit previous prompts feature work
* fix padding
* revert unneeded changes
* bring back pending message
* fix front-end streaming
* fix initial message
* Revert "fix initial message"
This reverts commit 6257fe8789c52a20e7506aa453efda55c16e95bb.
* Fix bug subtree state refresh
* fix continue feature on shared co…
* allow customizing disclaimer as `PUBLIC_APP_DISCLAIMER_MESSAGE`
* support passing `defaultHeaders` to `openai` endpoint
* add azure openai, claude, mistral examples using `defaultHeaders` & `openai` endpoint
* fix streaming being buffered behind cloudflare tunnel
might help to relieve issue #598
* support new lines in model description
* don't automatically generate modelUrl to huggingface
fixes broken links for self-hosted or custom-named model
* add `PUBLIC_APP_DISCLAIMER_MESSAGE` in `.env`
* `npm run format`
---------
Co-authored-by: Nathan Sarrazin <sarrazin.nathan@gmail.com>
[JS] use shorthand notation (#711)
Mishig
Unverified signature
5869ab4
* [JS] use shorthand notation
* add `"object-shorthand": ["error", "always"],`
* fix "Expected method shorthand object-shorthand"
* format
Support websearch for openAI chat completion mode (#608)
Add support for passing an API key or any other custom token in the authorization header (#579)
Galén+1: nsarrazin
Unverified signature
3eb7ff2
* Add support for passing an API key or any other custom token in the authorization header
* Make linter happy
* Fix README as per linter suggestions
* Refactor endpoints to actually parse zod config
* Remove top level env var and simplify header addition
* Skip section on API key or other, remove obsolete comment in endpointTgi.ts and remote CUSTOM_AUTHORIZATION_TOKEN from .env
---------
Co-authored-by: Nathan Sarrazin <sarrazin.nathan@gmail.com>
Modular backends & support for openAI & AWS endpoints (#541)
nsarrazin+4: chenhunghan, Henry Chen, Mishig, Eliott C.
Unverified signature
0ab1dfb
* Fix the response
Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
* Should use /completions
Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
* Use async generator
Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
* Use openai npm
Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
* Fix generateFromDefaultEndpoint
Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
* Fix last char become undefined
Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
* Better support for system prompt
Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
* Updates
Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
* Revert
Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
* Update README
Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
* Default system prompt
Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
* remove sk-
Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
* Fixing t…