@@ -10,13 +10,7 @@ import {
10
10
XMarkIcon ,
11
11
} from '@heroicons/react/24/solid' ;
12
12
import clsx from 'clsx' ;
13
- import { useAtomValue } from 'jotai' ;
14
- import {
15
- modelCosts ,
16
- outputProviders ,
17
- ProcessingStep ,
18
- StepInputs ,
19
- } from 'litlytics' ;
13
+ import { modelCosts , OUTPUT_ID , ProcessingStep , StepInputs } from 'litlytics' ;
20
14
import _ from 'lodash' ;
21
15
import { ChangeEvent , useMemo , useState } from 'react' ;
22
16
import { Badge } from '~/components/catalyst/badge' ;
@@ -38,27 +32,19 @@ import { CodeEditor } from '~/components/step/CodeEditor';
38
32
import { StepTest } from '~/components/step/StepTest' ;
39
33
import { stepInputLabels } from '~/components/step/util' ;
40
34
import { CentIcon } from '~/components/ui/CentIcon' ;
41
- import { configAtom , useLitlytics } from '~/store/store ' ;
35
+ import { useLitlytics } from '~/store/WithLitLytics ' ;
42
36
import { NodeContent , NodeFrame , NodeHeader } from './NodeFrame' ;
43
37
44
38
export function StepNode ( { data } : { data : ProcessingStep } ) {
45
39
const litlytics = useLitlytics ( ) ;
46
- const litlyticsConfig = useAtomValue ( configAtom ) ;
47
40
const [ isOpen , setIsOpen ] = useState ( false ) ;
48
41
const [ loading , setLoading ] = useState ( false ) ;
49
42
const [ refine , setRefine ] = useState ( '' ) ;
50
43
51
- const output = useMemo ( ( ) => {
52
- const Output = outputProviders [ litlytics . pipeline . output . outputType ] ;
53
- const output = new Output ( litlytics . pipeline ) ;
54
- return output ;
55
- } , [ litlytics ] ) ;
56
-
57
44
const { averageTiming, averagePrompt, averageCompletion, averageCost } =
58
45
useMemo ( ( ) => {
59
46
// const timings = data.
60
- const cfg = output . getConfig ( ) ;
61
- const results = Array . isArray ( cfg . results ) ? cfg . results : [ cfg . results ] ;
47
+ const results = litlytics . docs ;
62
48
const res = results . filter ( ( doc ) => doc ) ;
63
49
if ( ! res . length ) {
64
50
return { } ;
@@ -87,19 +73,19 @@ export function StepNode({ data }: { data: ProcessingStep }) {
87
73
completionTokens . length
88
74
) ;
89
75
const inputCost =
90
- litlyticsConfig . provider === 'ollama'
76
+ litlytics . config . provider === 'ollama'
91
77
? 0
92
- : modelCosts [ litlyticsConfig . model ! ] . input ;
78
+ : modelCosts [ litlytics . config . model ! ] . input ;
93
79
const outputCost =
94
- litlyticsConfig . provider === 'ollama'
80
+ litlytics . config . provider === 'ollama'
95
81
? 0
96
- : modelCosts [ litlyticsConfig . model ! ] . output ;
82
+ : modelCosts [ litlytics . config . model ! ] . output ;
97
83
const averageCost = _ . round (
98
84
averagePrompt * inputCost + averageCompletion * outputCost ,
99
85
3
100
86
) ;
101
87
return { averageTiming, averagePrompt, averageCompletion, averageCost } ;
102
- } , [ output , data , litlyticsConfig ] ) ;
88
+ } , [ litlytics , data ] ) ;
103
89
104
90
const updateNodeByKey = (
105
91
newVal : string | boolean | undefined ,
@@ -154,7 +140,7 @@ export function StepNode({ data }: { data: ProcessingStep }) {
154
140
. map ( ( s ) => {
155
141
let connectsTo = s . connectsTo . filter ( ( id ) => id !== data . id ) ;
156
142
if ( connectsTo . length === 0 ) {
157
- connectsTo = [ litlytics . pipeline . output . id ] ;
143
+ connectsTo = [ OUTPUT_ID ] ;
158
144
}
159
145
return {
160
146
...s ,
@@ -174,9 +160,6 @@ export function StepNode({ data }: { data: ProcessingStep }) {
174
160
connectsTo : sourceConnect ,
175
161
} ,
176
162
steps : newSteps ,
177
- output : {
178
- ...litlytics . pipeline . output ,
179
- } ,
180
163
} ) ;
181
164
} ;
182
165
0 commit comments