feat(llm): add model-specific reasoning effort controls
This commit is contained in:
@@ -1,8 +1,28 @@
|
||||
import type { Context } from 'cordis'
|
||||
import { CallId, LlmAdapter, type GenerateOptions, type StreamChunk } from '@deepseek-ai/dsh-llm'
|
||||
import {
|
||||
CallId,
|
||||
LlmAdapter,
|
||||
ReasoningEffortId,
|
||||
type GenerateOptions,
|
||||
type LlmModelReasoningInfo,
|
||||
type StreamChunk,
|
||||
} from '@deepseek-ai/dsh-llm'
|
||||
|
||||
const HIGH = ReasoningEffortId('high')
|
||||
const MAX = ReasoningEffortId('max')
|
||||
|
||||
/** Keyless headless-agent adapter: one real bash call followed by a final answer. */
|
||||
class CliMockAdapter extends LlmAdapter {
|
||||
override async resolveModelReasoning(): Promise<LlmModelReasoningInfo> {
|
||||
return {
|
||||
efforts: [
|
||||
{ id: HIGH, name: 'High' },
|
||||
{ id: MAX, name: 'Max' },
|
||||
],
|
||||
defaultEffort: HIGH,
|
||||
}
|
||||
}
|
||||
|
||||
async * stream(options: GenerateOptions): AsyncIterable<StreamChunk> {
|
||||
const toolResult = options.messages.at(-1)?.content.find(block => block.type === 'tool-result')
|
||||
if (toolResult === undefined) {
|
||||
@@ -34,4 +54,8 @@ export const inject = ['llm']
|
||||
/** Register the keyless `cli-mock` adapter. */
|
||||
export function apply(ctx: Context): void {
|
||||
ctx.llm.registerAdapter(['cli-mock'], new CliMockAdapter())
|
||||
ctx.on('agent/request', async (_agent, _turn, step, _config, _signal, next) => {
|
||||
const config = await next()
|
||||
return step === 2 ? { ...config, reasoningEffort: MAX } : config
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user