feat: Allow FIM chat requests without messages - #1959
Conversation
WalkthroughUpdates enable Fill-in-the-Middle requests without explicit messages: validation now permits missing messages when Prefix/Suffix exist, and the SiliconFlow adaptor injects an empty user message if needed to meet provider requirements. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Client
participant Relay
participant Validator as GetAndValidateTextRequest
participant Adaptor as SiliconFlow Adaptor
participant Provider as SiliconFlow API
Client->>Relay: ChatCompletions request (Prefix/Suffix, no Messages)
Relay->>Validator: Validate request
alt Prefix/Suffix present
Validator-->>Relay: OK (messages optional)
else No Prefix/Suffix
Validator-->>Relay: Error (messages required)
end
Relay->>Adaptor: ConvertOpenAIRequest
alt Messages empty AND Prefix/Suffix present
Adaptor->>Adaptor: Inject empty user message
end
Adaptor-->>Relay: Modified request
Relay->>Provider: Send request
Provider-->>Relay: Response
Relay-->>Client: Response
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🧰 Additional context used🧬 Code graph analysis (1)relay/channel/siliconflow/adaptor.go (1)
🔇 Additional comments (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
feat: Allow FIM chat requests without messages
PR 类型
PR 是否包含破坏性更新?
PR 描述
close #1649
为兼容prefix/subfix形式的 FIM 调用,当客户端未提供 messages 时,不再在入参校验阶段直接拒绝请求,同时在 SiliconFlow 适配器内补充一个空的 user 消息以满足上游服务的必填要求,从而避免这类请求被误判为无效。
Summary by CodeRabbit
New Features
Bug Fixes