add function to determine artifact type
This commit is contained in:
parent
1743191379
commit
d7e1270436
1 changed files with 8 additions and 2 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
from typing import Any, Union
|
from typing import Any, Union, Generator
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
from langchain_core.documents import Document
|
from langchain_core.documents import Document
|
||||||
|
|
@ -20,6 +20,7 @@ class ArtifactType(str, Enum):
|
||||||
TEXT = "text"
|
TEXT = "text"
|
||||||
RECORD = "record"
|
RECORD = "record"
|
||||||
OBJECT = "object"
|
OBJECT = "object"
|
||||||
|
STREAM = "stream"
|
||||||
UNKNOWN = "unknown"
|
UNKNOWN = "unknown"
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -61,8 +62,9 @@ def serialize_field(value):
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
def get_artifact_type(value: Any) -> str:
|
def get_artifact_type(custom_component, build_result) -> str:
|
||||||
result = ArtifactType.UNKNOWN
|
result = ArtifactType.UNKNOWN
|
||||||
|
value = custom_component.repr_value
|
||||||
match value:
|
match value:
|
||||||
case Record():
|
case Record():
|
||||||
result = ArtifactType.RECORD
|
result = ArtifactType.RECORD
|
||||||
|
|
@ -73,4 +75,8 @@ def get_artifact_type(value: Any) -> str:
|
||||||
case dict():
|
case dict():
|
||||||
result = ArtifactType.OBJECT
|
result = ArtifactType.OBJECT
|
||||||
|
|
||||||
|
if result == ArtifactType.UNKNOWN:
|
||||||
|
if isinstance(build_result, Generator):
|
||||||
|
result = ArtifactType.STREAM
|
||||||
|
|
||||||
return result.value
|
return result.value
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue