mirror of
https://github.com/EthanMarti/infio-copilot.git
synced 2026-05-09 16:38:19 +00:00
update apply diff
This commit is contained in:
31
src/contexts/DiffStrategyContext.tsx
Normal file
31
src/contexts/DiffStrategyContext.tsx
Normal 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
|
||||
}
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user