Skip to content

Commit

Permalink
context: add markers
Browse files Browse the repository at this point in the history
  • Loading branch information
nl0 committed Aug 2, 2024
1 parent e7dfdb8 commit ea31868
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion catalog/app/components/Assistant/Model/Context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import * as Tool from './Tool'
export interface ContextShape {
messages: string[]
tools: Tool.Collection
markers: Record<string, boolean>
}

interface ContextAggregator {
Expand Down Expand Up @@ -56,6 +57,7 @@ export function ContextAggregatorProvider({ children }: React.PropsWithChildren<
const ROOT_CONTEXT: ContextShape = {
tools: {},
messages: [],
markers: {},
}

function aggregateContext(contexts: Partial<ContextShape>[]) {
Expand All @@ -66,6 +68,7 @@ function aggregateContext(contexts: Partial<ContextShape>[]) {
// XXX: check for conflicts?
tools: { ...acc.tools, ...next.tools },
messages: acc.messages.concat(next.messages || []),
markers: { ...acc.markers, ...next.markers },
}),
ROOT_CONTEXT,
)
Expand Down Expand Up @@ -97,7 +100,7 @@ export function usePushContext(context: Partial<ContextShape>) {
React.useEffect(() => push(contextMemo), [push, contextMemo])
}

export function Push(context: ContextShape) {
export function Push(context: Partial<ContextShape>) {
usePushContext(context)
return null
}
Expand Down

0 comments on commit ea31868

Please sign in to comment.