Commit Graph
196 Commits
Author SHA1 Message Date
Chenyme 25f947790e chore: enhance token management with batch enable/disable functionality 2026-03-05 16:54:12 +08:00
Chenyme f180c952d2 feat: add CF cookies configuration and improve proxy handling in asset services 2026-03-04 23:00:23 +08:00
Chenyme 944412ca47 chore: enhance configuration with new fields for custom instructions and session management 2026-03-04 22:25:44 +08:00
Chenyme 43317ea186 Merge pull request #270 from africa1207/main
feat: 增加自定义指令
2026-03-04 20:16:03 +08:00
Chenyme 8181ba167a Merge pull request #269 from arces/feature/english-translation
English Translation + Translation Docs
2026-03-04 18:25:29 +08:00
Chenyme 18051f381f feat: add static versioning to locale fetch and enhance chat session management with default title handling 2026-03-04 18:22:10 +08:00
Chenyme a6828709ef feat: enhance WebSocket proxy handling and add session reset status code 2026-03-04 17:57:35 +08:00
liutao 9b90dddc16 feat: 增加自定义指令 2026-03-04 17:05:44 +08:00
Dan Janes d5a961ff11 English Translation + Translation Docs
Added an i18n English translation + Original Chinese text.
Readme talking about how it works, how to use it in the future, etc
2026-03-03 15:36:39 -08:00
being s a8a0f036b4 feat: add proxy SSL verification skip and configurable session reset codes
When using a proxy with self-signed certificates, the original strict SSL
verification causes connection failures. This patch adds:

- `proxy.skip_proxy_ssl_verify` config option to bypass proxy SSL
  verification (PROXY_SSL_VERIFYPEER / PROXY_SSL_VERIFYHOST) without
  affecting target server SSL validation
- WebSocket SSL context override for proxy connections
- `retry.reset_session_status_codes` config option to allow customizing
  which HTTP status codes trigger a session reset (defaults to [403])
2026-03-02 15:39:12 +08:00
Chenyme 4706d91bd7 chore: bump version to 1.5.4 and update API key description in configuration files 2026-03-01 16:54:19 +08:00
Chenyme 4fbf192cbd feat: update chat UI with multi-session management and improved layout 2026-03-01 16:00:31 +08:00
Chenyme cf3e2251a7 Merge main 2026-03-01 15:42:51 +08:00
Chenyme 708a75338a refactor: enhance cf_refresh configuration and improve error handling 2026-03-01 15:38:43 +08:00
Chenyme a511607cae feat(api): Integrate chat router with public key verification 2026-03-01 14:56:16 +08:00
piexian 111614a6bd fix(ui): 修复移动端适配与安全渲染问题
- 顶部导航栏移动端适配:缩减间距、品牌文字隐藏、链接横向滚动
- 底部 footer 移动端居中显示,防止溢出裁切
- 输入栏移动端改为双排布局:上排输入框、下排功能按钮
- 模型/推理下拉菜单移除 overflow 裁剪,修复移动端无法展示问题
- 对话区滚动条改为细线样式,悬停时显示、拖动时加深
- 统一 innerHTML 渲染入口为 setRenderedHTML,收口 XSS 风险
- 恢复空密钥时的 verify 校验,页面初始化未通过认证时跳转登录
2026-03-01 10:47:11 +08:00
John Howe fc37404ebe refactor: remove emoji from logs, make flaresolverr optional via profiles
- Remove all emoji from cf_refresh log messages
- Add Docker Compose profiles to flaresolverr (only starts with --profile cf-refresh)
- Default: docker compose up starts grok2api + warp only, no 500MB Chrome process
- CF refresh stays disabled unless explicitly configured
2026-03-01 10:25:32 +08:00
John Howe a4e7b96d29 fix: remove nginx, restore imagine_fast selects, clean up docker-compose
- Remove nginx service and nginx/ directory (not in main branch)
- Restore imagine_fast size/response_format select inputs
- Revert grok2api to ports: 8000:8000 (direct expose)
- Remove dev-testing source mounts from docker-compose
- Restore warp port to 1080
2026-03-01 10:16:42 +08:00
John Howe b85b87072b fix: use loguru logging, empty default flaresolverr_url, add nginx config, mount local source
- Switch cf_refresh module from stdlib logging to loguru for consistent log output
- Set flaresolverr_url default to empty so FLARESOLVERR_URL env var triggers auto-enable
- Add nginx/conf/default.conf with SSE streaming support
- Mount local source files in docker-compose for development testing
- Change warp port to 1180 to avoid local conflict
2026-03-01 10:02:35 +08:00
John Howe 26504b672f feat: add cf_refresh auto-refresh module and full Docker Compose deployment
- Add app/services/cf_refresh/ module (FlareSolverr-based cf_clearance auto-refresh)
- Integrate CF refresh startup/shutdown in main.py lifespan
- Add CF refresh config entries in config.defaults.toml (enabled, flaresolverr_url, refresh_interval, timeout)
- Update headers.py to use cf_cookies from FlareSolverr instead of single cf_clearance
- Add admin panel CF refresh UI with toggle-linked field disabling
- Docker Compose: add warp (SOCKS proxy), nginx (reverse proxy), flaresolverr containers
2026-03-01 09:48:13 +08:00
piexian 623570ccb4 fix(auth,chat): 加固认证逻辑与修复前端交互缺陷
- 移除 verify_api_key 中 public_enabled 无密钥时的免认证后门
- 对 public_key 进行 strip 归一化,避免配置空白导致哈希不匹配
- 前端空密钥时直接缓存空值,移除多余的 verify 网络请求
- 阻止删除正在流式传输中的消息,防止 session 状态不同步
- 编辑消息取消时使用 DOM 克隆恢复,避免 innerHTML 注入风险
- 合并三个全局 click 监听器为一个,减少事件绑定开销
2026-03-01 03:42:44 +08:00
piexian e3b3aab4dd feat(chat): 添加多会话管理与 UI 交互优化
- 实现基于 localStorage 的多会话管理(创建/切换/删除/重命名)
- 新增侧边栏会话列表,支持移动端滑入式布局
- 替换原生 select 为自定义模型/推理强度下拉菜单
- 支持消息编辑、删除、从指定位置重新生成
- 添加上下文压缩功能(保留最近 4 条消息)
- 优化 public_key 认证:前端哈希存储,后端支持原始值与哈希匹配
- 改进思考过程展示:工具卡片彩色标识、自动折叠与计时优化
2026-03-01 03:24:47 +08:00
Chenyme 6c32305cc6 Merge branch 'main' into pr/248
# Conflicts:
#	app/services/grok/services/image.py
#	config.defaults.toml
2026-02-28 10:58:22 +08:00
Chenyme 45a8be9187 Merge branch 'main' into main 2026-02-28 10:23:34 +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
Chenyme 3b4316c145 Merge pull request #236 from chenhuawang-04/fix/image-draft-filter-v2
fix: improve final image selection in stream processor
2026-02-28 09:24:29 +08:00
qoomezhu 547dbe9d15 Merge pull request #2 from qoomezhu/feat/image-mode-token-routing
image: 优先选择 nsfw-tag Token + WebSocket 重试配置
2026-02-28 00:29:38 +08:00
Mo Li e733e84a46 feat: make blocked review grace timeout configurable 2026-02-27 14:20:46 +08:00
qoomezhu 8377575fe8 image: prefer nsfw-tag tokens + configurable ws retries 2026-02-27 13:03:39 +08:00
qoomezhu d89f43bde6 token: allow pick_token() to prefer tagged tokens 2026-02-27 12:59:35 +08:00
qoomezhu 101c8ab1f3 token: allow get_token() to prefer tagged tokens 2026-02-27 12:59:19 +08:00
qoomezhu 87cba0cf6a token: support prefer_tags when selecting token 2026-02-27 12:54:13 +08:00
qoomezhu 16332d611d admin(token): add 500/1000/2000 page size options 2026-02-27 12:51:58 +08:00
chenhuawang-04andClaude Opus 4.6 53ab1fd086 fix: improve final image selection in stream processor
When n=1, the stream processor locks onto the first image received
as target. If a different image gets its final version first,
completed >= n breaks the WebSocket loop, but the processor saves
the target's medium-quality data as "final".

Now checks if the target actually has is_final=True before selecting
it. If not, falls back to the highest quality image available.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 16:13:55 +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 5aa29aad02 feat: enhance StreamProcessor with tool stream handling 2026-02-26 14:00:19 +08:00
Chenyme c2989e8579 refactor: update image handling in chat completions and services 2026-02-26 11:38:25 +08:00
Chenyme 02d4f91c4a feat: enhance chat service with fallback prompt for attachments and semaphore management 2026-02-26 11:20:46 +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
Chenyme 186e6bb20b Merge pull request #209 from BytePioneer-AI/fix/issue-206-base64-path
fix: support relative asset paths in base64 download flow
2026-02-21 21:25:41 +08:00
Chenyme d5bd81ece0 Merge pull request #204 from FakerL/fix/sql-ssl-connect-args
fix: handle SSL query params for asyncpg and aiomysql
2026-02-21 21:11:05 +08:00
BytePioneer-AI 68895f0f31 fix: support relative asset paths in base64 download flow 2026-02-21 14:12:42 +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
Zhi YangandClaude Opus 4.6 c818bdfa2d fix: handle SSL query params for asyncpg and aiomysql drivers
Both asyncpg and aiomysql reject SSL-related query parameters (sslmode,
ssl-mode, ssl) when passed through SQLAlchemy URLs. This extracts SSL
mode from the URL, normalizes it per backend, and passes proper
connect_args instead.

- Postgres: passes libpq-style mode string via connect_args={"ssl": mode}
- MySQL: builds an SSLContext matching the requested verification level
- Supports cross-dialect aliases (e.g. verify-full works for both backends)
- Adds mariadb+aiomysql:// prefix handling
- Raises ValueError on unrecognized SSL modes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 22:23:31 +00: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 0e73fab4e4 style: enhance chat UI with new image retry functionality and improved layout; update login redirection to chat page 2026-02-20 00:55:54 +08:00