Skip to content
Open
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
2 changes: 2 additions & 0 deletions api/api_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ class BlockInfo(BaseModel):
slots: List[Parameter]
inports: List[Parameter]
outport: str # the output class name
description: Optional[str]
examples: Optional[str]


class ApplicationBlocksResponse(APIModel):
Expand Down
2 changes: 2 additions & 0 deletions api/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ def blocks(self) -> ApplicationBlocksResponse:
slots=self.resolve_params(self.resolver.slots(name)),
inports=self.resolve_params(self.resolver.inports(name)),
outport=self.resolver.relookup(self.resolver.outport(name)),
description=self.resolver.lookup(name, "description"),
examples=self.resolver.lookup(name, "examples"),
)
)

Expand Down
8 changes: 7 additions & 1 deletion blocks/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@
from .base import BaseBlock


@block(name="LLM", kind="llm")
@block(
name="LLM",
kind="llm",
description="""test
test new line""",
examples="""this is a text""",
)
class LLMChain(BaseBlock):
"""
LLMChain render template with given text and pass the result to llm model.
Expand Down
12 changes: 11 additions & 1 deletion resolver/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,21 @@ def outport(self, name: str) -> Optional[type]:
return signature.return_annotation


def block(name: str, kind: str, alias: str = None):
def block(
name: str,
kind: str,
alias: Optional[str] = None,
description: Optional[str] = None,
examples: Optional[str] = None,
):
"""
Decorator for registering a block class.
Args:
name: The name of the block.
kind: The kind of the block (e.g., 'input', 'output').
alias: An optional alias for the block name.
description: The description of the block.
examples: Examples about the usage of the block.
Returns:
The decorated class.
"""
Expand All @@ -215,6 +223,8 @@ def decorator(cls):
"category": "block",
"dir": kind,
"class": cls,
"description": description,
"examples": examples,
}
)
return cls
Expand Down