Skip to content

Commit eb2599b

Browse files
committed
Update provider integration and icon
1 parent 68291aa commit eb2599b

File tree

2 files changed

+42
-51
lines changed

2 files changed

+42
-51
lines changed

apps/sim/components/icons.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5551,17 +5551,10 @@ export function FirefliesIcon(props: SVGProps<SVGSVGElement>) {
55515551
}
55525552

55535553
export const AvianIcon = (props: SVGProps<SVGSVGElement>) => (
5554-
<svg
5555-
{...props}
5556-
fill='currentColor'
5557-
height='1em'
5558-
viewBox='0 0 24 24'
5559-
width='1em'
5560-
xmlns='http://www.w3.org/2000/svg'
5561-
>
5554+
<svg {...props} viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'>
55625555
<title>Avian</title>
55635556
<path
5564-
d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm3.5 7.5L12 13l-3.5-3.5L12 6l3.5 3.5zM8 14.5l4 4 4-4H8z'
5557+
d='M21 3c-1.5 2-3.5 3.5-6 4.5C13.5 5.5 11 4.5 8 5c-2 .3-3.8 1.2-5 2.5 1.5-.3 3-.2 4.5.3-1.5 1-2.5 2.5-3 4.2 1.2-.8 2.5-1.2 4-1.2-1 1.5-1.2 3.2-.8 5 2-2.5 4.5-4 7.5-4.5.2 1.5-.2 3-1 4.2 2-.5 3.5-1.8 4.5-3.5.5 1 .5 2.2.3 3.5 1.5-1.8 2-4 1.5-6.5C22 7 22 5 21 3z'
55655558
fill='#6366F1'
55665559
/>
55675560
</svg>

apps/sim/providers/avian/index.ts

Lines changed: 40 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
calculateCost,
1616
prepareToolExecution,
1717
prepareToolsWithUsageControl,
18+
sumToolCosts,
1819
trackForcedToolUsage,
1920
} from '@/providers/utils'
2021
import { executeTool } from '@/tools'
@@ -123,28 +124,25 @@ export const avianProvider: ProviderConfig = {
123124
)
124125

125126
const streamingResult = {
126-
stream: createReadableStreamFromAvianStream(
127-
streamResponse as any,
128-
(content, usage) => {
129-
streamingResult.execution.output.content = content
130-
streamingResult.execution.output.tokens = {
131-
input: usage.prompt_tokens,
132-
output: usage.completion_tokens,
133-
total: usage.total_tokens,
134-
}
127+
stream: createReadableStreamFromAvianStream(streamResponse as any, (content, usage) => {
128+
streamingResult.execution.output.content = content
129+
streamingResult.execution.output.tokens = {
130+
input: usage.prompt_tokens,
131+
output: usage.completion_tokens,
132+
total: usage.total_tokens,
133+
}
135134

136-
const costResult = calculateCost(
137-
request.model,
138-
usage.prompt_tokens,
139-
usage.completion_tokens
140-
)
141-
streamingResult.execution.output.cost = {
142-
input: costResult.input,
143-
output: costResult.output,
144-
total: costResult.total,
145-
}
135+
const costResult = calculateCost(
136+
request.model,
137+
usage.prompt_tokens,
138+
usage.completion_tokens
139+
)
140+
streamingResult.execution.output.cost = {
141+
input: costResult.input,
142+
output: costResult.output,
143+
total: costResult.total,
146144
}
147-
),
145+
}),
148146
execution: {
149147
success: true,
150148
output: {
@@ -205,7 +203,7 @@ export const avianProvider: ProviderConfig = {
205203
total: currentResponse.usage?.total_tokens || 0,
206204
}
207205
const toolCalls = []
208-
const toolResults = []
206+
const toolResults: Record<string, unknown>[] = []
209207
const currentMessages = [...allMessages]
210208
let iterationCount = 0
211209
let hasUsedForcedTool = false
@@ -325,7 +323,7 @@ export const avianProvider: ProviderConfig = {
325323
})
326324

327325
let resultContent: any
328-
if (result.success) {
326+
if (result.success && result.output) {
329327
toolResults.push(result.output)
330328
resultContent = result.output
331329
} else {
@@ -456,28 +454,27 @@ export const avianProvider: ProviderConfig = {
456454
const accumulatedCost = calculateCost(request.model, tokens.input, tokens.output)
457455

458456
const streamingResult = {
459-
stream: createReadableStreamFromAvianStream(
460-
streamResponse as any,
461-
(content, usage) => {
462-
streamingResult.execution.output.content = content
463-
streamingResult.execution.output.tokens = {
464-
input: tokens.input + usage.prompt_tokens,
465-
output: tokens.output + usage.completion_tokens,
466-
total: tokens.total + usage.total_tokens,
467-
}
457+
stream: createReadableStreamFromAvianStream(streamResponse as any, (content, usage) => {
458+
streamingResult.execution.output.content = content
459+
streamingResult.execution.output.tokens = {
460+
input: tokens.input + usage.prompt_tokens,
461+
output: tokens.output + usage.completion_tokens,
462+
total: tokens.total + usage.total_tokens,
463+
}
468464

469-
const streamCost = calculateCost(
470-
request.model,
471-
usage.prompt_tokens,
472-
usage.completion_tokens
473-
)
474-
streamingResult.execution.output.cost = {
475-
input: accumulatedCost.input + streamCost.input,
476-
output: accumulatedCost.output + streamCost.output,
477-
total: accumulatedCost.total + streamCost.total,
478-
}
465+
const streamCost = calculateCost(
466+
request.model,
467+
usage.prompt_tokens,
468+
usage.completion_tokens
469+
)
470+
const tc = sumToolCosts(toolResults)
471+
streamingResult.execution.output.cost = {
472+
input: accumulatedCost.input + streamCost.input,
473+
output: accumulatedCost.output + streamCost.output,
474+
toolCost: tc || undefined,
475+
total: accumulatedCost.total + streamCost.total + tc,
479476
}
480-
),
477+
}),
481478
execution: {
482479
success: true,
483480
output: {
@@ -508,6 +505,7 @@ export const avianProvider: ProviderConfig = {
508505
cost: {
509506
input: accumulatedCost.input,
510507
output: accumulatedCost.output,
508+
toolCost: undefined as number | undefined,
511509
total: accumulatedCost.total,
512510
},
513511
},

0 commit comments

Comments
 (0)