Commit graph

29 commits

Author SHA1 Message Date
Danny Avila
9a210971f5
🛜 refactor: Streamline App Config Usage (#9234)
* WIP: app.locals refactoring

WIP: appConfig

fix: update memory configuration retrieval to use getAppConfig based on user role

fix: update comment for AppConfig interface to clarify purpose

🏷️ refactor: Update tests to use getAppConfig for endpoint configurations

ci: Update AppService tests to initialize app config instead of app.locals

ci: Integrate getAppConfig into remaining tests

refactor: Update multer storage destination to use promise-based getAppConfig and improve error handling in tests

refactor: Rename initializeAppConfig to setAppConfig and update related tests

ci: Mock getAppConfig in various tests to provide default configurations

refactor: Update convertMCPToolsToPlugins to use mcpManager for server configuration and adjust related tests

chore: rename `Config/getAppConfig` -> `Config/app`

fix: streamline OpenAI image tools configuration by removing direct appConfig dependency and using function parameters

chore: correct parameter documentation for imageOutputType in ToolService.js

refactor: remove `getCustomConfig` dependency in config route

refactor: update domain validation to use appConfig for allowed domains

refactor: use appConfig registration property

chore: remove app parameter from AppService invocation

refactor: update AppConfig interface to correct registration and turnstile configurations

refactor: remove getCustomConfig dependency and use getAppConfig in PluginController, multer, and MCP services

refactor: replace getCustomConfig with getAppConfig in STTService, TTSService, and related files

refactor: replace getCustomConfig with getAppConfig in Conversation and Message models, update tempChatRetention functions to use AppConfig type

refactor: update getAppConfig calls in Conversation and Message models to include user role for temporary chat expiration

ci: update related tests

refactor: update getAppConfig call in getCustomConfigSpeech to include user role

fix: update appConfig usage to access allowedDomains from actions instead of registration

refactor: enhance AppConfig to include fileStrategies and update related file strategy logic

refactor: update imports to use normalizeEndpointName from @librechat/api and remove redundant definitions

chore: remove deprecated unused RunManager

refactor: get balance config primarily from appConfig

refactor: remove customConfig dependency for appConfig and streamline loadConfigModels logic

refactor: remove getCustomConfig usage and use app config in file citations

refactor: consolidate endpoint loading logic into loadEndpoints function

refactor: update appConfig access to use endpoints structure across various services

refactor: implement custom endpoints configuration and streamline endpoint loading logic

refactor: update getAppConfig call to include user role parameter

refactor: streamline endpoint configuration and enhance appConfig usage across services

refactor: replace getMCPAuthMap with getUserMCPAuthMap and remove unused getCustomConfig file

refactor: add type annotation for loadedEndpoints in loadEndpoints function

refactor: move /services/Files/images/parse to TS API

chore: add missing FILE_CITATIONS permission to IRole interface

refactor: restructure toolkits to TS API

refactor: separate manifest logic into its own module

refactor: consolidate tool loading logic into a new tools module for startup logic

refactor: move interface config logic to TS API

refactor: migrate checkEmailConfig to TypeScript and update imports

refactor: add FunctionTool interface and availableTools to AppConfig

refactor: decouple caching and DB operations from AppService, make part of consolidated `getAppConfig`

WIP: fix tests

* fix: rebase conflicts

* refactor: remove app.locals references

* refactor: replace getBalanceConfig with getAppConfig in various strategies and middleware

* refactor: replace appConfig?.balance with getBalanceConfig in various controllers and clients

* test: add balance configuration to titleConvo method in AgentClient tests

* chore: remove unused `openai-chat-tokens` package

* chore: remove unused imports in initializeMCPs.js

* refactor: update balance configuration to use getAppConfig instead of getBalanceConfig

* refactor: integrate configMiddleware for centralized configuration handling

* refactor: optimize email domain validation by removing unnecessary async calls

* refactor: simplify multer storage configuration by removing async calls

* refactor: reorder imports for better readability in user.js

* refactor: replace getAppConfig calls with req.config for improved performance

* chore: replace getAppConfig calls with req.config in tests for centralized configuration handling

* chore: remove unused override config

* refactor: add configMiddleware to endpoint route and replace getAppConfig with req.config

* chore: remove customConfig parameter from TTSService constructor

* refactor: pass appConfig from request to processFileCitations for improved configuration handling

* refactor: remove configMiddleware from endpoint route and retrieve appConfig directly in getEndpointsConfig if not in `req.config`

* test: add mockAppConfig to processFileCitations tests for improved configuration handling

* fix: pass req.config to hasCustomUserVars and call without await after synchronous refactor

* fix: type safety in useExportConversation

* refactor: retrieve appConfig using getAppConfig in PluginController and remove configMiddleware from plugins route, to avoid always retrieving when plugins are cached

* chore: change `MongoUser` typedef to `IUser`

* fix: Add `user` and `config` fields to ServerRequest and update JSDoc type annotations from Express.Request to ServerRequest

* fix: remove unused setAppConfig mock from Server configuration tests
2025-08-26 12:10:18 -04:00
Danny Avila
50b7bd6643
🔄 fix: Ensure lastRefill Date for Existing Users & Refactor Balance Middleware (#9086)
- Deleted setBalanceConfig middleware and its associated file.
- Introduced createSetBalanceConfig factory function to create middleware for synchronizing user balance settings.
- Updated auth and oauth routes to use the new balance configuration middleware.
- Added comprehensive tests for the new balance middleware functionality.
- Updated package versions and dependencies in package.json and package-lock.json.
- Added balance types and updated middleware index to export new balance middleware.
2025-08-15 17:02:49 -04:00
Danny Avila
66bd419baa
🔐 feat: Granular Role-based Permissions + Entra ID Group Discovery (#7804)
WIP: pre-granular-permissions commit

feat: Add category and support contact fields to Agent schema and UI components

Revert "feat: Add category and support contact fields to Agent schema and UI components"

This reverts commit c43a52b4c9.

Fix: Update import for renderHook in useAgentCategories.spec.tsx

fix: Update icon rendering in AgentCategoryDisplay tests to use empty spans

refactor: Improve category synchronization logic and clean up AgentConfig component

refactor: Remove unused UI flow translations from translation.json

feat: agent marketplace features

🔐 feat: Granular Role-based Permissions + Entra ID Group Discovery (#7804)
2025-08-13 16:24:17 -04:00
Danny Avila
1ccac58403
🔒 fix: Provider Validation for Social, OpenID, SAML, and LDAP Logins (#8999)
* fix: social login provider crossover

* feat: Enhance OpenID login handling and add tests for provider validation

* refactor: authentication error handling to use ErrorTypes.AUTH_FAILED enum

* refactor: update authentication error handling in LDAP and SAML strategies to use ErrorTypes.AUTH_FAILED enum

* ci: Add validation for login with existing email and different provider in SAML strategy

chore: Add logging for existing users with different providers in LDAP, SAML, and Social Login strategies
2025-08-11 18:51:46 -04:00
Danny Avila
ec7370dfe9
🪐 feat: MCP OAuth 2.0 Discovery Support (#7924)
* chore: Update @modelcontextprotocol/sdk to version 1.12.3 in package.json and package-lock.json

- Bump version of @modelcontextprotocol/sdk to 1.12.3 to incorporate recent updates.
- Update dependencies for ajv and cross-spawn to their latest versions.
- Add ajv as a new dependency in the sdk module.
- Include json-schema-traverse as a new dependency in the sdk module.

* feat: @librechat/auth

* feat: Add crypto module exports to auth package

- Introduced a new crypto module by creating index.ts in the crypto directory.
- Updated the main index.ts of the auth package to export from the new crypto module.

* feat: Update package dependencies and build scripts for auth package

- Added @librechat/auth as a dependency in package.json and package-lock.json.
- Updated build scripts to include the auth package in both frontend and bun build processes.
- Removed unused mongoose and openid-client dependencies from package-lock.json for cleaner dependency management.

* refactor: Migrate crypto utility functions to @librechat/auth

- Replaced local crypto utility imports with the new @librechat/auth package across multiple files.
- Removed the obsolete crypto.js file and its exports.
- Updated relevant services and models to utilize the new encryption and decryption methods from @librechat/auth.

* feat: Enhance OAuth token handling and update dependencies in auth package

* chore: Remove Token model and TokenService due to restructuring of OAuth handling

- Deleted the Token.js model and TokenService.js, which were responsible for managing OAuth tokens.
- This change is part of a broader refactor to streamline OAuth token management and improve code organization.

* refactor: imports from '@librechat/auth' to '@librechat/api' and add OAuth token handling functionality

* refactor: Simplify logger usage in MCP and FlowStateManager classes

* chore: fix imports

* feat: Add OAuth configuration schema to MCP with token exchange method support

* feat: FIRST PASS Implement MCP OAuth flow with token management and error handling

- Added a new route for handling OAuth callbacks and token retrieval.
- Integrated OAuth token storage and retrieval mechanisms.
- Enhanced MCP connection to support automatic OAuth flow initiation on 401 errors.
- Implemented dynamic client registration and metadata discovery for OAuth.
- Updated MCPManager to manage OAuth tokens and handle authentication requirements.
- Introduced comprehensive logging for OAuth processes and error handling.

* refactor: Update MCPConnection and MCPManager to utilize new URL handling

- Added a `url` property to MCPConnection for better URL management.
- Refactored MCPManager to use the new `url` property instead of a deprecated method for OAuth handling.
- Changed logging from info to debug level for flow manager and token methods initialization.
- Improved comments for clarity on existing tokens and OAuth event listener setup.

* refactor: Improve connection timeout error messages in MCPConnection and MCPManager and use initTimeout for connection

- Updated the connection timeout error messages to include the duration of the timeout.
- Introduced a configurable `connectTimeout` variable in both MCPConnection and MCPManager for better flexibility.

* chore: cleanup MCP OAuth Token exchange handling; fix: erroneous use of flowsCache and remove verbose logs

* refactor: Update MCPManager and MCPTokenStorage to use TokenMethods for token management

- Removed direct token storage handling in MCPManager and replaced it with TokenMethods for better abstraction.
- Refactored MCPTokenStorage methods to accept parameters for token operations, enhancing flexibility and readability.
- Improved logging messages related to token persistence and retrieval processes.

* refactor: Update MCP OAuth handling to use static methods and improve flow management

- Refactored MCPOAuthHandler to utilize static methods for initiating and completing OAuth flows, enhancing clarity and reducing instance dependencies.
- Updated MCPManager to pass flowManager explicitly to OAuth handling methods, improving flexibility in flow state management.
- Enhanced comments and logging for better understanding of OAuth processes and flow state retrieval.

* refactor: Integrate token methods into createMCPTool for enhanced token management

* refactor: Change logging from info to debug level in MCPOAuthHandler for improved log management

* chore: clean up logging

* feat: first pass, auth URL from MCP OAuth flow

* chore: Improve logging format for OAuth authentication URL display

* chore: cleanup mcp manager comments

* feat: add connection reconnection logic in MCPManager

* refactor: reorganize token storage handling in MCP

- Moved token storage logic from MCPManager to a new MCPTokenStorage class for better separation of concerns.
- Updated imports to reflect the new token storage structure.
- Enhanced methods for storing, retrieving, updating, and deleting OAuth tokens, improving overall token management.

* chore: update comment for SYSTEM_USER_ID in MCPManager for clarity

* feat: implement refresh token functionality in MCP

- Added refresh token handling in MCPManager to support token renewal for both app-level and user-specific connections.
- Introduced a refreshTokens function to facilitate token refresh logic.
- Enhanced MCPTokenStorage to manage client information and refresh token processes.
- Updated logging for better traceability during token operations.

* chore: cleanup @librechat/auth

* feat: implement MCP server initialization in a separate service

- Added a new service to handle the initialization of MCP servers, improving code organization and readability.
- Refactored the server startup logic to utilize the new initializeMCP function.
- Removed redundant MCP initialization code from the main server file.

* fix: don't log auth url for user connections

* feat: enhance OAuth flow with success and error handling components

- Updated OAuth callback routes to redirect to new success and error pages instead of sending status messages.
- Introduced `OAuthSuccess` and `OAuthError` components to provide user feedback during authentication.
- Added localization support for success and error messages in the translation files.
- Implemented countdown functionality in the success component for a better user experience.

* fix: refresh token handling for user connections, add missing URL and methods

- add standard enum for system user id and helper for determining app-lvel vs. user-level connections

* refactor: update token handling in MCPManager and MCPTokenStorage

* fix: improve error logging in OAuth authentication handler

* fix: concurrency issues for both login url emission and concurrency of oauth flows for shared flows (same user, same server, multiple calls for same server)

* fix: properly fail shared flows for concurrent server calls and prevent duplication of tokens

* chore: remove unused auth package directory from update configuration

* ci: fix mocks in samlStrategy tests

* ci: add mcpConfig to AppService test setup

* chore: remove obsolete MCP OAuth implementation documentation

* fix: update build script for API to use correct command

* chore: bump version of @librechat/api to 1.2.4

* fix: update abort signal handling in createMCPTool function

* fix: add optional clientInfo parameter to refreshTokensFunction metadata

* refactor: replace app.locals.availableTools with getCachedTools in multiple services and controllers for improved tool management

* fix: concurrent refresh token handling issue

* refactor: add signal parameter to getUserConnection method for improved abort handling

* chore: JSDoc typing for `loadEphemeralAgent`

* refactor: update isConnectionActive method to use destructured parameters for improved readability

* feat: implement caching for MCP tools to handle app-level disconnects for loading list of tools

* ci: fix agent test
2025-06-17 13:50:33 -04:00
tsutsu3
939b4ce659
🔑 feat: SAML authentication (#6169)
* feat: add SAML authentication

* refactor: change SAML icon

* refactor: resolve SAML metadata paths using paths.js

* test: add samlStrategy tests

* fix: update setupSaml import

* test: add SAML settings tests in config.spec.js

* test: add client tests

* refactor: improve SAML button label and fallback localization

* feat: allow only one authentication method OpenID or SAML at a time

* doc: add SAML configuration sample to docker-compose.override

* fix: require SAML_SESSION_SECRET to enable SAML

* feat: update samlStrategy

* test: update samle tests

* feat: add SAML login button label to translations and remove default value

* fix: update SAML cert file binding

* chore: update override example with SAML cert volume

* fix: update SAML session handling with Redis backend

---------

Co-authored-by: Ruben Talstra <RubenTalstra1211@outlook.com>
2025-05-29 11:00:58 -04:00
Danny Avila
c68cc0a550
fix: Debounce setUserContext and Default State Param for OpenID Auth (#7559)
* fix: Add default random state parameter to OpenID auth request for providers that require it; ensure passport strategy uses it

*  refactor: debounce setUserContext to avoid race condition

* refactor: Update OpenID authentication to use randomState from openid-client

* chore: linting in presetSettings type definition

* chore: import order in ModelPanel

* refactor: remove `isLegacyOutput` property from AnthropicClient since only used where defined, add latest models to non-legacy patterns, and remove from client cleanup

* refactor: adjust grid layout in Parameters component for improved responsiveness

* refactor: adjust grid layout in ModelPanel for improved display of model parameters

* test: add cases for maxOutputTokens handling in Claude 4 Sonnet and Opus models

* ci: mock loadCustomConfig in server tests and refactor OpenID route for improved authentication handling
2025-05-25 23:40:37 -04:00
Peter
bf80cf30b3
*️⃣ feat: Reuse OpenID Auth Tokens (#7397)
* feat: integrate OpenID Connect support with token reuse

- Added `jwks-rsa` and `new-openid-client` dependencies for OpenID Connect functionality.
- Implemented OpenID token refresh logic in `AuthController`.
- Enhanced `LogoutController` to handle OpenID logout and session termination.
- Updated JWT authentication middleware to support OpenID token provider.
- Modified OAuth routes to accommodate OpenID authentication and token management.
- Created `setOpenIDAuthTokens` function to manage OpenID tokens in cookies.
- Upgraded OpenID strategy with user info fetching and token exchange protocol.
- Introduced `openIdJwtLogin` strategy for handling OpenID JWT tokens.
- Added caching mechanism for exchanged OpenID tokens.
- Updated configuration to include OpenID exchanged tokens cache key.
- updated .env.example to include the new env variables needed for the feature.

* fix: update return type in downloadImage documentation for clarity and fixed openIdJwtLogin env variables

* fix: update Jest configuration and tests for OpenID strategy integration

* fix: update OpenID strategy to include callback URL in setup

* fix: fix optionalJwtAuth middleware to support OpenID token reuse and improve currentUrl method in CustomOpenIDStrategy to override the dynamic host issue related to proxy (e.g. cloudfront)

* fix: fixed code formatting

* Fix: Add mocks for openid-client and passport strategy in Jest configuration to fix unit tests

* fix eslint errors: Format mock file openid-client.

*  feat: Add PKCE support for OpenID and default handling in strategy setup

---------

Co-authored-by: Atef Bellaaj <slalom.bellaaj@external.daimlertruck.com>
Co-authored-by: Ruben Talstra <RubenTalstra1211@outlook.com>
2025-05-23 17:40:40 -04:00
Danny Avila
0865bc4a72
🪙 feat: Sync Balance Config on Login (#6671)
* chore: Add deprecation warnings for environment variables in checks

* chore: Change deprecatedVariables to a const declaration in checks.js

* fix: Add date validation in checkBalanceRecord to prevent invalid date errors

* feat: Add setBalanceConfig middleware to synchronize user balance settings

* chore: Reorder middleware imports in oauth.js for better readability
2025-04-01 21:19:42 -04:00
Danny Avila
cbba914290
🛠 feat: Enhance Redis Integration, Rate Limiters & Log Headers (#6462)
* feat: Implement Redis-based rate limiting, initially import limits

* feat: Enhance rate limiters with Redis support and custom prefixes

* chore: import orders

* chore: update JSDoc for next middleware parameter type in ban and limiter middleware

* feat: add logHeaders middleware to log forwarded headers in requests

* refactor: change log level from info to debug for Redis rate limiters

* feat: increase Redis max listeners and refactor session storage to use Keyv
2025-03-21 14:14:45 -04:00
heptapod
f95d5aaf4d
🔒feat: Enable OpenID Auto-Redirect (#6066)
* added feature for oidc auto redirection

* Added Cooldown logic for OIDC auto redirect for failed login attempts

* 🔧 feat: Implement custom logout redirect handling and enhance OpenID auto-redirect logic

* 🔧 refactor: Update getLoginError to use TranslationKeys for improved type safety

* 🔧 feat: Localize redirect message to OpenID provider in Login component

---------

Co-authored-by: Ruben Talstra <RubenTalstra1211@outlook.com>
2025-03-19 09:51:56 -04:00
Ruben Talstra
e1a6268904
🍎 feat: Apple auth (#5473)
* implemented Apple Auth login.

Closes: #3438

TODO:
- write config Doc

* removed some comments

* removed comment

* Add unit tests for Apple login strategy

Introduce comprehensive tests for the Apple login strategy, covering new user creation, existing user updates, and error handling scenarios during the authentication flow. Mocks implemented for external dependencies to ensure isolated testing.

* Remove unnecessary blank line in socialLogins.js
2025-01-31 09:49:09 -05:00
Ragavendaran P R
d048a10b2e
📜 refactor: Log Error Messages when OAuth Fails (#5337) 2025-01-18 09:32:41 -05:00
Marco Beretta
ee673d682e
📧 feat: email verification (#2344)
* feat: verification email

* chore: email verification invalid; localize: update

* fix: redirect to login when signup: fix: save emailVerified correctly

* docs: update ALLOW_UNVERIFIED_EMAIL_LOGIN; fix: don't accept login only when ALLOW_UNVERIFIED_EMAIL_LOGIN = true

* fix: user needs to be authenticated

* style: update

* fix: registration success message and redirect logic

* refactor: use `isEnabled` in ALLOW_UNVERIFIED_EMAIL_LOGIN

* refactor: move checkEmailConfig to server/utils

* refactor: use req as param for verifyEmail function

* chore: jsdoc

* chore: remove console log

* refactor: rename `createNewUser` to `createSocialUser`

* refactor: update typing and add expiresAt field to userSchema

* refactor: begin use of user methods over direct model access for User

* refactor: initial email verification rewrite

* chore: typing

* refactor: registration flow rewrite

* chore: remove help center text

* refactor: update getUser to getUserById and add findUser methods. general fixes from recent changes

* refactor: Update updateUser method to remove expiresAt field and use $set and $unset operations, createUser now returns Id only

* refactor: Update openidStrategy to use optional chaining for avatar check, move saveBuffer init to buffer condition

* refactor: logout on deleteUser mutatation

* refactor: Update openidStrategy login success message format

* refactor: Add emailVerified field to Discord and Facebook profile details

* refactor: move limiters to separate middleware dir

* refactor: Add limiters for email verification and password reset

* refactor: Remove getUserController and update routes and controllers accordingly

* refactor: Update getUserById method to exclude password and version fields

* refactor: move verification to user route, add resend verification option

* refactor: Improve email verification process and resend option

* refactor: remove more direct model access of User and remove unused code

* refactor: replace user authentication methods and token generation

* fix: add user.id to jwt user

* refactor: Update AuthContext to include setError function, add resend link to Login Form, make registration redirect shorter

* fix(updateUserPluginsService): ensure userPlugins variable is defined

* refactor: Delete all shared links for a specific user

* fix: remove use of direct User.save() in handleExistingUser

* fix(importLibreChatConvo): handle missing createdAt field in messages

---------

Co-authored-by: Danny Avila <danny@librechat.ai>
2024-06-07 15:06:47 -04:00
Mathieu Breton
75da75be08
🛂 feat(oauth): add domain restriction on social login (#2512) 2024-04-24 12:14:27 -04:00
Danny Avila
972402e029
🛡️ : Security Enhancements (#1681)
* fix: sanitize HTTP params and do not send whole error objects backs

* fix: prevent path traversal

* fix: send custom error message for tokenizer route

* chore: handle info exposure vector

* chore(oauth): skip check due to false positive as oauth routes are rate-limited

* chore(app): disable `x-powered-by`

* chore: disable false positives or flagging of hardcoded secrets when they are fake values

* chore: add path traversal safety check
2024-01-30 14:34:02 -05:00
Danny Avila
ea1dd59ef4
refactor(api): Central Logging 📜 (#1348)
* WIP: initial logging changes
add several transports in ~/config/winston
omit messages in logs, truncate long strings
add short blurb in dotenv for debug logging
GoogleClient: using logger
OpenAIClient: using logger, handleOpenAIErrors
Adding typedef for payload message
bumped winston and using winston-daily-rotate-file
moved config for server paths to ~/config dir
Added `DEBUG_LOGGING=true` to .env.example

* WIP: Refactor logging statements in code

* WIP: Refactor logging statements and import configurations

* WIP: Refactor logging statements and import configurations

* refactor: broadcast Redis initialization message with `info` not `debug`

* refactor: complete Refactor logging statements and import configurations

* chore: delete unused tools

* fix: circular dependencies due to accessing logger

* refactor(handleText): handle booleans and write tests

* refactor: redact sensitive values, better formatting

* chore: improve log formatting, avoid passing strings to 2nd arg

* fix(ci): fix jest tests due to logger changes

* refactor(getAvailablePluginsController): cache plugins as they are static and avoids async addOpenAPISpecs call every time

* chore: update docs

* chore: update docs

* chore: create separate meiliSync logger, clean up logs to avoid being unnecessarily verbose

* chore: spread objects where they are commonly logged to allow string truncation

* chore: improve error log formatting
2023-12-14 07:49:27 -05:00
Danny Avila
12209fe0dd
refactor: address potential issues with deploy-compose.yml (#1220)
* chore: remove /config/loader

* chore: remove config/loader steps from Dockerfile.multi

* chore: remove install script
2023-11-25 16:34:51 -05:00
Danny Avila
7b2cedf5ff
feat: Message Rate Limiters, Violation Logging, & Ban System 🔨 (#903)
* refactor: require Auth middleware in route index files

* feat: concurrent message limiter

* feat: complete concurrent message limiter with caching

* refactor: SSE response methods separated from handleText

* fix(abortMiddleware): fix req and res order to standard, use endpointOption in req.body

* chore: minor name changes

* refactor: add isUUID condition to saveMessage

* fix(concurrentLimiter): logic correctly handles the max number of concurrent messages and res closing/finalization

* chore: bump keyv and remove console.log from Message

* fix(concurrentLimiter): ensure messages are only saved in later message children

* refactor(concurrentLimiter): use KeyvFile instead, could make other stores configurable in the future

* feat: add denyRequest function for error responses

* feat(utils): add isStringTruthy function

Introduce the isStringTruthy function to the utilities module to check if a string value is a case-insensitive match for 'true'

* feat: add optional message rate limiters by IP and userId

* feat: add optional message rate limiters by IP and userId to edit route

* refactor: rename isStringTruthy to isTrue for brevity

* refactor(getError): use map to make code cleaner

* refactor: use memory for concurrent rate limiter to prevent clearing on startup/exit, add multiple log files, fix error message for concurrent violation

* feat: check if errorMessage is object, stringify if so

* chore: send object to denyRequest which will stringify it

* feat: log excessive requests

* fix(getError): correctly pluralize messages

* refactor(limiters): make type consistent between logs and errorMessage

* refactor(cache): move files out of lib/db into separate cache dir
>> feat: add getLogStores function so Keyv instance is not redundantly created on every violation
feat: separate violation logging to own function with logViolation

* fix: cache/index.js export, properly record userViolations

* refactor(messageLimiters): use new logging method, add logging to registrations

* refactor(logViolation): make userLogs an array of logs per user

* feat: add logging to login limiter

* refactor: pass req as first param to logViolation and record offending IP

* refactor: rename isTrue helper fn to isEnabled

* feat: add simple non_browser check and log violation

* fix: open handles in unit tests, remove KeyvMongo as not used and properly mock global fetch

* chore: adjust nodemon ignore paths to properly ignore logs

* feat: add math helper function for safe use of eval

* refactor(api/convos): use middleware at top of file to avoid redundancy

* feat: add delete all static method for Sessions

* fix: redirect to login on refresh if user is not found, or the session is not found but hasn't expired (ban case)

* refactor(getLogStores): adjust return type

* feat: add ban violation and check ban logic
refactor(logViolation): pass both req and res objects

* feat: add removePorts helper function

* refactor: rename getError to getMessageError and add getLoginError for displaying different login errors

* fix(AuthContext): fix type issue and remove unused code

* refactor(bans): ban by ip and user id, send response based on origin

* chore: add frontend ban messages

* refactor(routes/oauth): add ban check to handler, also consolidate logic to avoid redundancy

* feat: add ban check to AI messaging routes

* feat: add ban check to login/registration

* fix(ci/api): mock KeyvMongo to avoid tests hanging

* docs: update .env.example
> refactor(banViolation): calculate interval rate crossover, early return if duration is invalid
ci(banViolation): add tests to ensure users are only banned when expected

* docs: improve wording for mod system

* feat: add configurable env variables for violation scores

* chore: add jsdoc for uaParser.js

* chore: improve ban text log

* chore: update bun test scripts

* refactor(math.js): add fallback values

* fix(KeyvMongo/banLogs): refactor keyv instances to top of files to avoid memory leaks, refactor ban logic to use getLogStores instead
refactor(getLogStores): get a single log store by type

* fix(ci): refactor tests due to banLogs changes, also make sure to clear and revoke sessions even if ban duration is 0

* fix(banViolation.js): getLogStores import

* feat: handle 500 code error at login

* fix(middleware): handle case where user.id is _id and not just id

* ci: add ban secrets for backend unit tests

* refactor: logout user upon ban

* chore: log session delete message only if deletedCount > 0

* refactor: change default ban duration (2h) and make logic more clear in JSDOC

* fix: login and registration limiters will now return rate limiting error

* fix: userId not parsable as non ObjectId string

* feat: add useTimeout hook to properly clear timeouts when invoking functions within them
refactor(AuthContext): cleanup code by using new hook and defining types in ~/common

* fix: login error message for rate limits

* docs: add info for automated mod system and rate limiters, update other docs accordingly

* chore: bump data-provider version
2023-09-13 10:57:07 -04:00
Danny Avila
33f087d38f
feat: Refresh Token for improved Session Security (#927)
* feat(api): refresh token logic

* feat(client): refresh token logic

* feat(data-provider): refresh token logic

* fix: SSE uses esm

* chore: add default refresh token expiry to AuthService, add message about env var not set when generating a token

* chore: update scripts to more compatible bun methods, ran bun install again

* chore: update env.example and playwright workflow with JWT_REFRESH_SECRET

* chore: update breaking changes docs

* chore: add timeout to url visit

* chore: add default SESSION_EXPIRY in generateToken logic, add act script for testing github actions

* fix(e2e): refresh automatically in development environment to pass e2e tests
2023-09-11 13:10:46 -04:00
Danny Avila
4ca43fb53d
refactor: Encrypt & Expire User Provided Keys, feat: Rate Limiting (#874)
* docs: make_your_own.md formatting fix for mkdocs

* feat: add express-mongo-sanitize
feat: add login/registration rate limiting

* chore: remove unnecessary console log

* wip: remove token handling from localStorage to encrypted DB solution

* refactor: minor change to UserService

* fix mongo query and add keys route to server

* fix backend controllers and simplify schema/crud

* refactor: rename token to key to separate from access/refresh tokens, setTokenDialog -> setKeyDialog

* refactor(schemas): TEndpointOption token -> key

* refactor(api): use new encrypted key retrieval system

* fix(SetKeyDialog): fix key prop error

* fix(abortMiddleware): pass random UUID if messageId is not generated yet for proper error display on frontend

* fix(getUserKey): wrong prop passed in arg, adds error handling

* fix: prevent message without conversationId from saving to DB, prevents branching on the frontend to a new top-level branch

* refactor: change wording of multiple display messages

* refactor(checkExpiry -> checkUserKeyExpiry): move to UserService file

* fix: type imports from common

* refactor(SubmitButton): convert to TS

* refactor(key.ts): change localStorage map key name

* refactor: add new custom tailwind classes to better match openAI colors

* chore: remove unnecessary warning and catch ScreenShot error

* refactor: move userKey frontend logic to hooks and remove use of localStorage and instead query the DB

* refactor: invalidate correct query key, memoize userKey hook, conditionally render SetKeyDialog to avoid unnecessary calls, refactor SubmitButton props and useEffect for showing 'provide key first'

* fix(SetKeyDialog): use enum-like object for expiry values
feat(Dropdown): add optionsClassName to dynamically change dropdown options container classes

* fix: handle edge case where user had provided a key but the server changes to env variable for keys

* refactor(OpenAI/titleConvo): move titling to client to retain authorized credentials in message lifecycle for titling

* fix(azure): handle user_provided keys correctly for azure

* feat: send user Id to OpenAI to differentiate users in completion requests

* refactor(OpenAI/titleConvo): adding tokens helps minimize LLM from using the language in title response

* feat: add delete endpoint for keys

* chore: remove throttling of title

* feat: add 'Data controls' to Settings, add 'Revoke' keys feature in Key Dialog and Data controls

* refactor: reorganize PluginsClient files in langchain format

* feat: use langchain for titling convos

* chore: cleanup titling convo, with fallback to original method, escape braces, use only snippet for language detection

* refactor: move helper functions to appropriate langchain folders for reusability

* fix: userProvidesKey handling for gptPlugins

* fix: frontend handling of plugins key

* chore: cleanup logging and ts-ignore SSE

* fix: forwardRef misuse in DangerButton

* fix(GoogleConfig/FileUpload): localize errors and simplify validation with zod

* fix: cleanup google logging and fix user provided key handling

* chore: remove titling from google

* chore: removing logging from browser endpoint

* wip: fix menu flicker

* feat: useLocalStorage hook

* feat: add Tooltip for UI

* refactor(EndpointMenu): utilize Tooltip and useLocalStorage, remove old 'New Chat' slide-over

* fix(e2e): use testId for endpoint menu trigger

* chore: final touches to EndpointMenu before future refactor to declutter component

* refactor(localization): change select endpoint to open menu and add translations

* chore: add final prop to error message response

* ci: minor edits to facilitate testing

* ci: new e2e test which tests for new key setting/revoking features
2023-09-06 10:46:27 -04:00
Marco Beretta
007d51ede1
feat: facebook login (#820)
* Facebook strategy

* Update user_auth_system.md

* Update user_auth_system.md
2023-08-24 20:10:48 -04:00
Danny Avila
e5336039fc
ci(backend-review.yml): add linter step to the backend review workflow (#625)
* ci(backend-review.yml): add linter step to the backend review workflow

* chore(backend-review.yml): remove prettier from lint-action configuration

* chore: apply new linting workflow

* chore(lint-staged.config.js): reorder lint-staged tasks for JavaScript and TypeScript files

* chore(eslint): update ignorePatterns in .eslintrc.js
chore(lint-action): remove prettier option in backend-review.yml
chore(package.json): add lint and lint:fix scripts

* chore(lint-staged.config.js): remove prettier --write command for js, jsx, ts, tsx files

* chore(titleConvo.js): remove unnecessary console.log statement
chore(titleConvo.js): add missing comma in options object

* chore: apply linting to all files

* chore(lint-staged.config.js): update lint-staged configuration to include prettier formatting
2023-07-14 09:36:49 -04:00
Marco Beretta
747e087cf5
Discord Login (#615)
* Add files via upload

* Create linode-setup.md

* Create cloudflare-setup.md

* Update cloudflare-setup.md

* Delete 4-linode.png

* Delete 3-linode.png

* Add files via upload

* Add files via upload

* Update cloudflare-setup.md

* Update linode-setup.md

* Rename cloudflare-setup.md to cloudflare.md

* Rename linode-setup.md to linode.md

* Update mkdocs.yml

* Update cloudflare.md

* Update linode.md

* Update README.md

* Update README.md

* Update linode.md

sentence in Italian

* v1

The frontend has been completed, along with the .env variables.

However, there is an issue of infinite loading thereafter.

* Fix email and remove deprecated GitHub passport

* Update user_auth_system.md

add How to Set Up a Github Authentication

* Update .env.example

Improved the comment above the GitHub client ID and secret.

* Update user_auth_system.md

* Update package.json

* Remove unnecessary passport GitHub package

* fixed conflicts

 fixed conflicts between Berry-13:main and danny-avila:main

in api/server/index.js 45:54

* Delete e -i HEAD~2

* (WIP) Discord Login

* Fix duplicate githubLoginEnabled

* .env.example restore

* Update user_auth_system.md

Discord Login

* Fix and new Feature

1. Added Discord login to .env.example.
2. Created Google, Github, and Discord icons in client\src\components\svg.
3. Added the social login option in the .env file; it fixes the ---or---. Check Discord for more information.

* fix Login.tsx and Registration.tsx

* Update user_auth_system.md

* Update .env.example

* Added OpenID Icon

* quick discord icon fix

* discord strategy fix

* remove comment
2023-07-11 17:17:58 -04:00
Marco Beretta
d0078d478d
GIthub Login (#578)
* Add files via upload

* Create linode-setup.md

* Create cloudflare-setup.md

* Update cloudflare-setup.md

* Delete 4-linode.png

* Delete 3-linode.png

* Add files via upload

* Add files via upload

* Update cloudflare-setup.md

* Update linode-setup.md

* Rename cloudflare-setup.md to cloudflare.md

* Rename linode-setup.md to linode.md

* Update mkdocs.yml

* Update cloudflare.md

* Update linode.md

* Update README.md

* Update README.md

* Update linode.md

sentence in Italian

* v1

The frontend has been completed, along with the .env variables.

However, there is an issue of infinite loading thereafter.

* Fix email and remove deprecated GitHub passport

* Update user_auth_system.md

add How to Set Up a Github Authentication

* Update .env.example

Improved the comment above the GitHub client ID and secret.

* Update user_auth_system.md

* Update package.json

* Remove unnecessary passport GitHub package

* fixed conflicts

 fixed conflicts between Berry-13:main and danny-avila:main

in api/server/index.js 45:54

* Delete e -i HEAD~2
2023-07-04 15:23:42 -04:00
bsu3338
eceba36f54
OpenID Authentication (#495)
* Squashed commit of the following:

commit 26ab03fb36fcc7fcee63fdf3ae8c2dfb29027eff
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date:   Tue Jun 13 00:23:23 2023 -0500

    Update Registration.spec.tsx

commit e908dd82fe9ef1b43c75ee64c183d2f654bdac1c
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date:   Tue Jun 13 00:23:01 2023 -0500

    Update Login.spec.tsx

commit 223734820fb77d7fb5af4802af642d1c1fd7c1f5
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date:   Tue Jun 13 00:22:39 2023 -0500

    Update Registration.tsx

commit 7036d3dd0538979ee397d958ebc113bb0ea32411
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date:   Tue Jun 13 00:21:55 2023 -0500

    Update Login.tsx

commit 76bb78221db3195fd930fe9cfd6a5da7194fa759
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date:   Tue Jun 13 00:21:03 2023 -0500

    Update envConstants.js

commit ee2f69f33d75fbb57022afbcd9564bca38a46bee
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date:   Tue Jun 13 00:20:08 2023 -0500

    Update docker-compose.yml

commit 5ac72d789b3446884c6e2f4f595cbf67d731d43c
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date:   Tue Jun 13 00:18:41 2023 -0500

    Update Dockerfile

commit d24341db2bd5b17eb89ab01e171a5f51f3beab0a
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date:   Tue Jun 13 00:16:38 2023 -0500

    Update .env.example

commit 22154f4a09c5fcdfee95d43609fb01a5a883b7a9
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date:   Tue Jun 13 00:07:48 2023 -0500

    Update Registration.spec.tsx

commit 5163f7d372a6a03c94f4357b358211a03369456e
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date:   Tue Jun 13 00:07:30 2023 -0500

    Update Login.spec.tsx

commit 61da49e330a9376e130b24dc944854f97ab58d80
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date:   Tue Jun 13 00:07:00 2023 -0500

    Update Registration.tsx

commit 0e45d3f0dbde34388ff2f0b2dc51b983b472eb05
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date:   Tue Jun 13 00:06:18 2023 -0500

    Update Login.tsx

commit dca1e5367e5f3b468c7964218cc5914ca53095af
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date:   Tue Jun 13 00:05:07 2023 -0500

    Update envConstants.js

commit f48c058465d82b03716ba85224e9f97007e014d2
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date:   Tue Jun 13 00:04:05 2023 -0500

    Update .env.example

commit 818226c9cb079acae4fcbfe5997e4aa9e3c6d2cc
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date:   Mon Jun 12 23:59:08 2023 -0500

    Update .env.example

commit 9a805439189b352a38ac7654d7a31bb28f0f58dd
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date:   Mon Jun 12 23:58:31 2023 -0500

    Update env.d.ts

commit 3f37ce54758b017c9281b7fad9b040a47630ec66
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date:   Mon Jun 12 23:57:04 2023 -0500

    Update .env.example

commit 1026036f4dd529e9531c53084450ce768cfca4c1
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date:   Mon Jun 12 23:50:36 2023 -0500

    Update docker-compose.yml

commit a61cf7b8c51d4a9bd73a20bd67abc29891c11463
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date:   Mon Jun 12 23:50:00 2023 -0500

    Update Dockerfile

commit 79610d6648755cd5ec45215b9fdbe04ba8242fcf
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date:   Mon Jun 12 23:35:34 2023 -0500

    Update package-lock.json

commit e40853fd2b77f2db5be1c3dfd8b170d650e23271
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date:   Mon Jun 12 23:30:17 2023 -0500

    Update envConstants.js

commit 5529bc61b43f279fb4418c3851be2f9011b6454d
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date:   Mon Jun 12 23:25:58 2023 -0500

    Update docker-compose.yml

commit 07848cc464a64f7cad484e24a1310dc61aa03b18
Merge: ec628a3 72e9828
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date:   Mon Jun 12 23:24:03 2023 -0500

    Merge branch 'danny-avila:main' into openid-client

commit ec628a3044ba963b4e733c72229400074e7c2bc4
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date:   Mon Jun 12 23:23:16 2023 -0500

    Update envConstants.js

commit 21272221db0f58c244f08335482d45b177d338ab
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date:   Mon Jun 12 23:21:59 2023 -0500

    Update Registration.spec.tsx

commit d3f2949c0484d5760e7b689501852f86209992a3
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date:   Mon Jun 12 23:21:12 2023 -0500

    Update Login.spec.tsx

commit f2cf23ddd6708a3bb8d032dde5f1ce300dbe8cad
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date:   Mon Jun 12 23:20:15 2023 -0500

    Update Registration.tsx

commit 482c346b2a7baf958665c9474223d2557504dee5
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date:   Mon Jun 12 23:17:53 2023 -0500

    Update Login.tsx

commit 2f017aa5bf4ef91b73fe027fb346132e1a5d8b87
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date:   Mon Jun 12 23:14:17 2023 -0500

    Update env.d.ts

commit addfd95cf93ef19cae05bab652d634af64313e6a
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date:   Mon Jun 12 23:13:16 2023 -0500

    Create openidStrategy.js

commit 84c3b5c2f078494d8380f3a02e3ba2d935d8d79f
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date:   Mon Jun 12 23:09:02 2023 -0500

    Update oauth.js

commit 63225cdf33b7f42005b4a446797acbd91b7ee4a7
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date:   Mon Jun 12 23:07:35 2023 -0500

    Update index.js

commit 6efe4dafd4359ed1c3139468bf9d43f70bbaf6aa
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date:   Mon Jun 12 23:04:55 2023 -0500

    Update package.json

commit 201badbbb5a5c8d48f5c4cba3a1349d4cfc7a070
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date:   Mon Jun 12 23:03:37 2023 -0500

    Update User.js

commit 7d13d5c303465be9b1268e5f6d9bdf7bb8dfb2e4
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date:   Mon Jun 12 23:02:29 2023 -0500

    Update Dockerfile

commit 2ef7f84ea77f281c3dce61211d9fd841a6424e65
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date:   Mon Jun 12 23:00:42 2023 -0500

    Update .env.example

* Update openidStrategy.js

* Update .env.example

* Update .env.example

* Update docker-compose.yml

* Update env.d.ts

* Update .env.example

* Update .env.example

* Update config.js

* Update Login.tsx

* Update config.js

* Update Login.tsx

* Update Registration.tsx

* Update docker-compose.yml

* Update openidStrategy.js

* Update docker-compose.yml

* Update config.spec.js

* Update Login.spec.tsx

* Update Registration.spec.tsx

* Update types.ts

* Update .env.example

* Update package-lock.json

* Update openidStrategy.js

* Update openidStrategy.js

* Update config.js

* Update config.js

* Update Login.tsx

* Update Registration.tsx

* Update oauth.js

* Update openidStrategy.js

* Update openidStrategy.js

* Update Registration.tsx

* Update Login.tsx

* Update Login.tsx

* Update Registration.tsx

* Update Registration.tsx

* Update index.js

* Update index.js

* Update .env.example

* Update user_auth_system.md

updated instruction that includes OpenID set up

* Update package.json

* Update package-lock.json

* Update package-lock.json

* Update package-lock.json

* Update package-lock.json

* Update package-lock.json

* Update package-lock.json

* Update package-lock.json

* Update package-lock.json

* Update openidStrategy.js

* Update openidStrategy.js

Lookup user based on openID instead of email.  This is because not all AzureAD users may have an email tied to their account

* Update openidStrategy.js

First try to match an email, then try openIdID

* Update openidStrategy.js

* Update openidStrategy.js

Consider a family name or given name is not provided

---------

Co-authored-by: Fuegovic <32828263+fuegovic@users.noreply.github.com>
2023-06-24 22:45:52 -04:00
Danny Avila
e4c91dfbea
feat: Plugins endpoint - Reverse Engineering of official Plugins features (#197)
* components for plugins in progress

* WIP: add langchain client implementation for tools/plugins
feat(langchain): add loadHistory function for loading chat history from database
feat(langchain): add saveMessageToDatabase function for saving chat messages to database

* chore(Memory.js): remove Memory.js file from the project directory.

* WIP: adding plugin functionality
——————————————————
fix(eslintrc.js): change arrow-parens rule to always require parentheses

refactor(agent.js): reorganize imports and add new imports
feat(agent.js): add support for saving and loading chat history
feat(agent.js): add support for saving messages to database
feat(agent.js): add ChatAgent class with initialize and sendMessage methods

fix(langchain): use getConvo and saveMessage functions from models.js instead of Conversation and Message models
feat(langchain): add user parameter to loadHistory and saveMessageToDatabase functions
chore(package.json): update langchain package version to 0.0.59 and add langchain script to run test2.js file
——————————————————

* WIP: testing agent initialization

* WIP: testing various agent methods

feat(agent.js): add CustomChatAgent class and initializeAgentExecutorWithOptions method
feat(customChatAgent.js): add CustomPromptTemplate and CustomOutputParser classes

refactor(langchain): uncomment code for input2 and options
feat(langchain): add input1 to read comments on a youtube video
docs(langchain): remove commented code and add whitespace to package.json

* WIP: feat: plugin endpoint, backend class working

* feat(agent.js): add support for Zapier NLA API key
feat(agent.js): add ZapierToolKit to tools if zapierApiKey is provided
feat(customAgent.js): change prompt prefix and suffix to reflect new task-based prompt
feat(test4.js): add test for new task-based prompt

* style(langchain): improve readability and add comments to code
feat(langchain): update prompt message for custom agent
fix(langchain): update message format in test4.js

* style(customAgent.js): remove unnecessary capitalization and rephrase some sentences
test(langchain): add test2 and test3 scripts to package.json

* chore(customAgent.js): fix typo in comment, change "an" to "identical"

* WIP: gpt-4 testing

* feat(langchain): add AIPluginTool and HumanTool classes
fix(langchain): remove zapierApiKey option from ChatAgent constructor
refactor(langchain): update langchain package to v0.0.64
misc(langchain): update test2, test3, and test4 scripts to use --inspect flag

* feat(langchain): add GoogleSearchAPI tool for searching the web using Google Custom Search API

* feat(askGPTPlugins.js): add support for progress callback in ask function
fix(agent.js): pass progress callback to sendApiMessage function

* refactor(agent.js): load tools from options and initialize them in constructor
feat(agent.js): add support for environment variable SERPAPI_API_KEY
feat(agent.js): add support for environment variable ZAPIER_NLA_API_KEY
docs(agent.js): remove commented out code and add comments to clarify code

* chore(langchain): remove unused files loadHistory.js and saveMessage.js

* feat(validateTools.js): add function to validate API keys for supported tools

* feat(langchain): update langchain package to version 0.0.66
feat(langchain): add support for GPT-4 model
fix(server/index.js): fix uncaughtException handler to ignore 'fetch failed' errors

* refactor(agent.js): remove FORMAT_INSTRUCTIONS and replace with a more concise message
refactor(agent.js): remove unused variable 'errorMessage'
refactor(agent.js): change 'result' variable initialization to an empty object instead of null
refactor(agent.js): change error message when response generation fails
refactor(agent.js): change output message when response generation fails
refactor(agent.js): change output message when response generation succeeds

* chore(langchain): comment out unused model in ChatAgent constructor
feat(langchain): add test5 script to package.json for running test5.js script

* refactor(agent.js): change response to answer and update message
refactor(test3.js, test5.js): remove commented out code and add comments

The changes in agent.js are to improve the message that is returned to the user. The word "response" has been changed to "answer" to better reflect the output of the chatbot. The message has also been updated to provide clearer instructions to the user.

The changes in test3.js and test5.js are to remove commented out code and add comments to improve readability.

* docs: update links to LOCAL_INSTALL.md and defaultSystemMessage.md
fix: fix typo in BingAI/Settings.jsx
feat: add Dockerfile for app containerization

docs(google_search.md): add guide for setting up Google Custom Search API key and ID

* docs: update link to system message guidelines in Bing AI Settings component
docs: update link to system message guidelines in GOOGLE_SEARCH.md
feat: add JAILBREAK_INFO.md guide for Bing AI jailbreak mode system message guidelines

* style(api): remove unnecessary quotes and empty values from .env.example
style(agent.js): refactor getActions method to accept an input parameter
feat(agent.js): add handleChainEnd method to CustomChatAgent class
style(customAgent.js): add a new line to the end of the file
style(test5.js): comment out unused variable and update input1 variable
style(googleSearch.js): change tool name to kebab-case

* chore(langchain): comment out handleChainEnd method in agent.js
feat(langchain): add browser tool to ChatAgent in test2.js
feat(langchain): add modelOptions to ChatAgent in test2.js
feat(langchain): change question in input1 and request article review summary in test5.js

* fix(askGPTPlugins.js): fix syntax error by removing extra comma in parentMessageId field
feat(askGPTPlugins.js): add default value of null to parentMessageId parameter in ask function

* fix(askGPTPlugins.js): change endpoint string from 'GPTPlugins' to 'gptPlugins'
feat(endpoints.js): add support for gptPlugins endpoint
feat(PresetItem.jsx): add support for gptPlugins endpoint
feat(HoverButtons.jsx): add support for gptPlugins endpoint
feat(createPayload.ts): add support for gptPlugins endpoint
feat(types.ts): add gptPlugins endpoint to EModelEndpoint enum
feat(endpoints.js): add gptPlugins endpoint to availableEndpoints selector
feat(cleanupPreset.js): add support for gptPlugins endpoint
feat(getDefaultConversation.js): add support for gptPlugins endpoint
feat(getIcon.jsx): add support for gptPlugins endpoint
feat(handleSubmit.js): add support for gptPlugins endpoint

* refactor(agent.js): remove debug option from options object
refactor(agent.js): change tool name from 'google-search' to 'google'
refactor(agent.js): update description for 'google' tool
feat(agent.js): add support for citing sources when using web links in response message
fix(agent.js): update error message to not mention error to user
feat(agent.js): add unique message ids for user message and response message
feat(agent.js): limit number of search results to 5 in 'google' tool
refactor(validateTools.js): add console log to show valid tools

* feat(askGPTPlugins.js): add support for GPT-3.5-turbo model and validate model option
refactor(askGPTPlugins.js): remove unused imports and variables
refactor(askGPTPlugins.js): remove commented code
refactor(askGPTPlugins.js): remove unused parameters in ask function
feat(ask/index.js): add askGPTPlugins route to router

* feat(NewConversationMenu): add alpha tag to gptPlugins endpoint and rename it to Plugins

* refactor(askGPTPlugins.js): remove commented code and unused imports
feat(askGPTPlugins.js): add support for debug option in endpointOption
feat(askGPTPlugins.js): add support for chatGptLabel, promptPrefix, temperature, top_p, presence_penalty, and frequency_penalty in endpointOption
feat(askGPTPlugins.js): add support for sending plugin and pluginend events
feat(askGPTPlugins.js): add onAgentAction and onChainEnd callbacks to ChatAgent.sendMessage
refactor(titleConvo.js): comment out unused imports
refactor(validateTools.js): comment out console.log statement
refactor(agent.js): change saveMessage to include unfinished property
feat(agent.js): add endpoint property to saveConvo call in saveMessageToDatabase
feat(askGPTPlugins.js): add validateTools import and use it to validate endpointOption.tools before passing to ChatAgent constructor
feat(askGPTPlugins.js

* refactor(MessageHeader.jsx): extract plugins section into a separate variable and add support for gptPlugins endpoint
fix(MessageHeader.jsx): disable clicking on non-clickable endpoints

* components for plugins in progress

* feat(Plugin.jsx): add plugin prop to Plugin component and display plugin name
feat(Plugin.jsx): add loading state and display loading spinner
feat(Plugin.jsx): add Disclosure component to Plugin component
feat(Plugin.jsx): add Disclosure.Panel to Plugin component to display team pricing information
feat(Spinner.jsx): add classProp prop to Spinner component to allow for custom styling
feat(Landing.jsx): add Plugin component to Landing page for testing

testing gpt plugins

feat(plugins): Milestone commit

- Add formatAction function to format plugin actions.
- Add prefix.js file to store the prefix message for ChatAgent.
- Update ask function to include plugin object to store plugin data.
- Update onAgentAction and onChainEnd functions to format plugin data and send intermediate messages.
- Update response object to include plugin data.

The `handlers.js` file now includes a `formatAction` function that formats the action object for display in the UI. The `createOnProgress` function now returns a `sendIntermediateMessage` function that sends intermediate messages to the client.

feat (client): add support for plugins in messages

This commit adds support for plugins in messages. It includes changes to the `handlers.js`, `index.jsx`, `CodeBlock.jsx`, `Message.jsx`, `MessageHeader.jsx`, and `Plugin.jsx` files.

The `index.jsx` file now includes a `plugin` property in the `messageHandler` function.

The `CodeBlock.jsx` file now includes a `plugin` property that determines the language of the code block.

The `Message.jsx` file now includes a `Plugin` component that displays the plugin used in the message.

The `MessageHeader.jsx` file now includes a `Plugins` component that displays the enabled plugins.

feat(langchain): add OpenAICreateImage tool for generating images based on user prompts
fix(langchain): update validateTools to include create-image tool
fix(langchain): save plugin data to messageSchema
fix(server/routes/askGPTPlugins.js): save userMessage and response to messageSchema

feat(langchain): add SelfReflectionTool

Add a new tool to the LangChain agent, SelfReflectionTool, which enhances the agent's self-awareness by reflecting on its thoughts before taking action. The tool provides a space for the agent to explore and organize its ideas in response to the user's message.

Also, update the prefix message to reflect the changes in the agent's behavior and the way it should engage with the user. The prefix message now emphasizes the use of tools when necessary, and relying on the agent's knowledge for creative requests. It also provides clear instructions on how to use the 'Action' input and how to carry out tasks in the sequence written by the human.

Finally, update the OpenAICreateImage tool to return the image URL in markdown format. The tool replaces newlines and spaces in the input text with hyphens to create a valid markdown link.

Milestone commit: better error handling with custom output parser, dir and file re-org

style(langchain): fix formatting and add comments to prefix.js
fix(langchain): remove commented out code in test6.js
feat(langchain): reduce maxAttempts from 3 to 2 in CustomChatAgent's buildPromptPrefix method
feat(langchain): add null check for result.output in CustomChatAgent's buildPromptPrefix method

style(langchain): improve consistency and readability of code

This commit improves the consistency and readability of the code in the langchain directory. Specifically, it:

- Changes the case of the "Thought" output in the CustomChatAgent class to match the "Thought" output in the SelfReflectionTool class.
- Adds a currentDateString property to the CustomChatAgent class to avoid repeating the same code in multiple places.
- Updates the prefix in the prefix.js file to match the current objectives of the ChatGPT model.
- Changes the description of the OpenAICreateImage tool to request a description of the image to be generated.
- Updates the tools used by the ChatAgent in the askGPTPlugins.js file to include the Google and Browser tools instead of the Calculator and Create-Image tools.

feat: add wolfram, improve image creation, rename to dall-e

* refactor(langchain): update language and formatting in various files

- Update tool-based instructions to use proper Markdown syntax for image URLs
- Adjust temperature for modelOptions in CustomChatAgent class
- Comment out console.debug statement in CustomChatAgent class
- Update prefix in initializeCustomAgent function to use proper line breaks
- Update prefix in instructions.js to use proper line breaks and change "user" to "human"
- Update input in test6.js to use Ezra Pound instead of Hemingway
- Update return statement in OpenAICreateImage class to use "generated-image" as alt-text
- Update description in SelfReflectionTool class to provide clearer instructions
- Update tools in ask function in askGPTPlugins.js to use only the DALL-E tool and enable debug mode

feat(ask): add support for DALL-E tool in formatAction function
feat(ask): add support for self-reflection tool in formatAction function
feat(Plugin.jsx): add support for self-reflection tool in Plugin component
fix(Plugin.jsx): fix Plugin component to not display 'None' when latest is not available

* docs(openaiCreateImage.js): update tool description to clarify usage

* feat(agent.js): add message parameter to initialize function
feat(agent.js): pass message parameter to SelfReflectionTool constructor
feat(customAgent.js): add longestToolName variable to CustomOutputParser
feat(openaiCreateImage.js): replace new lines with spaces in prompt parameter
feat(selfReflection.js): add message parameter to SelfReflectionTool constructor
feat(selfReflection.js): add placeholder response to selfReflect function

* feat: frontend plugin selection

* fix: agent updates, available tools via endpoint config

* fix: improve frontend plugin selection

* feat: further customize agent and bypass executor when no tools are provided

* fix: key issue in multiselect and allow setting changes during convo in plugins endpoint

* fix: convo will save modelOptions, fix persistent errors with agent

* fix: add looser final answer parsing and edit action formatting

* fix: handle edge case where stop token is not hit and causes long parsing error

* feat: trying new prompt for image creation

* fix: improvements based on gpt-3.5

* feat: allow setting model options throughout plugin conversation

* fix: agent adjustments

* improve final reply for gpt-4, gpt-3.5 needs a more stable approach

* fix: better context output for gpt-3.5

* fix: added clarification for better context output for gpt-3.5

* feat(PluginsOptions): add advanced mode to show/hide options
style(PluginsOptions): add styles for advanced mode and show/hide options

* minor changes to styling

* refactor(langchain): add support for custom GPT-4 agent

This commit adds support for a custom GPT-4 agent in the langchain
module. The `CustomGpt4Agent` class extends the `ZeroShotAgent` class
and includes a new `createPrompt` method that generates a prompt
template for the agent. The `initializeCustomAgent` function has been
updated to use the `CustomGpt4Agent` class when the model is not GPT-3.

The `instructions.js` file has also been updated to include new
instructions for the GPT-4 agent. The `formatInstructions` method has
been removed and replaced with `gpt4Instructions` and `prefix2` and
`suffix2` have been added to include the new instructions.

feat(langchain): add custom output parser for langchain agents

This commit adds a custom output parser for langchain agents. The new parser is called CustomOutputParser and it extends ZeroShotAgentOutputParser. It takes a fields object as a parameter and sets the tools and longestToolName properties. It also sets the finishToolNameRegex property to match the final answer. The parse method of the CustomOutputParser class takes a text parameter and returns an object with returnValues, log, and toolInput properties.

This commit also adds a Gpt4OutputParser class that extends ZeroShotAgentOutputParser. It takes a fields object as a parameter and sets the tools and longestToolName properties. It also sets the finishToolNameRegex property to match the final answer. The parse method of the Gpt4OutputParser class takes a text parameter and returns an object with returnValues, log, and toolInput properties.

feat(langchain): add isGpt3 parameter to

* Stable Diffusion Plugin (#204)

* Added stable diffusion plugin

* Added example prompt

* Fixed naming

* Removed brackets in the prompt

* fix: improved agent for gpt-3.5

* fix: outparser, gpt3 instructions, and wolfram error handling

* chore: update langchain to 0.0.71

* fix: long parsing action input fix

* fix: make plugin select close on clicking label/button

* fix: make plugin select close on clicking label/button

* fix: wolfram input formatting and gpt-3 payload without plugins

* chore(api): update axios package version to 1.3.4
feat(api): add requireJwtAuth middleware to askGPTPlugins endpoint
fix(api): replace session user with user id in askGPTPlugins endpoint

docs(LOCAL_INSTALL.md): update guide for local installation and testing

This commit updates the guide for local installation and testing of the
ChatGPT-Clone app. It includes instructions for locally running the app,
updating the app version, and running tests. It also includes a new
option for running the app using Docker. The commit also fixes some
typos and formatting issues.

* add reverseProxy to plugins client

* chore(Dockerfile-app): add Dockerfile for building and running the app in a container
docs: remove outdated guides on Google search and Bing jailbreak mode

docs(LOCAL_INSTALL.md): remove outdated Windows installation instructions and update MeiliSearch configuration file

* fix: handle n/a parsing error better, reduce token waste if no agentic behavior is needed

* style: fix formatting and add parentheses around arrow function parameter
style: change hover background color to white and dark hover background color to gray-700

* chore: re-organize agent dir and files

* feat(ChatAgent.js): add support for PlanAndExecuteAgentExecutor
feat(PlanAndExecuteAgentExecutor.js): add PlanAndExecuteAgentExecutor class
feat(planExecutor.js): add demo for PlanAndExecuteAgentExecutor

* feat: add azure support to plugins

* refactor(utils): add basePath endpoint for genAzureEndpoint
feat(api): add support for Azure OpenAI API in various modules and tools

* feat: add plugin api for fetching available tools

* feat: add data service for getting available plugins

* feat: first iteration plugin store UI

* refactor: rename files to follow proper naming convention

* feat: Plugin store UI components

* feat: create separate user routes, service, controller, and add plugins to user model

* feat: create data service for adding and removing plugins per user

* feat: UI for adding and removing plugins, displaying plugins in dropdown based on what user has installed

* fix: merge conflicts from main

* fix: fix plugin items titles

* fix: tool.value -> tool.pluginKey

* fix: testing returnDirect for self-reflection

* fix: add browser tool to manifest

* refactor(outputParser.js): remove commented out code
feat(outputParser.js): add support for thought input when there is no action input

* handling 'use tool' edge case

* merge main to langchain

* fix(User.js, auth.service.js, localStrategy.js): change deprecated Joi.validate() to schema.validate() method (#322)

* fix(auth.service.js): fixes deprecated error callback in mongoose save method (#323)

* chore: run formatting script with new rules

* refactor: add requiresAuth to manifest, fix uninstall button

* version with plugin auth as dialog modal

* feat: Complete frontend for plugin auth

* frontend styling updates

* feat: api for plugin auth

* feat: Add tooltip with field description to plugin auth form

* fix: issue with plugin that has no auth

* feat(tools): add support for user-specific API keys

This commit adds support for user-specific API keys for the following tools:
- Google Search API
- Web Browser
- SerpAPI
- Zapier
- DALL-E
- Wolfram Alpha API

It also adds support for OpenAI API key for the Web Browser tool.

The `validateTools` function now takes a `user` parameter and checks for user-specific API keys before falling back to environment variables.

The `loadTools` function now takes a `user` parameter and initializes the tools with user-specific API keys if available.

The `manifest.json` file has been updated to include the new `authConfig` fields for the tools that support user-specific API keys.

The `askGPTPlugins.js` file has been updated to use the `validateTools` function with the `user` parameter.

refactor(ChatAgent.js): add user parameter to initialize function and pass it to loadTools function

refactor(tools/index.js): set default value for tools parameter in validateTools function
refactor(askGPTPlugins.js): remove duplicate user variable declaration and use the one from req object

* refactor(ChatAgent.js): await validTool() before pushing to this.tools array
refactor(tools/index.js): use Map instead of Set to store valid tools
refactor(tools/index.js): filter availableTools to only validate tools passed in
refactor(PluginController.js): filter out duplicate plugins by pluginKey
refactor(crypto.js): use environment variables for encryption key and initialization vector
feat(PluginService.js): add null check for pluginAuth in getUserPluginAuthValue()

* feat(api): add credentials key and IV to .env.example for securely storing credentials

* Adds testing for handling tools, introducing a test env to the backend
Fixes bugs & optimizes code as revealed through testing, including:
- wolfram.js: fixes bug where wolfram was not handling authentication
- ChatAgent.js: ChatAgent modified to reflect 'handleTools' changes
- handleTools.js: Moves logic out of index file
- handleTools.js: loadTools: returns only requested tools
- handleTools.js: validTools: correctly returns tools based on authentication

* test(index.test.js): add test to validate a tool from an environment variable

* test(tools): add test for initializing an authenticated tool through Environment Variables

* refactor(ChatAgent.js): remove commented out code and unused imports

* refactor(ChatAgent.js): move instructions to a separate file and import them
fix(ChatAgent.js): replace hardcoded instructions with imported ones

* refactor(ChatAgent.js): change import path for TextStream
refactor(stream.js): remove unused TextStream class

* chore(.gitignore): add .env.test to gitignore
refactor(ChatAgent.js): rename CustomChatAgent to ChatAgent
test(ChatAgent.test.js): add tests for ChatAgent class
refactor(outputParser.js): remove OldOutputParser class
refactor(outputParser.js): rename CustomOutputParser to OutputParser
docs(.env.test.example): add comment explaining how to use OPENAI_API_KEY
refactor(jestSetup.js): use dotenv to load environment variables from .env.test file

* Various optimizations and config, add tests for PluginStoreDialog

* test(ChatAgent.test.js): add test to check if chat history is returned correctly

* test: unit tests for plugin store

* test: add frontend-test script to root package.json

* feat(ChatAgent.js, askGPTPlugins.js): add support for aborting chat requests (in progress)

* test: add more client tests

* feat(ChatAgent): allow plugin requests to be cancelled

* feat(ChatAgent): allow message regeneration

* feat(ChatAgent): remember last selected tools

* Remove plugins we don't yet have from manifest.json

* fix(ChatAgent.js): increase maxAttempts from 1 to 2
fix(ChatAgent.js): change error message to 'Cancelled.' if message was aborted mid-generation
fix(openaiCreateImage.js): replace unwanted characters in input string
fix(handlers.js): compare action.tool in lowercase to 'self-reflection'

* fix(ChatAgent): Fix up plugin I/O formatting for n/a actions

* refactor(Plugin.jsx): remove unused import statement
feat(Plugin.jsx): add Plugin component with svg paths and styles

* refactor: simplify credential encryption/decryption by using a single key and IV for all environments. Update crypto.js and .env.example files accordingly.

* fix(ChatAgent.js): reduce maxAttempts from 2 to 1
feat(ChatAgent.js): add model information to responseMessage object
feat(Message.js): add model field to messageSchema
feat(Message.js): add model field to message object
feat(Message.jsx): pass model information to getIcon function
feat(getIcon.jsx): add Plugin component and handle plugin messages differently

* feat(askGPTPlugins.js): add model property to the ask function response object
feat(EndpointItem.jsx): add message property to the EndpointItem component
feat(MessageHeader.jsx): add Plugin icon to the plugins section
feat(MessageHeader.jsx): change alpha to beta in the plugins section
feat(svg): add Plugin, GPTIcon, and BingIcon components to the svg folder
refactor(EndpointItems.jsx): remove unused import statement

* refactor(googleSearch.js, wolfram.js): change error handling to return a message instead of throwing an error

* refactor(CustomAgent): remove commented code and change return object to include returnValues property

* feat(CustomAgent.js): add currentDateString to createPrompt method options
deps(api/package.json): update langchain to v0.0.81

* fix: do not show pagination if the maxPage is 1

* Add Zapier back to manifest (accidentally removed)

* chore(api): update langchain dependency to version 0.0.84

* feat(DALL-E.js): add DALL-E tool for generating images using OpenAI's DALL-E API
refactor(handleTools.js): update import for DALL-E tool
refactor(index.test.js): update import for DALL-E tool
refactor(stablediffusion.js): add check for image directory existence before saving image

* refactor(CustomAgent): rename instructions prefix variable to gpt3 and add gpt4 instructions
feat(CustomAgent): add support for gpt-4 model
fix(initializeCustomAgent.js): pass model name to createPrompt method
fix(outputParser.js): set selectedTool to 'self-reflection' when tool parsing fails

* style(langchain/tools): update guidelines for image creation in DALL-E and StableDiffusion

- Update guidelines for image creation in DALL-E and StableDiffusion tools
- Emphasize the importance of "showing" and not "telling" the imagery in crafting input
- Update formatting for the example prompt for generating a realistic portrait photo of a man
- Generate images only once per human query unless explicitly requested by the user

* docs(tools): update tool descriptions for DALL-E and Stable Diffusion

- Update the description for DALL-E tool to indicate that it is exclusively for visual content and provide guidelines for generating images with a focus on visual attributes.
- Update the description for Stable Diffusion tool to indicate that it is exclusively for visual content and provide guidelines for generating images with a focus on visual attributes.

* chore(api): update "@waylaidwanderer/chatgpt-api" dependency to version "^1.36.3"

* refactor(ChatAgent.js): use environment variable for reverse proxy url
refactor(ChatAgent.js): use environment variable for openai base path
refactor(instructions.js): update gpt3 and gpt3-v2 instructions
refactor(outputParser.js): update finishToolNameRegex in CustomOutputParser class

* refactor(DALL-E.js): change apiKey and azureKey fields to uppercase
refactor(googleSearch.js): change cx and apiKey fields to uppercase
feat(manifest.json): add authConfig field for Stable Diffusion WebUI API URL
refactor(stablediffusion.js): add url field to constructor and change getServerURL() to this.url
refactor(wolfram.js): change apiKey field to uppercase WOLFRAM_APP_ID

* refactor(handleTools.js): simplify tool loading and add support for custom tool constructors and options

* refactor(handleTools.js): remove commented out code and unused imports

* refactor(handleTools.js, index.js): change file name from wolfram.js to Wolfram.js and selfReflection.js to SelfReflection.js to follow PascalCase convention

* refactor(outputParser.js, askGPTPlugins.js): improve code readability and remove unnecessary comments

* feat(GoogleSearch.js): add GoogleSearchAPI tool to allow agents to use the Google Custom Search API
feat(SelfReflection.js): add SelfReflectionTool to allow agents to reflect on their thoughts and actions
feat(StableDiffusion.js): add StableDiffusionAPI tool to allow agents to generate images using stable diffusion webui's api

feat(Wolfram.js): add WolframAlphaAPI tool for computation, math, curated knowledge & real-time data through WolframAlpha.

* testing openai specs

* doc: fix link in .env.example

* package-update

* fix(MultiSelectDropDown.jsx): handle null or undefined values in availableValues array

* refactor(DALL-E.js, StableDiffusion.js): remove 'dist/' from image path
feat(docker-compose.yml): add comments for reverse proxy configuration

* chore(.gitignore): ignore client/public/images/
fix(DALL-E.js, StableDiffusion.js): change image path from dist/ to public/
feat(index.js): add support for serving static files from client/public/ directory

* fix: remove selected tool when uninstalled

* plugin options in progress

* fix: fix issue with uninstalling a plugin that is in use and typescript errors

* feat(gptPlugins): add Preset support for GPT Plugins endpoint
feat(ChatAgent.js): add support for agentOptions object
feat(convoSchema.js): add agentOptions field to conversation schema
feat(defaults.js): add agentOptions object to defaults
feat(presetSchema.js): add agentOptions field to preset schema
feat(askGPTPlugins.js): add support for agentOptions object in request body

feat(EditPresetDialog.jsx): add support for showing/hiding GPT Plugins agent settings
feat(EditPresetDialog.jsx): add support for setting GPT Plugins agent options
fix(EndpointOptionsDialog.jsx): change endpoint name from 'gptPlugins' to 'Plugins'

feat(AgentSettings.jsx): add AgentSettings component for GPT plugins configuration

feat(client): add GPT Plugins settings component and endpoint to Settings component
fix(client): remove unused imports in GoogleOptions component

feat(PluginsOptions): add support for agent settings and refactor code
feat(PluginsOptions): add GPTIcon to show/hide agent settings button
feat(index.ts): export SVG components

feat(GPTIcon.jsx): add className prop to GPTIcon component
feat(GPTIcon.jsx): import cn function from utils
feat(BingIcon.tsx): export BingIcon component
feat(index.ts): export BingIcon component
feat(index.ts): export MessagesSquared component
refactor(cleanupPreset.js): add default values for agentOptions in gptPlugins endpoint

feat(getDefaultConversation.js, handleSubmit.js): add agentOptions object to conversation object for GPT plugins endpoint. Update default temperature value to 0.8. Add chatGptLabel and promptPrefix properties to conversation object.

* fix: set default convo back to null

* refactor(ChatAgent.js, askGPTPlugins.js, AgentSettings.jsx): change variable names for better readability and remove redundant code

* test: add RecoilRoot to layout-test-utils

* refactor(askGPTPlugins.js): remove redundant code and use endpointOption directly
feat(askGPTPlugins.js): add validation for tools in endpointOption before using it

* chore(ChatAgent.js, Settings.jsx): add agentOptions to saveConvo function and adjust Settings component height

The ChatAgent.js file was modified to include the agentOptions object in the saveConvo function. The Settings.jsx file was modified to adjust the height of the component to ensure that all content is visible.

* refactor(ChatAgent.js): extract reverseProxyUrl option to a class property and add support for it
feat(ChatAgent.js): add support for completionMode option in sendApiMessage method
feat(ChatAgent.js): add support for user-provided promptPrefix in buildPrompt method

* feat(plugins): allow preset change mid conversation

* chore: update OPENAI_KEY to OPENAI_API_KEY in .github/playwright.yml and api/.env.example
refactor(chatgpt-client.js): update OPENAI_KEY to OPENAI_API_KEY
feat(langchain): add demo-aiplugin.js and demo-yaml.js, remove test2.js, test3.js, and test4.js

chore: remove unused test files
fix(titleConvo.js): fix typo in environment variable name
fix(askGPTPlugins.js): fix typo in environment variable name
fix(endpoints.js): fix typo in environment variable name
docs: update installation guide to use OPENAI_API_KEY instead of OPENAI_KEY in .env file

* fix(index.test.js): change import of GoogleSearchAPI to use uppercase G in GoogleSearch

* chore(api): bump langchain version

* feat(PluginController.js): authenticate plugins from environment variables if they are set
feat(PluginStoreDialog.tsx): show plugin auth form only if plugin is not authenticated by env var and require authentication
feat(types.ts): add authenticated field to TPlugin type definition

* docs: update google_search.md and add stable_diffusion.md

* Update stable_diffusion.md

* refactor(Wolfram.js): remove newline characters from query before encoding
docs(wolfram.md): add instructions for setting WOLFRAM_APP_ID in api.env to bypass prompt for AppID in plugin

* refactor(Wolfram.js): replace deprecated replaceAll method with replace method

* Update wolfram.md

* fix(askGPTPlugins): error message will reference correct Parent Message

* refactor(chatgpt-client.js, ChatAgent.js): simplify maxContextTokens calculation and add promptPrefix parameter to buildPrompt method

* docs: initial draft of intro to plugins

* Update introduction.md

* Update introduction.md

* Feature: User/Reg cleanup + Install / Upgrade script for langchain (#427)

* test: login tests

* test: finish login tests

* test: initial tests for registration

* test: registration specs

* feature: Init a app config file
- Simplifies the ENV vars too
- Legacy fallbacks for older builds

* refactor(auth): Refactor log in/out controllers
- Moves both login and logout controllers to their own file

* chore(jwt): Throw warning if secret is default

* feature(frontend): Ability to disable registration

* feature(env): Env in the root + version support
ie .env.prod, .env.dev, .env.test

* feature: Upgrade .env script for users

* chore(config): Refactor and remove legacy env refs

* feature(upgrade): Upgrade script for .env changes

* feature: Install script and upgrade script

* bugfix: Uncomment line to remove old .env file

* chore: rename OPENAI_KEY to OPENAI_API_KEY

* chore: Cleanup config changes/bugs

* bugfix: Fix config and node env issues

* bugfix: Config validation logic

* bugfix: Handle unusual env configs gracefully

* bugfix: Revert route changes and fix registration disable calling

* bugfix: Fix env issues in frontend

* bugfix: Fix login

* bugfix: Fix frontend envs

* bugfix: Fix frontend jest tests

* bugfix: Fix upgrade scripts

* bugfix: Allow install in non-tty envs

* bugfix(windows): Use cross-env to set for windows

* bugfix(env): Handle .env being incorrect to begin with for client domain

* chore(merge-conflict): Update to LibreChat

* chore(merge-conflict): Update to package-lock

---------

Co-authored-by: Daniel D Orlando <dan@danorlando.com>

* chore: comment out unused agent options

* Update langchain plugins docs (#461)

* Update: install docs (LibreChat) (#458)

* Release: rename project from ChatGPT Clone to LibreChat

Release: rename project from ChatGPT Clone to LibreChat

* Release: rename project from ChatGPT Clone to LibreChat

Release: rename project from ChatGPT Clone to LibreChat

* Release: rename project from ChatGPT Clone to LibreChat

Release: rename project from ChatGPT Clone to LibreChat

* Release: rename project from ChatGPT Clone to LibreChat

Release: rename project from ChatGPT Clone to LibreChat

* Update documentation_guidelines.md

* Update introduction.md

add link to readme

* Update stable_diffusion.md

add link back to readme

* Update wolfram.md

add link back to readme

* Update README.md

add Plugins to ToC

* feat(ChatAgent.js): add support for langchainProxy configuration option

Add a new configuration option `langchainProxy` to the ChatAgent class. If the option is set, the `basePath` configuration option of the `ChatOpenAI` instance is set to the base path of `langchainProxy`.

* bugfix(errors): Possible workaround for error flashing (#463)

* Test/user auth system client tests (#462)

* test: login tests

* test: finish login tests

* test: initial tests for registration

* test: registration specs

* chore(api): update langchain dependency to version 0.0.91

* Update introduction.md

* Update introduction.md

* Update introduction.md

* fix: no longer renders html in markdown content
fix: patch XSS vulnerability completely by handling cursor on the frontend without css/html

* fix(Content.jsx): fix cursor logic so it never shows for static messages

* bugfix(langchain): Upgrade script, docker, env and docs (#465)

* bugfix(errors): Remove incorrect manual fix from misunderstanding

* chore(env): Lets not make a .env.prod and use the prod values in the default root .env
- .env.dev will still be created

* chore(upgrade.js): Lets tell the user about .env.dev if we create it

* bugfix(env): Move to full name environments for vite
- .env.prod => .env.production
- .env.dev => .env.development

* chore(env-example): Explain how to get google login working in production

* bugfix(oauth): Minor fix to point isProduction to a correct value

* bugfix: Typo in public

* chore(docs): Update docs to note the changes to .env

* chore(docs): Include note on how to get google auth working in dev and how to disable registration

* bugfix: Fix missing env changes

* bugfix: Fix up docker to work with new env / npm changes

* Update .env.example

Cleanup the env of the palm2 instruction and fix to formating

* chore(docker): Simplify Docker deployments
- Needs work to support dev env/hotreload

* bugfix: Remove volume map for client dir

* chore(env-example): Change instructions to be more user centric

---------

Co-authored-by: Fuegovic <32828263+fuegovic@users.noreply.github.com>

* update: install docs (#466)

* Add files via upload

* Update apis-and-tokens.md

* Update apis-and-tokens.md

* Update docker_install.md

* Update linux_install.md

* Rename apis-and-tokens.md to apis_and_tokens.md

* Update docker_install.md

* Update linux_install.md

* Update mac_install.md

* Update linux_install.md

* Update docker_install.md

* Update windows_install.md

* Update apis_and_tokens.md

* Update mac_install.md

* Update linux_install.md

* Update docker_install.md

* Update README.md

* Update README.md : Breaking Changes

---------

Co-authored-by: Danny Avila <110412045+danny-avila@users.noreply.github.com>

* Update README.md (#468)

add new API/Token docs to Toc

* docs: guide on how to create your own plugin

* Update make_your_own.md

* Update make_your_own.md

* feat(docker): add build args for frontend variables in Dockerfile
feat(docker-compose): add build args for frontend variables in docker-compose.yml

* Update docker_install.md

* Update docker_install.md

* Update docker_install.md

* Update docker_install.md

* docs: update (#469)

* Update: make_your_own.md

* Update README.md

add `make_your_own.md` to ToC

* Update linux_install.md

* Update mac_install.md

* Update windows_install.md

* Update apis_and_tokens.md

* Update docker_install.md

* Update docker_install.md

* Update linux_install.md

* Update mac_install.md

* Update windows_install.md

* Update apis_and_tokens.md

* Update user_auth_system.md

* Update docker_install.md

clean up of repeated information

* Update docker_install.md

* Update docker_install.md

typo

* fix: fix issue with pluginstore next and prev buttons going out of bounds

* fix: add icon for web browser plugin

* docs(GoogleSearch.js): update description of GoogleSearchAPI class to be more descriptive of its functionality

* feat(ask/handlers.js): add cursor to indicate ongoing progress of a long-running task
fix(Content.jsx): handle null content in the message stream by replacing it with an empty string (with a space so a text space is rendered)

* Update README.md

* Update README.md

* fix: plugin option stacking order

* update: web browser icon (#470)

* Delete web-browser.png

* update: web browser icon

* Update readme (#472)

* Update README.md

Discord badge now displays the number of online users
Project description has been updated to reflect current status
Feature section has been updated to reflect current capabilities
Sponsors section is now located just above the contributors section
Roadmap has been removed as it was outdated.

* Delete roadmap.md

Roadmap has been removed to streamline document maintenance.

* Update README.md

* Update README.md

* Delete CHANGELOG.md

* fix: pluginstore in mobile view getting clipped and not scrolling

* docs(linux_install.md): remove duplicate git clone command

* chore(Dockerfile): comment out nginx-client build stage
docs(README.md): update installation instructions and mention docker-compose changes
docs(features/plugins/introduction.md): bold plugin names and add emphasis to notes

* feat: add superscript and subscript support to markdown rendering
refactor: support markdown citations for BingAI

* refactor: support markdown citations for BingAI

---------

Co-authored-by: David Shin <42793498+dncc89@users.noreply.github.com>
Co-authored-by: Daniel D Orlando <dan@danorlando.com>
Co-authored-by: LaraClara <2524209+ClaraLeigh@users.noreply.github.com>
Co-authored-by: Fuegovic <32828263+fuegovic@users.noreply.github.com>
2023-06-10 19:10:03 -04:00
Dan Orlando
7fdc862042
Build/Refactor: lint pre-commit hook and reformat repo to spec (#314)
* build/refactor: move lint/prettier packages to project root, install husky, add pre-commit hook

* refactor: reformat files

* build: put full eslintrc back with all rules
2023-05-18 14:09:31 -04:00
Dan Orlando
dac19038a3
feat: Auth and User System (#205)
* server-side JWT auth implementation

* move oauth routes and strategies, fix bugs

* backend modifications for wiring up the frontend login and reg forms

* Add frontend data services for login and registration

* Add login and registration forms

* Implment auth context, functional client side auth

* protect routes with jwt auth

* finish local strategy (using local storage)

* Start setting up google auth

* disable token refresh, remove old auth middleware

* refactor client, add ApiErrorBoundary context

* disable google and facebook strategies

* fix: fix presets not displaying specific to user

* fix: fix issue with browser refresh

* fix: casing issue with User.js (#11)

* delete user.js to be renamed

* fix: fix casing issue with User.js

* comment out api error watcher temporarily

* fix: issue with api error watcher (#12)

* delete user.js to be renamed

* fix: fix casing issue with User.js

* comment out api error watcher temporarily

* feat: add google auth social login

* fix: make google login url dynamic based on dev/prod

* fix: bug where UI is briefly displayed before redirecting to login

* fix: fix cookie expires value for local auth

* Update README.md

* Update LOCAL_INSTALL structure

* Add local testing instructions

* Only load google strategy if client id and secret are provided

* Update .env.example files with new params

* fix issue with not redirecting to register form

* only show google login button if value is set in .env

* cleanup log messages

* Add label to button for google login on login form

* doc: fix client/server url values in .env.example

* feat: add error message details to registration failure

* Restore preventing paste on confirm password

* auto-login user after registering

* feat: forgot password (#24)

* make login/reg pages look like openai's

* add password reset data services

* new form designs similar to openai, add password reset pages

* add api's for password reset

* email utils for password reset

* remove bcrypt salt rounds from process.env

* refactor: restructure api auth code, consolidate routes (#25)

* add api's for password reset

* remove bcrypt salt rounds from process.env

* refactor: consolidate auth routes, use controller pattern

* refactor: code cleanup

* feat: migrate data to first user (#26)

* refactor: use /api for auth routes

* fix: use user id instead of username

* feat: migrate data to first user on register

* fix: fix social login routes after refactor (#27)

* refactor: use /api for auth routes

* fix: use user id instead of username

* feat: migrate data to first user on register

* fix: fix social login routes

* fix: issue with auto-login when logging out then logging in with new browser window (#28)

* refactor: use /api for auth routes

* fix: use user id instead of username

* feat: migrate data to first user on register

* fix: fix social login routes

* fix: fix issue with auto-login in new tab

* doc: Update README and .env.example files with user system information (#29)

* refactor: use /api for auth routes

* fix: use user id instead of username

* feat: migrate data to first user on register

* fix: fix social login routes

* fix: fix issue with auto-login in new tab

* doc: update README and .env.example files

* Fixup: LOCAL_INSTALL.md PS instructions (#200) (#30)

Co-authored-by: alfredo-f <alfredo.fomitchenko@mail.polimi.it>

* feat: send user with completion to protect against abuse (#31)

* Fixup: LOCAL_INSTALL.md PS instructions (#200)

* server-side JWT auth implementation

* move oauth routes and strategies, fix bugs

* backend modifications for wiring up the frontend login and reg forms

* Add frontend data services for login and registration

* Add login and registration forms

* Implment auth context, functional client side auth

* protect routes with jwt auth

* finish local strategy (using local storage)

* Start setting up google auth

* disable token refresh, remove old auth middleware

* refactor client, add ApiErrorBoundary context

* disable google and facebook strategies

* fix: fix presets not displaying specific to user

* fix: fix issue with browser refresh

* fix: casing issue with User.js (#11)

* delete user.js to be renamed

* fix: fix casing issue with User.js

* comment out api error watcher temporarily

* feat: add google auth social login

* fix: make google login url dynamic based on dev/prod

* fix: bug where UI is briefly displayed before redirecting to login

* fix: fix cookie expires value for local auth

* Only load google strategy if client id and secret are provided

* Update .env.example files with new params

* fix issue with not redirecting to register form

* only show google login button if value is set in .env

* cleanup log messages

* Add label to button for google login on login form

* doc: fix client/server url values in .env.example

* feat: add error message details to registration failure

* Restore preventing paste on confirm password

* auto-login user after registering

* feat: forgot password (#24)

* make login/reg pages look like openai's

* add password reset data services

* new form designs similar to openai, add password reset pages

* add api's for password reset

* email utils for password reset

* remove bcrypt salt rounds from process.env

* refactor: restructure api auth code, consolidate routes (#25)

* add api's for password reset

* remove bcrypt salt rounds from process.env

* refactor: consolidate auth routes, use controller pattern

* refactor: code cleanup

* feat: migrate data to first user (#26)

* refactor: use /api for auth routes

* fix: use user id instead of username

* feat: migrate data to first user on register

* fix: fix social login routes after refactor (#27)

* refactor: use /api for auth routes

* fix: use user id instead of username

* feat: migrate data to first user on register

* fix: fix social login routes

* fix: issue with auto-login when logging out then logging in with new browser window (#28)

* refactor: use /api for auth routes

* fix: use user id instead of username

* feat: migrate data to first user on register

* fix: fix social login routes

* fix: fix issue with auto-login in new tab

* doc: Update README and .env.example files with user system information (#29)

* refactor: use /api for auth routes

* fix: use user id instead of username

* feat: migrate data to first user on register

* fix: fix social login routes

* fix: fix issue with auto-login in new tab

* doc: update README and .env.example files

* Send user id to openai to protect against abuse

* add meilisearch to gitignore

* Remove webpack

---------

Co-authored-by: alfredo-f <alfredo.fomitchenko@mail.polimi.it>

---------

Co-authored-by: Danny Avila <110412045+danny-avila@users.noreply.github.com>
Co-authored-by: Alfredo Fomitchenko <alfredo.fomitchenko@mail.polimi.it>
2023-05-07 10:04:51 -07:00