Commit Graph
70 Commits
Author SHA1 Message Date
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
Chenyme f937d57d1e feat: enhance token management with normalization and improved error handling for token updates 2026-02-06 17:12:50 +08:00
Chenyme 9d6af73f35 feat: update image processing API to support response format customization and enhance request validation 2026-02-06 15:36:12 +08:00
Chenyme f84f5f4d6a refactor: remove voice service and related API, integrate voice functionality into admin routes 2026-02-06 14:19:17 +08:00
Chenyme ef5a8dc8e5 refactor: reorganize imports and create new services for models, assets, and media processing 2026-02-06 10:12:48 +08:00
ai88030669 02d45b9bd0 补充下参数 2026-02-05 21:10:07 +08:00
ai88030669 32565a8e33 添加了audio live 功能 2026-02-05 19:17:54 +08:00
Chenyme a2c2b1ba7f feat: add super refresh interval configuration and update token management logic 2026-02-04 23:34:58 +08:00
Chenyme b8997a22ef fix: update video configuration and format handling 2026-02-04 18:27:15 +08:00
Chenyme 76c7c1cc0d fix: added backend API Key retrieval functionality and updated authentication logic 2026-02-04 17:58:58 +08:00
piexian d25d2eae18 style: 修复 ruff 代码规范问题
- 修复裸 except 为 except Exception
- 修复单行多语句 (E701)
- 移除未使用的导入 (F401)
- 添加 noqa 注释忽略 main.py 的 E402 (设计决策)
- 代码格式化
2026-02-04 06:40:29 +08:00
piexian d605e0338f fix: 修复代码审查中的问题
1. processor.py: 标签过滤逻辑基于 filter_tags 配置而非硬编码 grok:render
2. chat.py: VALID_ROLES 移除 function(它是 tool 的别名)
3. chat.py: validate_stream 对未识别值抛出错误而非转为 True
4. retry.py: extract_status 回退到 status_code 属性
2026-02-04 05:22:56 +08:00