mirror of
https://github.com/sune-org/us.proxy.sune.chat.git
synced 2026-03-17 02:21:01 +00:00
Feat: Add web search support for Claude :online models
This commit is contained in:
11
providers.js
11
providers.js
@@ -129,12 +129,15 @@ export async function streamOpenAI({ apiKey, body, signal, onDelta, isRunning })
|
||||
|
||||
export async function streamClaude({ apiKey, body, signal, onDelta, isRunning }) {
|
||||
const client = new Anthropic({ apiKey })
|
||||
const online = (body.model ?? '').endsWith(':online')
|
||||
const model = online ? body.model.slice(0, -7) : body.model
|
||||
|
||||
const system = body.messages
|
||||
.filter(m => m.role === 'system')
|
||||
.map(extractText)
|
||||
.join('\n\n') || body.system
|
||||
const payload = {
|
||||
model: body.model,
|
||||
model,
|
||||
messages: body.messages.filter(m => m.role !== 'system').map(m => ({
|
||||
role: m.role,
|
||||
content: typeof m.content === 'string' ? m.content : (m.content || []).map(p => {
|
||||
@@ -157,6 +160,12 @@ export async function streamClaude({ apiKey, body, signal, onDelta, isRunning })
|
||||
...(body.reasoning.budget && { max_thinking_tokens: body.reasoning.budget }),
|
||||
}
|
||||
}
|
||||
if (online) {
|
||||
payload.tools = [
|
||||
...(payload.tools || []),
|
||||
{ type: 'web_search_20260209', name: 'web_search' },
|
||||
]
|
||||
}
|
||||
|
||||
const stream = client.messages.stream(payload)
|
||||
stream.on('text', text => { if (isRunning()) onDelta(text) })
|
||||
|
||||
Reference in New Issue
Block a user