chore: remove nested ternaries
This commit is contained in:
@@ -5,7 +5,8 @@
|
|||||||
"correctness": "warn"
|
"correctness": "warn"
|
||||||
},
|
},
|
||||||
"rules": {
|
"rules": {
|
||||||
"eslint/no-unused-vars": "error"
|
"eslint/no-unused-vars": "error",
|
||||||
|
"unicorn/no-nested-ternary": "error"
|
||||||
},
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"typeAware": true,
|
"typeAware": true,
|
||||||
|
|||||||
@@ -364,13 +364,13 @@ export class AgentLoop {
|
|||||||
if (response.content) await onProgress(response.content);
|
if (response.content) await onProgress(response.content);
|
||||||
const hint = response.toolCalls
|
const hint = response.toolCalls
|
||||||
.map((tc) => {
|
.map((tc) => {
|
||||||
|
let display = ''
|
||||||
|
|
||||||
const firstVal = Object.values(tc.arguments)[0];
|
const firstVal = Object.values(tc.arguments)[0];
|
||||||
const display =
|
if (typeof firstVal === 'string') {
|
||||||
typeof firstVal === 'string'
|
display = `"${firstVal.slice(0, 40) + (firstVal.length > 40 ? '…' : '')}"`
|
||||||
? firstVal.length > 40
|
}
|
||||||
? `"${firstVal.slice(0, 40)}…"`
|
|
||||||
: `"${firstVal}"`
|
|
||||||
: '';
|
|
||||||
return `${tc.name}(${display})`;
|
return `${tc.name}(${display})`;
|
||||||
})
|
})
|
||||||
.join(', ');
|
.join(', ');
|
||||||
|
|||||||
@@ -146,17 +146,14 @@ export class LLMProvider {
|
|||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
let toolChoice: 'required' | 'none' | 'auto' = 'auto'
|
||||||
|
if (opts.toolChoice === 'required' || opts.toolChoice === 'none') toolChoice = opts.toolChoice
|
||||||
const result = await generateText({
|
const result = await generateText({
|
||||||
model,
|
model,
|
||||||
messages: opts.messages as ModelMessage[],
|
messages: opts.messages as ModelMessage[],
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: AI SDK tools type is complex
|
// biome-ignore lint/suspicious/noExplicitAny: AI SDK tools type is complex
|
||||||
tools: aiTools as any,
|
tools: aiTools as any,
|
||||||
toolChoice:
|
toolChoice,
|
||||||
opts.toolChoice === 'required'
|
|
||||||
? 'required'
|
|
||||||
: opts.toolChoice === 'none'
|
|
||||||
? 'none'
|
|
||||||
: 'auto',
|
|
||||||
maxOutputTokens: maxTokens,
|
maxOutputTokens: maxTokens,
|
||||||
temperature,
|
temperature,
|
||||||
stopWhen: stepCountIs(1),
|
stopWhen: stepCountIs(1),
|
||||||
|
|||||||
Reference in New Issue
Block a user