Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ describe("OperatorAnnotationAgent", () => {

it("should send the correct request body", async () => {
mockFetch.mockResolvedValue({ result: { result: {} } });
const ctx = makeContext({ textPrompt: "cat" });
const ctx = makeContext();

await agent.infer(ctx);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ const useAgentContext = (): AnnotationContext | null => {
selectedLabel && "bounding_box" in selectedLabel.data
? {
taskType: AgentTaskType.SEGMENT,
textPrompt: selectedLabel.data.label,
regionsOfInterest: [
bboxToRoi(
(selectedLabel as DetectionAnnotationLabel).data.bounding_box
Expand Down
22 changes: 2 additions & 20 deletions app/packages/annotation/src/agents/hooks/useToolsContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ export type ToolsContext = {
negativePoints?: Vec2[];
/** The current selection of region-of-interest prompts. */
regionsOfInterest?: ROI[];
/** The current text prompt. */
textPrompt?: string;
};

/**
Expand All @@ -40,16 +38,13 @@ export interface ToolsState extends ToolsContext {
removeNegativePoint(index: number): void;
/** Replaces the full set of ROI prompts. */
setRegionsOfInterest(rois: ROI[]): void;
/** Sets the free-text prompt. */
setTextPrompt(prompt: string): void;
/** Clears all tool inputs back to their initial state. */
reset(): void;
}

const positivePointsAtom = atom<Vec2[]>([]);
const negativePointsAtom = atom<Vec2[]>([]);
const regionsOfInterestAtom = atom<ROI[]>([]);
const textPromptAtom = atom<string | null>(null);

/**
* Hook which returns the current {@link ToolsContext} (read-only).
Expand All @@ -61,17 +56,15 @@ export const useToolsContext = (): ToolsContext => {
const positivePoints = useAtomValue(positivePointsAtom);
const negativePoints = useAtomValue(negativePointsAtom);
const regionsOfInterest = useAtomValue(regionsOfInterestAtom);
const textPrompt = useAtomValue(textPromptAtom);

return useMemo(
() => ({
taskType: activeTask,
positivePoints,
negativePoints,
regionsOfInterest,
textPrompt,
}),
[activeTask, positivePoints, negativePoints, regionsOfInterest, textPrompt]
[activeTask, positivePoints, negativePoints, regionsOfInterest]
);
};

Expand All @@ -87,7 +80,6 @@ export const useToolsState = (): ToolsState => {
const [regionsOfInterest, setRegionsOfInterest] = useAtom(
regionsOfInterestAtom
);
const [textPrompt, setTextPrompt] = useAtom(textPromptAtom);

const addPositivePoint = useCallback(
(point: Vec2) => setPositivePoints((prev) => [...prev, point]),
Expand Down Expand Up @@ -115,41 +107,31 @@ export const useToolsState = (): ToolsState => {
setPositivePoints([]);
setNegativePoints([]);
setRegionsOfInterest([]);
setTextPrompt(null);
}, [
setPositivePoints,
setNegativePoints,
setRegionsOfInterest,
setTextPrompt,
]);
}, [setPositivePoints, setNegativePoints, setRegionsOfInterest]);

return useMemo(
() => ({
taskType: activeTask,
positivePoints,
negativePoints,
regionsOfInterest,
textPrompt,
addPositivePoint,
removePositivePoint,
addNegativePoint,
removeNegativePoint,
setRegionsOfInterest,
setTextPrompt,
reset,
}),
[
activeTask,
positivePoints,
negativePoints,
regionsOfInterest,
textPrompt,
addPositivePoint,
removePositivePoint,
addNegativePoint,
removeNegativePoint,
setRegionsOfInterest,
setTextPrompt,
reset,
]
);
Expand Down
4 changes: 0 additions & 4 deletions app/packages/annotation/src/agents/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,11 @@ export enum AgentTaskType {
* - `"positivePoint"` - a set of positive point prompts indicating regions to include
* - `"negativePoint"` - a set of negative point prompts indicating regions to exclude
* - `"roi"` - a set of polygonal regions of interest to bound the labels
* - `"textPrompt"` - a free-text description of the target object
*/
export enum InferenceCapability {
POSITIVE_POINT = "positivePoint",
NEGATIVE_POINT = "negativePoint",
ROI = "roi",
TEXT_PROMPT = "textPrompt",
}

/**
Expand Down Expand Up @@ -75,8 +73,6 @@ export type AnnotationContext = {
negativePoints?: Vec2[];
/** Polygonal regions of interest drawn by the user. */
regionsOfInterest?: ROI[];
/** Free-text description of the target object. */
textPrompt?: string;
};

/**
Expand Down
Loading