Skip to content

Commit cd4cf19

Browse files
authored
Merge pull request #1762 from roboflow/feat/openai-block-v4
OpenAI workflow block v4
2 parents b3aeb4d + ea56c11 commit cd4cf19

File tree

5 files changed

+1689
-6
lines changed

5 files changed

+1689
-6
lines changed

inference/core/workflows/core_steps/formatters/vlm_as_detector/v2.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,11 @@ class BlockManifest(WorkflowBlockManifest):
125125
}
126126
},
127127
)
128-
model_type: Literal["google-gemini", "anthropic-claude", "florence-2"] = Field(
129-
description="Type of the model that generated prediction",
130-
examples=[["google-gemini", "anthropic-claude", "florence-2"]],
128+
model_type: Literal["openai", "google-gemini", "anthropic-claude", "florence-2"] = (
129+
Field(
130+
description="Type of the model that generated prediction",
131+
examples=[["google-gemini", "anthropic-claude", "florence-2"]],
132+
)
131133
)
132134
task_type: Literal[tuple(SUPPORTED_TASKS)] = Field(
133135
description="Task type to performed by model.",
@@ -234,7 +236,7 @@ def try_parse_json(content: str) -> Tuple[bool, dict]:
234236
return True, {}
235237

236238

237-
def parse_gemini_object_detection_response(
239+
def parse_llm_object_detection_response(
238240
image: WorkflowImageData,
239241
parsed_data: dict,
240242
classes: List[str],
@@ -353,8 +355,11 @@ def get_4digit_from_md5(input_string):
353355

354356

355357
REGISTERED_PARSERS = {
356-
("google-gemini", "object-detection"): parse_gemini_object_detection_response,
357-
("anthropic-claude", "object-detection"): parse_gemini_object_detection_response,
358+
# LLMs
359+
("openai", "object-detection"): parse_llm_object_detection_response,
360+
("google-gemini", "object-detection"): parse_llm_object_detection_response,
361+
("anthropic-claude", "object-detection"): parse_llm_object_detection_response,
362+
# Florence 2
358363
("florence-2", "object-detection"): partial(
359364
parse_florence2_object_detection_response, florence_task_type="<OD>"
360365
),

inference/core/workflows/core_steps/loader.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@
221221
from inference.core.workflows.core_steps.models.foundation.openai.v3 import (
222222
OpenAIBlockV3,
223223
)
224+
from inference.core.workflows.core_steps.models.foundation.openai.v4 import (
225+
OpenAIBlockV4,
226+
)
224227
from inference.core.workflows.core_steps.models.foundation.perception_encoder.v1 import (
225228
PerceptionEncoderModelBlockV1,
226229
)
@@ -642,6 +645,7 @@ def load_blocks() -> List[Type[WorkflowBlock]]:
642645
OpenAIBlockV1,
643646
OpenAIBlockV2,
644647
OpenAIBlockV3,
648+
OpenAIBlockV4,
645649
PathDeviationAnalyticsBlockV1,
646650
PathDeviationAnalyticsBlockV2,
647651
PixelateVisualizationBlockV1,

0 commit comments

Comments
 (0)