update apply diff

This commit is contained in:
duanfuxiang
2025-03-23 09:34:44 +08:00
parent 570e8d9564
commit 635db9babd
34 changed files with 3161 additions and 410 deletions

View File

@@ -0,0 +1,31 @@
import {
PropsWithChildren,
createContext,
useContext,
useMemo
} from 'react'
import { DiffStrategy } from '../core/diff/DiffStrategy'
const DiffStrategyContext = createContext<DiffStrategy>(null)
export function DiffStrategyProvider({
diffStrategy,
children,
}: PropsWithChildren<{ diffStrategy: DiffStrategy }>) {
const value = useMemo(() => {
return diffStrategy
}, [diffStrategy])
return <DiffStrategyContext.Provider value={value}>{children}</DiffStrategyContext.Provider>
}
export function useDiffStrategy() {
const context = useContext(DiffStrategyContext)
if (!context) {
throw new Error('DiffStrategyContext is not initialized')
}
return context
}

View File

@@ -34,7 +34,7 @@ export type LLMContextType = {
options?: LLMOptions,
) => Promise<AsyncIterable<LLMResponseStreaming>>
chatModel: LLMModel
applyModel: LLMModel
// applyModel: LLMModel
}
const LLMContext = createContext<LLMContextType | null>(null)
@@ -50,12 +50,12 @@ export function LLMProvider({ children }: PropsWithChildren) {
}
}, [settings])
const applyModel = useMemo((): LLMModel => {
return {
provider: settings.applyModelProvider,
modelId: settings.applyModelId,
}
}, [settings])
// const applyModel = useMemo((): LLMModel => {
// return {
// provider: settings.applyModelProvider,
// modelId: settings.applyModelId,
// }
// }, [settings])
useEffect(() => {
const manager = new LLMManager(settings)
@@ -92,7 +92,7 @@ export function LLMProvider({ children }: PropsWithChildren) {
return (
<LLMContext.Provider
value={{ generateResponse, streamResponse, chatModel, applyModel }}
value={{ generateResponse, streamResponse, chatModel }}
>
{children}
</LLMContext.Provider>