diff --git a/api/api_schemas.py b/api/api_schemas.py index c123ae2..b91c5a3 100644 --- a/api/api_schemas.py +++ b/api/api_schemas.py @@ -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): diff --git a/api/application.py b/api/application.py index 5f65c2e..0cd7bfd 100644 --- a/api/application.py +++ b/api/application.py @@ -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"), ) ) diff --git a/blocks/llm.py b/blocks/llm.py index 49b16a4..d27f5c0 100644 --- a/blocks/llm.py +++ b/blocks/llm.py @@ -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. diff --git a/resolver/resolver.py b/resolver/resolver.py index 935042e..93e26a3 100644 --- a/resolver/resolver.py +++ b/resolver/resolver.py @@ -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. """ @@ -215,6 +223,8 @@ def decorator(cls): "category": "block", "dir": kind, "class": cls, + "description": description, + "examples": examples, } ) return cls diff --git a/ui/openapi.json b/ui/openapi.json index 07cfc07..c5fd074 100644 --- a/ui/openapi.json +++ b/ui/openapi.json @@ -1 +1 @@ -{"openapi":"3.1.0","info":{"title":"FastAPI","version":"0.1.0"},"paths":{"/patterns":{"get":{"summary":"Patterns","description":"Retrieves application patterns based on resolver information.\n\nReturns:\n ApplicationPatternsResponse: A response containing a list of PatternInfo objects.","operationId":"patterns_patterns_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApplicationPatternsResponse"}}}}}}},"/blocks":{"get":{"summary":"Blocks","description":"Retrieves application blocks based on resolver information.\n\nReturns:\n ApplicationBlocksResponse: A response containing a list of BlockInfo objects.","operationId":"blocks_blocks_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApplicationBlocksResponse"}}}}}}},"/applications/{application_id}":{"get":{"summary":"Get App","description":"Get information about a specific application.\n\nArgs:\n application_id (str): The ID of the application to retrieve.\n\nReturns:\n ApplicationInfoResponse: Information about the application, including its ID, name,\n active version, creation timestamp, and last update timestamp.","operationId":"get_app_applications__application_id__get","parameters":[{"required":true,"schema":{"type":"string","title":"Application Id"},"name":"application_id","in":"path"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApplicationInfoResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"put":{"summary":"Update App Meta","description":"Update the metadata of an application.\n\nArgs:\n application_id (str): The ID of the application to update.\n metadata (Metadata): The new metadata for the application.\n\nReturns:\n ItemUpdateResponse: An object indicating the success or failure of the update operation.","operationId":"update_app_meta_applications__application_id__put","parameters":[{"required":true,"schema":{"type":"string","title":"Application Id"},"name":"application_id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppMetadata"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ItemUpdateResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"delete":{"summary":"Delete App","description":"Delete an application by its ID.\n\nArgs:\n application_id (str): The ID of the application to be deleted.\n\nReturns:\n ItemDeleteResponse: A response indicating the success or failure of the deletion.","operationId":"delete_app_applications__application_id__delete","parameters":[{"required":true,"schema":{"type":"string","title":"Application Id"},"name":"application_id","in":"path"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ItemDeleteResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/applications":{"get":{"summary":"List App","description":"Retrieve a list of applications.\n\nReturns:\n ApplicationListResponse: The response containing a list of applications.","operationId":"list_app_applications_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApplicationListResponse"}}}}}},"post":{"summary":"Create App","description":"Endpoint to create a new application.\n\nArgs:\n application (ApplicationCreate): The application data to create.\n\nReturns:\n ApplicationCreateResponse: The response containing the ID of the created application.","operationId":"create_app_applications_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApplicationCreate"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApplicationCreateResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/applications/{application_id}/async_run":{"post":{"summary":"Async Run App","description":"Asynchronously runs an application with the specified ID and configuration.\n\nArgs:\n application_id (str): The ID of the application to run.\n config (ApplicationRun): The configuration for running the application.\n\nReturns:\n ApplicationRunResponse: The response containing the interaction ID which is\n used for polling running result latter.","operationId":"async_run_app_applications__application_id__async_run_post","parameters":[{"required":true,"schema":{"type":"string","title":"Application Id"},"name":"application_id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApplicationRun"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApplicationRunResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/interactions/{interaction_id}":{"get":{"summary":"Get Interaction","description":"Retrieves information about a specific interaction by its ID.\n\nArgs:\n interaction_id (str): The ID of the interaction to retrieve.\n\nReturns:\n InteractionInfoResponse: An object containing information about the interaction.","operationId":"get_interaction_interactions__interaction_id__get","parameters":[{"required":true,"schema":{"type":"string","title":"Interaction Id"},"name":"interaction_id","in":"path"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InteractionInfoResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/applications/{application_id}/versions/{version_id}/async_run":{"post":{"summary":"Async Run App Version","description":"Asynchronously runs an application with the specified app ID, version ID and configuration.\n\nArgs:\n application_id (str): The ID of the application to run.\n version_id (str): The version of the application to run.\n config (ApplicationRun): The configuration for running the application.\n\nReturns:\n ApplicationRunResponse: The response containing the interaction ID which is\n used for polling running result latter.","operationId":"async_run_app_version_applications__application_id__versions__version_id__async_run_post","parameters":[{"required":true,"schema":{"type":"string","title":"Application Id"},"name":"application_id","in":"path"},{"required":true,"schema":{"type":"string","title":"Version Id"},"name":"version_id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApplicationRun"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApplicationRunResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/applications/{application_id}/versions/{version_id}":{"get":{"summary":"Get App Version","operationId":"get_app_version_applications__application_id__versions__version_id__get","parameters":[{"required":true,"schema":{"type":"string","title":"Application Id"},"name":"application_id","in":"path"},{"required":true,"schema":{"type":"string","title":"Version Id"},"name":"version_id","in":"path"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VersionInfoResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"put":{"summary":"Update App Version Meta","description":"Update the metadata of an application.\n\nArgs:\n application_id (str): The ID of the application.\n version_id (str): The ID of the version to be updated.\n metadata (VersionMetadata): The new metadata for the version.\n\nReturns:\n ItemUpdateResponse: An object indicating the success or failure of the update operation.","operationId":"update_app_version_meta_applications__application_id__versions__version_id__put","parameters":[{"required":true,"schema":{"type":"string","title":"Application Id"},"name":"application_id","in":"path"},{"required":true,"schema":{"type":"string","title":"Version Id"},"name":"version_id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/VersionMetadata"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ItemUpdateResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"delete":{"summary":"Delete App Version","description":"Delete a specific version of an application.\n\nArgs:\n application_id (str): The ID of the application.\n version_id (str): The ID of the version to be deleted.\n\nReturns:\n ItemDeleteResponse: An object indicating whether the deletion was successful.","operationId":"delete_app_version_applications__application_id__versions__version_id__delete","parameters":[{"required":true,"schema":{"type":"string","title":"Application Id"},"name":"application_id","in":"path"},{"required":true,"schema":{"type":"string","title":"Version Id"},"name":"version_id","in":"path"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ItemDeleteResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/applications/{application_id}/versions":{"get":{"summary":"List App Versions","description":"Get a list of application versions for the specified application_id.\n\nArgs:\n application_id (str): The ID of the application.\n\nReturns:\n VersionListResponse: A response containing a list of ApplicationVersionInfo objects\n representing the versions of the specified application.","operationId":"list_app_versions_applications__application_id__versions_get","parameters":[{"required":true,"schema":{"type":"string","title":"Application Id"},"name":"application_id","in":"path"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VersionListResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"post":{"summary":"Create App Version","description":"Create a new application version.\n\nArgs:\n application_id (str): The ID of the application.\n version (ApplicationVersionCreate): The details of the new application version.\n\nReturns:\n VersionCreateResponse: The response containing the ID of the created version.","operationId":"create_app_version_applications__application_id__versions_post","parameters":[{"required":true,"schema":{"type":"string","title":"Application Id"},"name":"application_id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApplicationVersionCreate"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VersionCreateResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/applications/{application_id}/versions/{version_id}/active":{"put":{"summary":"Active App Version","description":"Update the active version of an application in the database.\n\nArgs:\n application_id (str): The ID of the application to update.\n version_id (str): The ID of the version to set as active.\n\nReturns:\n ItemUpdateResponse: An ItemUpdateResponse indicating the success or failure of the update.","operationId":"active_app_version_applications__application_id__versions__version_id__active_put","parameters":[{"required":true,"schema":{"type":"string","title":"Application Id"},"name":"application_id","in":"path"},{"required":true,"schema":{"type":"string","title":"Version Id"},"name":"version_id","in":"path"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/ping":{"get":{"summary":"Ping","operationId":"ping_ping_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","title":"Response Ping Ping Get"}}}}}}},"/me":{"get":{"summary":"Me","operationId":"me_me_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/User"}}}}}}}},"components":{"schemas":{"AppMetadata":{"properties":{"name":{"type":"string","title":"Name"},"langfusePublicKey":{"type":"string","title":"Langfusepublickey"},"langfuseSecretKey":{"type":"string","title":"Langfusesecretkey"}},"type":"object","required":["name"],"title":"AppMetadata","description":"The request model for updating app data."},"ApplicationBlocksResponse":{"properties":{"blocks":{"items":{"$ref":"#/components/schemas/BlockInfo"},"type":"array","title":"Blocks"}},"type":"object","required":["blocks"],"title":"ApplicationBlocksResponse","description":"The response model for /blocks."},"ApplicationCreate":{"properties":{"name":{"type":"string","title":"Name"},"langfusePublicKey":{"type":"string","title":"Langfusepublickey"},"langfuseSecretKey":{"type":"string","title":"Langfusesecretkey"}},"type":"object","required":["name"],"title":"ApplicationCreate","description":"The request model for creating app."},"ApplicationCreateResponse":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"}},"type":"object","required":["id"],"title":"ApplicationCreateResponse","description":"The response model for creating app."},"ApplicationInfo":{"properties":{"id":{"type":"string","title":"Id"},"name":{"type":"string","title":"Name"},"user":{"type":"string","title":"User"},"langfuse_public_key":{"type":"string","title":"Langfuse Public Key"},"langfuse_secret_key":{"type":"string","title":"Langfuse Secret Key"},"active_version":{"type":"string","title":"Active Version"},"created_at":{"type":"integer","title":"Created At"},"updated_at":{"type":"integer","title":"Updated At"}},"type":"object","required":["id","name","user","created_at","updated_at"],"title":"ApplicationInfo","description":"ApplicationInfo models the app object."},"ApplicationInfoResponse":{"properties":{"application":{"$ref":"#/components/schemas/ApplicationInfo"}},"type":"object","title":"ApplicationInfoResponse","description":"The response model for /applications/{application_id}, which returns information\nof specific app. If the specifed app not found, the application property will be\nNone."},"ApplicationListResponse":{"properties":{"applications":{"items":{"$ref":"#/components/schemas/ApplicationInfo"},"type":"array","title":"Applications"}},"type":"object","required":["applications"],"title":"ApplicationListResponse","description":"The response model for /applications, which returns a list of app info."},"ApplicationPatternsResponse":{"properties":{"patterns":{"items":{"$ref":"#/components/schemas/PatternInfo"},"type":"array","title":"Patterns"}},"type":"object","required":["patterns"],"title":"ApplicationPatternsResponse","description":"The response model for /patterns."},"ApplicationRun":{"properties":{"input":{"anyOf":[{"type":"string"},{"items":{"type":"string"},"type":"array"},{"additionalProperties":{"type":"string"},"type":"object"}],"title":"Input"}},"type":"object","required":["input"],"title":"ApplicationRun","description":"The request model for trigger an app."},"ApplicationRunResponse":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"}},"type":"object","required":["id"],"title":"ApplicationRunResponse","description":"The response model for trigger an app."},"ApplicationVersionCreate":{"properties":{"name":{"type":"string","title":"Name"},"parentId":{"type":"string","title":"Parentid"},"metadata":{"type":"object","title":"Metadata"},"configuration":{"$ref":"#/components/schemas/GraphConfiguration"}},"type":"object","required":["name","configuration"],"title":"ApplicationVersionCreate","description":"The request model for app version creation api."},"ApplicationVersionInfo":{"properties":{"id":{"type":"string","title":"Id"},"name":{"type":"string","title":"Name"},"user":{"type":"string","title":"User"},"app_id":{"type":"string","title":"App Id"},"created_at":{"type":"integer","title":"Created At"},"updated_at":{"type":"integer","title":"Updated At"},"metadata":{"type":"object","title":"Metadata"},"configuration":{"type":"object","title":"Configuration"}},"type":"object","required":["id","name","user","app_id","created_at","updated_at"],"title":"ApplicationVersionInfo","description":"ApplicationVersionInfo models the app version object.\nAn app can have multiple versions (but at most one active)."},"BlockInfo":{"properties":{"name":{"type":"string","title":"Name"},"alias":{"type":"string","title":"Alias"},"dir":{"type":"string","title":"Dir"},"slots":{"items":{"$ref":"#/components/schemas/Parameter"},"type":"array","title":"Slots"},"inports":{"items":{"$ref":"#/components/schemas/Parameter"},"type":"array","title":"Inports"},"outport":{"type":"string","title":"Outport"}},"type":"object","required":["name","alias","dir","slots","inports","outport"],"title":"BlockInfo","description":"A `Block` is a node in LinguFlow DAG.\n\nBlockInfo class describes:\n- what the node take (inports property)\n- what the node produce (outport property)\n- how to construct the node (slots property)"},"GraphConfiguration":{"properties":{"nodes":{"items":{"$ref":"#/components/schemas/GraphNode"},"type":"array","title":"Nodes"},"edges":{"items":{"$ref":"#/components/schemas/GraphEdge"},"type":"array","title":"Edges"}},"type":"object","required":["nodes","edges"],"title":"GraphConfiguration","description":"GraphConfiguration defines the DAG in app version.\nIt contains a node list which defines how to construct each node.\nAnd a edige list which defines how data flows."},"GraphEdge":{"properties":{"src_block":{"type":"string","title":"Src Block"},"dst_block":{"type":"string","title":"Dst Block"},"dst_port":{"type":"string","title":"Dst Port"},"alias":{"type":"string","title":"Alias"},"case":{"anyOf":[{"type":"boolean"},{"type":"string"},{"type":"integer"}],"title":"Case"}},"type":"object","title":"GraphEdge","description":"GraphEdge defines the dataflow direction between nodes in the DAG."},"GraphNode":{"properties":{"id":{"type":"string","title":"Id"},"name":{"type":"string","title":"Name"},"alias":{"type":"string","title":"Alias"},"slots":{"type":"object","title":"Slots"}},"type":"object","required":["id","name"],"title":"GraphNode","description":"GraphNode describes nodes in DAG.\nIt defines the id and fills construction parameters for blocks."},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"InteractionInfo":{"properties":{"id":{"type":"string","title":"Id"},"user":{"type":"string","title":"User"},"version_id":{"type":"string","title":"Version Id"},"created_at":{"type":"integer","title":"Created At"},"updated_at":{"type":"integer","title":"Updated At"},"output":{"type":"string","title":"Output"},"data":{"type":"object","title":"Data"}},"type":"object","required":["id","user","version_id","created_at","updated_at"],"title":"InteractionInfo","description":"InteractionInfo models the interaction object."},"InteractionInfoResponse":{"properties":{"interaction":{"$ref":"#/components/schemas/InteractionInfo"}},"type":"object","title":"InteractionInfoResponse","description":"The response model for /interactions/{interaction_id}."},"ItemDeleteResponse":{"properties":{"success":{"type":"boolean","title":"Success"},"message":{"type":"string","title":"Message"}},"type":"object","required":["success","message"],"title":"ItemDeleteResponse","description":"The response model for app/version deletion."},"ItemUpdateResponse":{"properties":{"success":{"type":"boolean","title":"Success"},"message":{"type":"string","title":"Message"}},"type":"object","required":["success","message"],"title":"ItemUpdateResponse","description":"The response model for app/version update."},"Parameter":{"properties":{"name":{"type":"string","title":"Name"},"class_name":{"type":"string","title":"Class Name"},"default":{"title":"Default"},"is_variable_keyword":{"type":"boolean","title":"Is Variable Keyword","default":false}},"type":"object","required":["name","class_name"],"title":"Parameter","description":"Parameter describles the parameter of Block.__init__ and Pattern.__init__ .\n\nFor example, for Secret pattern it has a __init__ function:\n\n```\ndef __init__(self, plaintext: str):\n ...\n```\n\nSo the Parameter `plaintext` will be:\n\n```json\n{\n \"name\": \"plaintext\"\n \"class_name\": \"text\",\n \"default\": null,\n \"is_variable_keyword\": false\n}\n```"},"PatternInfo":{"properties":{"name":{"type":"string","title":"Name"},"alias":{"type":"string","title":"Alias"},"candidates":{"items":{"type":"string"},"type":"array","title":"Candidates"},"slots":{"items":{"$ref":"#/components/schemas/Parameter"},"type":"array","title":"Slots"}},"type":"object","required":["name","alias","candidates"],"title":"PatternInfo","description":"PatternInfo describe how to construct a Pattern itself.\n\nFor example, for Secret pattern it has a __init__ function:\n\n```\ndef __init__(self, plaintext: str):\n ...\n```\n\nSo its' PatternInfo will be:\n\n```json\n{\n \"name\": \"Secret\",\n \"alias\": null,\n \"candidates\": [\"Secret\"],\n \"slots\": [{\n \"name\": \"plaintext\"\n \"class_name\": \"text\",\n \"default\": null,\n \"is_variable_keyword\": false\n }]\n}\n```"},"User":{"properties":{"user":{"type":"string","title":"User"}},"type":"object","required":["user"],"title":"User","description":"The user identity"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"},"VersionCreateResponse":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"}},"type":"object","required":["id"],"title":"VersionCreateResponse","description":"The reaponse model for app version creation api."},"VersionInfoResponse":{"properties":{"version":{"$ref":"#/components/schemas/ApplicationVersionInfo"}},"type":"object","title":"VersionInfoResponse","description":"The response model for /applications/{application_id}/versions/{version_id},\nwhich returns information of specific app version. If the specifed version not\nfound, the version property will be None."},"VersionListResponse":{"properties":{"versions":{"items":{"$ref":"#/components/schemas/ApplicationVersionInfo"},"type":"array","title":"Versions"}},"type":"object","required":["versions"],"title":"VersionListResponse","description":"The response model for application version list api."},"VersionMetadata":{"properties":{"name":{"type":"string","title":"Name"},"metadata":{"type":"object","title":"Metadata"}},"type":"object","required":["name"],"title":"VersionMetadata","description":"The request model for updating app version data."}}}} \ No newline at end of file +{"openapi":"3.1.0","info":{"title":"FastAPI","version":"0.1.0"},"paths":{"/patterns":{"get":{"summary":"Patterns","description":"Retrieves application patterns based on resolver information.\n\nReturns:\n ApplicationPatternsResponse: A response containing a list of PatternInfo objects.","operationId":"patterns_patterns_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApplicationPatternsResponse"}}}}}}},"/blocks":{"get":{"summary":"Blocks","description":"Retrieves application blocks based on resolver information.\n\nReturns:\n ApplicationBlocksResponse: A response containing a list of BlockInfo objects.","operationId":"blocks_blocks_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApplicationBlocksResponse"}}}}}}},"/applications/{application_id}":{"get":{"summary":"Get App","description":"Get information about a specific application.\n\nArgs:\n application_id (str): The ID of the application to retrieve.\n\nReturns:\n ApplicationInfoResponse: Information about the application, including its ID, name,\n active version, creation timestamp, and last update timestamp.","operationId":"get_app_applications__application_id__get","parameters":[{"required":true,"schema":{"type":"string","title":"Application Id"},"name":"application_id","in":"path"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApplicationInfoResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"put":{"summary":"Update App Meta","description":"Update the metadata of an application.\n\nArgs:\n application_id (str): The ID of the application to update.\n metadata (Metadata): The new metadata for the application.\n\nReturns:\n ItemUpdateResponse: An object indicating the success or failure of the update operation.","operationId":"update_app_meta_applications__application_id__put","parameters":[{"required":true,"schema":{"type":"string","title":"Application Id"},"name":"application_id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppMetadata"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ItemUpdateResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"delete":{"summary":"Delete App","description":"Delete an application by its ID.\n\nArgs:\n application_id (str): The ID of the application to be deleted.\n\nReturns:\n ItemDeleteResponse: A response indicating the success or failure of the deletion.","operationId":"delete_app_applications__application_id__delete","parameters":[{"required":true,"schema":{"type":"string","title":"Application Id"},"name":"application_id","in":"path"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ItemDeleteResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/applications":{"get":{"summary":"List App","description":"Retrieve a list of applications.\n\nReturns:\n ApplicationListResponse: The response containing a list of applications.","operationId":"list_app_applications_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApplicationListResponse"}}}}}},"post":{"summary":"Create App","description":"Endpoint to create a new application.\n\nArgs:\n application (ApplicationCreate): The application data to create.\n\nReturns:\n ApplicationCreateResponse: The response containing the ID of the created application.","operationId":"create_app_applications_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApplicationCreate"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApplicationCreateResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/applications/{application_id}/async_run":{"post":{"summary":"Async Run App","description":"Asynchronously runs an application with the specified ID and configuration.\n\nArgs:\n application_id (str): The ID of the application to run.\n config (ApplicationRun): The configuration for running the application.\n\nReturns:\n ApplicationRunResponse: The response containing the interaction ID which is\n used for polling running result latter.","operationId":"async_run_app_applications__application_id__async_run_post","parameters":[{"required":true,"schema":{"type":"string","title":"Application Id"},"name":"application_id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApplicationRun"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApplicationRunResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/interactions/{interaction_id}":{"get":{"summary":"Get Interaction","description":"Retrieves information about a specific interaction by its ID.\n\nArgs:\n interaction_id (str): The ID of the interaction to retrieve.\n\nReturns:\n InteractionInfoResponse: An object containing information about the interaction.","operationId":"get_interaction_interactions__interaction_id__get","parameters":[{"required":true,"schema":{"type":"string","title":"Interaction Id"},"name":"interaction_id","in":"path"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InteractionInfoResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/interactions/{interaction_id}/scores":{"post":{"summary":"Score Interaction","description":"Give an interaction a feedback to measure if the result is good.\n\nArgs:\n interaction_id (str): The ID of the interaction to score.\n score (InteractionScore): The score detail\n\nReturns:\n ItemCreateResponse: An object indicating the success or failure of the score operation.","operationId":"score_interaction_interactions__interaction_id__scores_post","parameters":[{"required":true,"schema":{"type":"string","title":"Interaction Id"},"name":"interaction_id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InteractionScore"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ItemCreateResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/applications/{application_id}/versions/{version_id}/async_run":{"post":{"summary":"Async Run App Version","description":"Asynchronously runs an application with the specified app ID, version ID and configuration.\n\nArgs:\n application_id (str): The ID of the application to run.\n version_id (str): The version of the application to run.\n config (ApplicationRun): The configuration for running the application.\n\nReturns:\n ApplicationRunResponse: The response containing the interaction ID which is\n used for polling running result latter.","operationId":"async_run_app_version_applications__application_id__versions__version_id__async_run_post","parameters":[{"required":true,"schema":{"type":"string","title":"Application Id"},"name":"application_id","in":"path"},{"required":true,"schema":{"type":"string","title":"Version Id"},"name":"version_id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApplicationRun"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApplicationRunResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/applications/{application_id}/versions/{version_id}":{"get":{"summary":"Get App Version","operationId":"get_app_version_applications__application_id__versions__version_id__get","parameters":[{"required":true,"schema":{"type":"string","title":"Application Id"},"name":"application_id","in":"path"},{"required":true,"schema":{"type":"string","title":"Version Id"},"name":"version_id","in":"path"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VersionInfoResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"put":{"summary":"Update App Version Meta","description":"Update the metadata of an application.\n\nArgs:\n application_id (str): The ID of the application.\n version_id (str): The ID of the version to be updated.\n metadata (VersionMetadata): The new metadata for the version.\n\nReturns:\n ItemUpdateResponse: An object indicating the success or failure of the update operation.","operationId":"update_app_version_meta_applications__application_id__versions__version_id__put","parameters":[{"required":true,"schema":{"type":"string","title":"Application Id"},"name":"application_id","in":"path"},{"required":true,"schema":{"type":"string","title":"Version Id"},"name":"version_id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/VersionMetadata"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ItemUpdateResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"delete":{"summary":"Delete App Version","description":"Delete a specific version of an application.\n\nArgs:\n application_id (str): The ID of the application.\n version_id (str): The ID of the version to be deleted.\n\nReturns:\n ItemDeleteResponse: An object indicating whether the deletion was successful.","operationId":"delete_app_version_applications__application_id__versions__version_id__delete","parameters":[{"required":true,"schema":{"type":"string","title":"Application Id"},"name":"application_id","in":"path"},{"required":true,"schema":{"type":"string","title":"Version Id"},"name":"version_id","in":"path"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ItemDeleteResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/applications/{application_id}/versions":{"get":{"summary":"List App Versions","description":"Get a list of application versions for the specified application_id.\n\nArgs:\n application_id (str): The ID of the application.\n\nReturns:\n VersionListResponse: A response containing a list of ApplicationVersionInfo objects\n representing the versions of the specified application.","operationId":"list_app_versions_applications__application_id__versions_get","parameters":[{"required":true,"schema":{"type":"string","title":"Application Id"},"name":"application_id","in":"path"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VersionListResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"post":{"summary":"Create App Version","description":"Create a new application version.\n\nArgs:\n application_id (str): The ID of the application.\n version (ApplicationVersionCreate): The details of the new application version.\n\nReturns:\n VersionCreateResponse: The response containing the ID of the created version.","operationId":"create_app_version_applications__application_id__versions_post","parameters":[{"required":true,"schema":{"type":"string","title":"Application Id"},"name":"application_id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApplicationVersionCreate"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VersionCreateResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/applications/{application_id}/versions/{version_id}/active":{"put":{"summary":"Active App Version","description":"Update the active version of an application in the database.\n\nArgs:\n application_id (str): The ID of the application to update.\n version_id (str): The ID of the version to set as active.\n\nReturns:\n ItemUpdateResponse: An ItemUpdateResponse indicating the success or failure of the update.","operationId":"active_app_version_applications__application_id__versions__version_id__active_put","parameters":[{"required":true,"schema":{"type":"string","title":"Application Id"},"name":"application_id","in":"path"},{"required":true,"schema":{"type":"string","title":"Version Id"},"name":"version_id","in":"path"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/ping":{"get":{"summary":"Ping","operationId":"ping_ping_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","title":"Response Ping Ping Get"}}}}}}},"/me":{"get":{"summary":"Me","operationId":"me_me_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/User"}}}}}}}},"components":{"schemas":{"AppMetadata":{"properties":{"name":{"type":"string","title":"Name"},"langfusePublicKey":{"type":"string","title":"Langfusepublickey"},"langfuseSecretKey":{"type":"string","title":"Langfusesecretkey"}},"type":"object","required":["name"],"title":"AppMetadata","description":"The request model for updating app data."},"ApplicationBlocksResponse":{"properties":{"blocks":{"items":{"$ref":"#/components/schemas/BlockInfo"},"type":"array","title":"Blocks"}},"type":"object","required":["blocks"],"title":"ApplicationBlocksResponse","description":"The response model for /blocks."},"ApplicationCreate":{"properties":{"name":{"type":"string","title":"Name"},"langfusePublicKey":{"type":"string","title":"Langfusepublickey"},"langfuseSecretKey":{"type":"string","title":"Langfusesecretkey"}},"type":"object","required":["name"],"title":"ApplicationCreate","description":"The request model for creating app."},"ApplicationCreateResponse":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"}},"type":"object","required":["id"],"title":"ApplicationCreateResponse","description":"The response model for creating app."},"ApplicationInfo":{"properties":{"id":{"type":"string","title":"Id"},"name":{"type":"string","title":"Name"},"user":{"type":"string","title":"User"},"langfuse_public_key":{"type":"string","title":"Langfuse Public Key"},"langfuse_secret_key":{"type":"string","title":"Langfuse Secret Key"},"active_version":{"type":"string","title":"Active Version"},"created_at":{"type":"integer","title":"Created At"},"updated_at":{"type":"integer","title":"Updated At"}},"type":"object","required":["id","name","user","created_at","updated_at"],"title":"ApplicationInfo","description":"ApplicationInfo models the app object."},"ApplicationInfoResponse":{"properties":{"application":{"$ref":"#/components/schemas/ApplicationInfo"}},"type":"object","title":"ApplicationInfoResponse","description":"The response model for /applications/{application_id}, which returns information\nof specific app. If the specifed app not found, the application property will be\nNone."},"ApplicationListResponse":{"properties":{"applications":{"items":{"$ref":"#/components/schemas/ApplicationInfo"},"type":"array","title":"Applications"}},"type":"object","required":["applications"],"title":"ApplicationListResponse","description":"The response model for /applications, which returns a list of app info."},"ApplicationPatternsResponse":{"properties":{"patterns":{"items":{"$ref":"#/components/schemas/PatternInfo"},"type":"array","title":"Patterns"}},"type":"object","required":["patterns"],"title":"ApplicationPatternsResponse","description":"The response model for /patterns."},"ApplicationRun":{"properties":{"input":{"anyOf":[{"type":"string"},{"items":{"type":"string"},"type":"array"},{"additionalProperties":{"type":"string"},"type":"object"}],"title":"Input"},"sessionId":{"type":"string","title":"Sessionid"}},"type":"object","required":["input"],"title":"ApplicationRun","description":"The request model for trigger an app."},"ApplicationRunResponse":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"}},"type":"object","required":["id"],"title":"ApplicationRunResponse","description":"The response model for trigger an app."},"ApplicationVersionCreate":{"properties":{"name":{"type":"string","title":"Name"},"parentId":{"type":"string","title":"Parentid"},"metadata":{"type":"object","title":"Metadata"},"configuration":{"$ref":"#/components/schemas/GraphConfiguration"}},"type":"object","required":["name","configuration"],"title":"ApplicationVersionCreate","description":"The request model for app version creation api."},"ApplicationVersionInfo":{"properties":{"id":{"type":"string","title":"Id"},"name":{"type":"string","title":"Name"},"user":{"type":"string","title":"User"},"app_id":{"type":"string","title":"App Id"},"created_at":{"type":"integer","title":"Created At"},"updated_at":{"type":"integer","title":"Updated At"},"metadata":{"type":"object","title":"Metadata"},"configuration":{"type":"object","title":"Configuration"}},"type":"object","required":["id","name","user","app_id","created_at","updated_at"],"title":"ApplicationVersionInfo","description":"ApplicationVersionInfo models the app version object.\nAn app can have multiple versions (but at most one active)."},"BlockInfo":{"properties":{"name":{"type":"string","title":"Name"},"alias":{"type":"string","title":"Alias"},"dir":{"type":"string","title":"Dir"},"slots":{"items":{"$ref":"#/components/schemas/Parameter"},"type":"array","title":"Slots"},"inports":{"items":{"$ref":"#/components/schemas/Parameter"},"type":"array","title":"Inports"},"outport":{"type":"string","title":"Outport"},"description":{"type":"string","title":"Description"},"examples":{"type":"string","title":"Examples"}},"type":"object","required":["name","alias","dir","slots","inports","outport"],"title":"BlockInfo","description":"A `Block` is a node in LinguFlow DAG.\n\nBlockInfo class describes:\n- what the node take (inports property)\n- what the node produce (outport property)\n- how to construct the node (slots property)"},"GraphConfiguration":{"properties":{"nodes":{"items":{"$ref":"#/components/schemas/GraphNode"},"type":"array","title":"Nodes"},"edges":{"items":{"$ref":"#/components/schemas/GraphEdge"},"type":"array","title":"Edges"}},"type":"object","required":["nodes","edges"],"title":"GraphConfiguration","description":"GraphConfiguration defines the DAG in app version.\nIt contains a node list which defines how to construct each node.\nAnd a edige list which defines how data flows."},"GraphEdge":{"properties":{"src_block":{"type":"string","title":"Src Block"},"dst_block":{"type":"string","title":"Dst Block"},"dst_port":{"type":"string","title":"Dst Port"},"alias":{"type":"string","title":"Alias"},"case":{"anyOf":[{"type":"boolean"},{"type":"string"},{"type":"integer"}],"title":"Case"}},"type":"object","title":"GraphEdge","description":"GraphEdge defines the dataflow direction between nodes in the DAG."},"GraphNode":{"properties":{"id":{"type":"string","title":"Id"},"name":{"type":"string","title":"Name"},"alias":{"type":"string","title":"Alias"},"slots":{"type":"object","title":"Slots"}},"type":"object","required":["id","name"],"title":"GraphNode","description":"GraphNode describes nodes in DAG.\nIt defines the id and fills construction parameters for blocks."},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"InteractionInfo":{"properties":{"id":{"type":"string","title":"Id"},"user":{"type":"string","title":"User"},"version_id":{"type":"string","title":"Version Id"},"created_at":{"type":"integer","title":"Created At"},"updated_at":{"type":"integer","title":"Updated At"},"output":{"type":"string","title":"Output"},"data":{"type":"object","title":"Data"}},"type":"object","required":["id","user","version_id","created_at","updated_at"],"title":"InteractionInfo","description":"InteractionInfo models the interaction object."},"InteractionInfoResponse":{"properties":{"interaction":{"$ref":"#/components/schemas/InteractionInfo"}},"type":"object","title":"InteractionInfoResponse","description":"The response model for /interactions/{interaction_id}."},"InteractionScore":{"properties":{"value":{"type":"number","title":"Value"},"comment":{"type":"string","title":"Comment"}},"type":"object","required":["value"],"title":"InteractionScore","description":"The request model for scoring interaction."},"ItemCreateResponse":{"properties":{"success":{"type":"boolean","title":"Success"},"message":{"type":"string","title":"Message"}},"type":"object","required":["success","message"],"title":"ItemCreateResponse","description":"The response model for item create."},"ItemDeleteResponse":{"properties":{"success":{"type":"boolean","title":"Success"},"message":{"type":"string","title":"Message"}},"type":"object","required":["success","message"],"title":"ItemDeleteResponse","description":"The response model for item deletion."},"ItemUpdateResponse":{"properties":{"success":{"type":"boolean","title":"Success"},"message":{"type":"string","title":"Message"}},"type":"object","required":["success","message"],"title":"ItemUpdateResponse","description":"The response model for item update."},"Parameter":{"properties":{"name":{"type":"string","title":"Name"},"class_name":{"type":"string","title":"Class Name"},"default":{"title":"Default"},"is_variable_keyword":{"type":"boolean","title":"Is Variable Keyword","default":false}},"type":"object","required":["name","class_name"],"title":"Parameter","description":"Parameter describles the parameter of Block.__init__ and Pattern.__init__ .\n\nFor example, for Secret pattern it has a __init__ function:\n\n```\ndef __init__(self, plaintext: str):\n ...\n```\n\nSo the Parameter `plaintext` will be:\n\n```json\n{\n \"name\": \"plaintext\"\n \"class_name\": \"text\",\n \"default\": null,\n \"is_variable_keyword\": false\n}\n```"},"PatternInfo":{"properties":{"name":{"type":"string","title":"Name"},"alias":{"type":"string","title":"Alias"},"candidates":{"items":{"type":"string"},"type":"array","title":"Candidates"},"slots":{"items":{"$ref":"#/components/schemas/Parameter"},"type":"array","title":"Slots"}},"type":"object","required":["name","alias","candidates"],"title":"PatternInfo","description":"PatternInfo describe how to construct a Pattern itself.\n\nFor example, for Secret pattern it has a __init__ function:\n\n```\ndef __init__(self, plaintext: str):\n ...\n```\n\nSo its' PatternInfo will be:\n\n```json\n{\n \"name\": \"Secret\",\n \"alias\": null,\n \"candidates\": [\"Secret\"],\n \"slots\": [{\n \"name\": \"plaintext\"\n \"class_name\": \"text\",\n \"default\": null,\n \"is_variable_keyword\": false\n }]\n}\n```"},"User":{"properties":{"user":{"type":"string","title":"User"}},"type":"object","required":["user"],"title":"User","description":"The user identity"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"},"VersionCreateResponse":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"}},"type":"object","required":["id"],"title":"VersionCreateResponse","description":"The reaponse model for app version creation api."},"VersionInfoResponse":{"properties":{"version":{"$ref":"#/components/schemas/ApplicationVersionInfo"}},"type":"object","title":"VersionInfoResponse","description":"The response model for /applications/{application_id}/versions/{version_id},\nwhich returns information of specific app version. If the specifed version not\nfound, the version property will be None."},"VersionListResponse":{"properties":{"versions":{"items":{"$ref":"#/components/schemas/ApplicationVersionInfo"},"type":"array","title":"Versions"}},"type":"object","required":["versions"],"title":"VersionListResponse","description":"The response model for application version list api."},"VersionMetadata":{"properties":{"name":{"type":"string","title":"Name"},"metadata":{"type":"object","title":"Metadata"}},"type":"object","required":["name"],"title":"VersionMetadata","description":"The request model for updating app version data."}}}} \ No newline at end of file diff --git a/ui/src/modules/app_builder/Block/ROBlock.tsx b/ui/src/modules/app_builder/Block/ROBlock.tsx new file mode 100644 index 0000000..2597cba --- /dev/null +++ b/ui/src/modules/app_builder/Block/ROBlock.tsx @@ -0,0 +1,23 @@ +import { forwardRef } from 'react' +import { BlockNode, BlockNodeProps } from '.' + +export const ROBlock = forwardRef void }>( + ({ schema, node, onClick }, ref) => { + return ( + + ) + } +) diff --git a/ui/src/modules/app_builder/Block/index.tsx b/ui/src/modules/app_builder/Block/index.tsx index 1786e93..dd1b560 100644 --- a/ui/src/modules/app_builder/Block/index.tsx +++ b/ui/src/modules/app_builder/Block/index.tsx @@ -17,7 +17,7 @@ import { } from '@mantine/core' import { IconCheck, IconCopy, IconSettings, IconX } from '@tabler/icons-react' import { Edge, Handle, NodeProps, Position, useEdges, useNodeId, useReactFlow, useUpdateNodeInternals } from 'reactflow' -import { useMemo, useState } from 'react' +import { forwardRef, useMemo, useState } from 'react' import { nanoid } from 'nanoid' import { useDisclosure } from '@mantine/hooks' import { useFormContext } from 'react-hook-form' @@ -62,7 +62,10 @@ export interface DisplayedInteraction { isError: boolean } -export const BlockNode: React.FC> = ({ data, selected }) => { +export const BlockNode = forwardRef< + HTMLDivElement, + NodeProps & { readonly?: boolean; onClick?: () => void } +>(({ data, selected, readonly, onClick }, ref) => { const { colors } = useMantineTheme() const PORT_CUSTOM_STYLE = usePortCustomStyle() const { schema, node, interaction } = data @@ -93,7 +96,7 @@ export const BlockNode: React.FC> = ({ data, selected useRegisterCloseDrawer(close) return ( - <> + > = ({ data, selected ...PORT_CUSTOM_STYLE, background: colors.gray[4], border: `${PORT_BORDER}px solid ${colors.gray[2]}`, - left: `-${PORT_OFFSET}px` + left: `-${PORT_OFFSET}px`, + ...(readonly ? { cursor: 'pointer', pointerEvents: 'none' } : {}) }} /> - {alias}({node.id}) + {alias} + {node.id ? `(${node.id})` : ''} - - - {({ copied, copy }) => ( - - - {copied ? : } + {!readonly && ( + + + {({ copied, copy }) => ( + + + {copied ? : } + + + )} + + {!!slots?.length && ( + + + )} - - {!!slots?.length && ( - - - - - - )} - + + )} {inportsWithoutIgnorePorts.map((p) => { @@ -179,7 +186,8 @@ export const BlockNode: React.FC> = ({ data, selected isValidConnection={() => false} style={{ ...PORT_CUSTOM_STYLE, - left: `-${PORT_OFFSET}px` + left: `-${PORT_OFFSET}px`, + ...(readonly ? { cursor: 'pointer', pointerEvents: 'none' } : {}) }} /> @@ -209,7 +217,8 @@ export const BlockNode: React.FC> = ({ data, selected isValidConnection={isValidConnection} style={{ ...PORT_CUSTOM_STYLE, - right: `-${PORT_OFFSET}px` + right: `-${PORT_OFFSET}px`, + ...(readonly ? { cursor: 'pointer', pointerEvents: 'none' } : {}) }} /> @@ -233,9 +242,9 @@ export const BlockNode: React.FC> = ({ data, selected props={node} /> )} - + ) -} +}) interface Port { id: string diff --git a/ui/src/modules/app_builder/Canvas/HotKeyMenu.tsx b/ui/src/modules/app_builder/Canvas/HotKeyMenu.tsx index c904185..6cff085 100644 --- a/ui/src/modules/app_builder/Canvas/HotKeyMenu.tsx +++ b/ui/src/modules/app_builder/Canvas/HotKeyMenu.tsx @@ -1,11 +1,13 @@ -import { Box, Menu, TextInput, rem } from '@mantine/core' +import { Box, Group, Menu, Popover, Stack, Text, TextInput, Title, rem } from '@mantine/core' import { IconChevronRight } from '@tabler/icons-react' -import { useEffect, useMemo, useState } from 'react' +import { MutableRefObject, useEffect, useMemo, useRef, useState } from 'react' import { BlockInfo } from '@api/linguflow.schemas' import { nanoid } from 'nanoid' import { Node, useReactFlow } from 'reactflow' +import { useDisclosure, useHover } from '@mantine/hooks' import { DIR_SORTS, useBlockSchema } from '../useSchema' import { BLOCK_NODE_NAME, BlockNodeProps } from '../Block' +import { ROBlock } from '../Block/ROBlock' import { useContainerElem } from './useContainerElem' export const HotKeyMenu: React.FC<{ @@ -68,12 +70,7 @@ export const HotKeyMenu: React.FC<{ /> {(!search || !!searchedBlocks.length) && } - {!!search && - searchedBlocks.map((b) => ( - handleClickBlock(b)}> - {b.alias} - - ))} + {!!search && searchedBlocks.map((b) => )} {!search && dirAndBlocks.map(([dir, blocks]) => ( {blocks.map((b) => ( - handleClickBlock(b)}> - {b.alias} - + ))} @@ -103,3 +98,64 @@ export const HotKeyMenu: React.FC<{ ) } + +const BlockItem: React.FC<{ block: BlockInfo; onClick: (b: BlockInfo) => void }> = ({ block, onClick }) => { + const [inItem, setInItem] = useState(false) + const [opened, { close, open }] = useDisclosure(false) + const { hovered, ref } = useHover() + const timerRef: MutableRefObject = useRef(null) + + useEffect(() => { + clearTimeout(timerRef.current as any as number) + if (!hovered && !inItem) { + timerRef.current = setTimeout(() => { + close() + }, 100) as any as number + } + }, [hovered, inItem, close]) + + return ( + + + onClick(block)} + onMouseEnter={() => { + setInItem(true) + open() + }} + onMouseLeave={() => setInItem(false)} + > + {block.alias} + + + + + {(block.description || block.examples) && ( + + {block.description && ( + <> + Description + {block.description} + + )} + {block.examples && ( + <> + Example + {block.examples} + + )} + + )} + {/* 123 {hovered.toString()} */} + onClick(block)} /> + + + + ) +}