Skip to content

Develop - #3

Merged
BYLinMou merged 3 commits into
mainfrom
develop
Oct 11, 2025
Merged

BYLinMou merged 3 commits into
mainfrom
develop

Conversation

@BYLinMou

Copy link
Copy Markdown
Owner

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 the main branch and bumps the app version. The most significant changes are grouped below:

API Refactoring and Centralization:

  • Extracted and centralized the OpenAI API call logic into a new callOpenAI helper function, reducing code duplication and standardizing how prompts are sent and responses are parsed across endpoints. (server/src/routes/api.js) [1] [2]
  • Added a getLanguageInstruction utility to consistently handle language-specific instructions for both standard and roleplay AI responses. (server/src/routes/api.js)
  • Improved error handling and response structure for all AI endpoints, providing more consistent and informative error messages. (server/src/routes/api.js) [1] [2] [3]

Configuration Improvements:

  • Enhanced the loadApiConfig function to require and validate a DEFAULT_MODEL configuration, ensuring the AI model is always specified and preventing misconfiguration. (server/src/routes/api.js)
  • Cleaned up and clarified how models are selected for AI requests, always defaulting to the configured model and removing scattered fallback logic. (server/src/routes/api.js)

Workflow and Versioning:

  • Updated the GitHub Actions workflow to only build and push Docker images on the main branch, not on develop. (.github/workflows/build.yml)
  • Bumped the application version to 0.0.4 and updated the publish date in package.json. (package.json)

These changes make the backend codebase more maintainable, robust, and easier to extend for future AI-powered features.

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.
@BYLinMou
BYLinMou merged commit c3293a2 into main Oct 11, 2025
1 check passed
@BYLinMou
BYLinMou deleted the develop branch October 11, 2025 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant