Commit Graph
81 Commits
Author SHA1 Message Date
Jensen Zhang 3e607e9f7c feat(token): add consumed mode for quota management
- Add 'consumed_mode_enabled' config option (opt-in, default false)
- Track local consumption separately from API quota
- consumed increases in both modes; quota deduction differs by mode
- Prefer tokens with lower consumed amount in pool selection
- UI dynamically switches between 'remaining quota' and 'consumed' display
- Disable quota editing in edit modal when consumed mode is enabled
- Maintain backward compatibility with existing configs
2026-03-12 08:10:42 +00:00
Chenyme ee3ddf420c feat: implement text sanitization for proxy and token configurations, enhancing security and data integrity across API endpoints 2026-03-06 22:29:56 +08:00
Chenyme becb23b771 chore: update version to 1.6.0, refactor API routes by renaming modules, and remove deprecated admin and function APIs for improved structure and maintainability 2026-03-06 18:14:21 +08:00
Chenyme 04b7ee481d refactor: replace public API functionality with function API, update configuration and static files accordingly 2026-03-06 17:37:15 +08:00
Chenyme db065659af refactor: rename public directory to _public and remove unused static files to streamline asset management 2026-03-06 16:11:34 +08:00
Chenyme 1b3bcb3b3e refactor: streamline static file management by removing unused CSS and JS files, and enhance admin/public page responses with centralized file handling 2026-03-06 15:25:29 +08:00
Chenyme da979f5a59 fix: refactor static file handling to use a public directory and simplify admin/public page responses with redirects 2026-03-06 15:00:19 +08:00
Chenyme 4217dbed26 feat: implement centralized file response handling for admin and public pages, enhancing error management and code reusability 2026-03-06 14:18:17 +08:00
Chenyme e44f267332 feat: add video generation API with validation for video length and integrate into main application 2026-03-06 11:40:48 +08:00
Chenyme a511607cae feat(api): Integrate chat router with public key verification 2026-03-01 14:56:16 +08:00
Chenyme 1c501e67ac feat: Introduce grok-imagine-1.0-fast model, replacing grok-superimage-1.0, and update related documentation and API references. 2026-02-28 10:21:34 +08:00
Mo Li a358872cb5 fix: avoid admin storage coroutine warning and skip futile transient retries 2026-02-26 19:41:00 +08:00
Chenyme 3a77067a10 feat: update README and API documentation to include new tool calling features and response parameters 2026-02-26 15:08:21 +08:00
Chenyme bed5eb6af6 feat: support responses router to main application 2026-02-26 14:47:06 +08:00
Chenyme c2989e8579 refactor: update image handling in chat completions and services 2026-02-26 11:38:25 +08:00
Chenyme cf4942d68b Merge branch 'main' into pr/function-calling 2026-02-26 09:49:16 +08:00
zxc123developer 1d49377bee feat: add OpenAI-compatible function calling (tools / tool_calls)
Implements prompt-based tool call emulation to support the OpenAI
function calling API (tools / tool_calls / tool_choice), fixing #219.

Changes:
- New module app/services/grok/utils/tool_call.py
  - build_tool_prompt(): inject tool definitions into system prompt
    using <tool_call> XML tag format
  - parse_tool_calls(): regex-extract <tool_call> blocks and convert
    to OpenAI-format tool_calls list
  - format_tool_history(): convert multi-turn tool messages to text
    for Grok's single-message API
  - build_tool_overrides(): experimental passthrough mode helper
- app/api/v1/chat.py
  - Add tool_calls, tool_call_id, name fields to MessageItem
  - Add tools, tool_choice, parallel_tool_calls to ChatCompletionRequest
  - Add "tool" to VALID_ROLES
  - Validate tool role messages (require tool_call_id)
  - Validate tools format and tool_choice values
- app/services/grok/services/chat.py
  - MessageExtractor: preprocess tool history and inject tool prompt
  - StreamProcessor: buffer tokens when tools active, emit tool_calls
    chunk with finish_reason="tool_calls" after stream ends
  - CollectProcessor: parse tool_calls from final content
  - GrokChatService/ChatService: forward tools params through the stack
- config.defaults.toml: add tool_call_mode = "prompt" config key
  (supports "prompt" default and experimental "passthrough" mode)

Backward compatible: requests without tools are completely unaffected.
2026-02-24 21:49:25 +08:00
guanyuyang 0356bb4ad8 Clarify PR flow and tool handling 2026-02-24 08:16:30 +08:00
guanyuyang 67fc2cc475 fix: 兼容 OpenAI-like content 对象与 assistant null content 2026-02-24 07:53:14 +08:00
Jensen Zhang e5e9225898 refactor: extract response formatting utilities and apply to image services
- Add app/services/grok/utils/response.py with reusable utilities:
  - make_response_id(): generate unique response IDs
  - make_chat_chunk(): build OpenAI-compatible chat completion chunks
  - make_chat_response(): build non-streaming chat completion responses
  - wrap_image_content(): wrap image content in markdown format
- Refactor image.py and image_edit.py to use these utilities
- Simplify chat.py non-streaming responses with make_chat_response()
2026-02-21 09:51:48 +08:00
Jensen Zhang 679b94622f fix: standardize image generation response to OpenAI ChatCompletion format
- Standardize non-streaming response from 'data' to 'choices' format
- Add chat_format parameter to image services
- Support SSE streaming with OpenAI chat.completion.chunk format
- Fix partial_image events to use chat format
- Pass chat_format to _stream_ws in _stream_retry
- Wrap image content in markdown format for chat completions
2026-02-20 13:59:14 +08:00
Chenyme 7454722068 chore: update version to 1.5.0 and add public chat endpoint 2026-02-20 00:29:11 +08:00
Chenyme f7976e12a5 feat: add usage flush interval configuration and enhance token management 2026-02-19 17:37:20 +08:00
Chenyme 1062006abb refactor: update Dockerfile for multi-stage build 2026-02-19 10:20:59 +08:00
Chenyme ee6ac473d8 chore: remove unused files 2026-02-16 01:18:50 +08:00
Chenyme ad92974ccc rrefactor: change admin and public API routers to compatible vercel 2026-02-16 01:06:03 +08:00
Chenyme ea86c91bbc fix: vercel deploy error 2026-02-16 00:21:09 +08:00
Chenyme 928faabbac refactor: update configuration settings, enhance public API integration, and streamline service imports while removing deprecated files 2026-02-15 17:43:57 +08:00
Chenyme 7f0db522ae refactor: enhance configuration management by adding public API key support, reorganizing chat and image settings, and removing deprecated components 2026-02-15 00:39:30 +08:00
Chenyme d04bc4ee4c refactor: streamline chat and video processing services, enhance validation, and remove unused components 2026-02-13 20:22:52 +08:00
Chenyme 6257b68527 refactor: remove unused files and streamline batch processing configuration in services 2026-02-13 14:21:11 +08:00
Chenyme e5df9ca323 refactor: reorganize batch processing utilities and update import paths across services 2026-02-13 14:01:40 +08:00
Chenyme c62faf193b refactor: update import paths for ModelService and remove unused model files 2026-02-13 13:36:16 +08:00
Chenyme 6228788956 refactor: consolidate usage configuration and update related services for improved clarity and performance 2026-02-13 13:27:45 +08:00
Chenyme 314102dcba feat: add NSFW configuration and refactor related services for improved management 2026-02-13 13:00:12 +08:00
Chenyme 0d0e793181 feat: enhance asset management configuration and services 2026-02-13 11:25:50 +08:00
Chenyme 432acf41cf refactor: replace DownloadService with CacheService in admin API and update related methods 2026-02-13 00:31:05 +08:00
Chenyme 716e274b89 refactor: update GROK services and remove unused components 2026-02-11 17:35:25 +08:00
Chenyme d947ef69ba refactor: simplify usage service by removing model_name parameter and integrating reverse request handler for rate limits 2026-02-09 22:03:27 +08:00
Chenyme d3a1b09d3a refactor: integrate reverse request handlers for image and video services 2026-02-09 16:41:43 +08:00
Chenyme 64180c6e3a feat: add root redirect endpoint to admin API for improved navigation 2026-02-07 23:50:38 +08:00
Chenyme 14c46255bd feat: implement Imagine session management with WebSocket and SSE support for real-time image generation 2026-02-07 23:48:28 +08:00
Chenyme 0bd1aaf335 feat: introduce DATA_DIR environment variable for configurable data storage paths 2026-02-07 23:00:29 +08:00
Chenyme a84880c75b feat: add Imagine feature with WebSocket support for real-time image generation 2026-02-07 16:37:50 +08:00
Chenyme 8361e65c31 refactor: clean up code formatting and improve readability across multiple files 2026-02-07 13:34:55 +08:00
Chenyme bcd94069a7 feat: migrate configuration structure to improve organization and flexibility 2026-02-07 13:30:50 +08:00
Chenyme 5d369596c5 feat: improve token management and logging across services 2026-02-07 13:11:23 +08:00
Chenyme 2e201b5ebf feat: enhance configuration management and service initialization 2026-02-07 12:40:42 +08:00
Chenyme b132590045 feat: enhance configuration options across services for improved flexibility 2026-02-07 11:32:25 +08:00
Chenyme 23a712eeb7 feat: add WebSocket support for image generation and editing, enhance configuration options for image processing 2026-02-07 02:16:11 +08:00