Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance/add description #77

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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: str
examples: 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
8 changes: 7 additions & 1 deletion resolver/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,17 @@ 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: str = None, description: str = "", examples: str = ""
freedeaths marked this conversation as resolved.
Show resolved Hide resolved
):
"""
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 +219,8 @@ def decorator(cls):
"category": "block",
"dir": kind,
"class": cls,
"description": description,
"examples": examples,
}
)
return cls
Expand Down