Conversation
Consolidates OpenAI API call logic into a reusable helper, improves configuration loading (including default model), and streamlines language instruction handling. Refactors all AI-related endpoints to use the new helper, reducing code duplication and improving maintainability. Also restores health and version endpoints to the top, and improves error handling and parameter merging.
The GitHub Actions workflow now triggers on push and pull request events only for the main branch, removing the develop branch from the trigger list.
Updated the package version to 0.0.4 and changed the publishDate to 2025-10-12 in package.json.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request refactors and streamlines the API logic in
server/src/routes/api.js, centralizing the AI call logic, improving configuration management, and enhancing error handling. It also updates the workflow configuration to only build Docker images on themainbranch and bumps the app version. The most significant changes are grouped below:API Refactoring and Centralization:
callOpenAIhelper function, reducing code duplication and standardizing how prompts are sent and responses are parsed across endpoints. (server/src/routes/api.js) [1] [2]getLanguageInstructionutility to consistently handle language-specific instructions for both standard and roleplay AI responses. (server/src/routes/api.js)server/src/routes/api.js) [1] [2] [3]Configuration Improvements:
loadApiConfigfunction to require and validate aDEFAULT_MODELconfiguration, ensuring the AI model is always specified and preventing misconfiguration. (server/src/routes/api.js)server/src/routes/api.js)Workflow and Versioning:
mainbranch, not ondevelop. (.github/workflows/build.yml)0.0.4and updated the publish date inpackage.json. (package.json)These changes make the backend codebase more maintainable, robust, and easier to extend for future AI-powered features.