From e43d09793b8c8c8cfc145891cec8e932ed326a35 Mon Sep 17 00:00:00 2001 From: Ritchie Martori Date: Mon, 17 Apr 2023 15:01:00 -0700 Subject: [PATCH 1/2] add operator impl --- __init__.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ fiftyone.yml | 2 ++ 2 files changed, 46 insertions(+) create mode 100644 __init__.py create mode 100644 fiftyone.yml diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..e42ce69 --- /dev/null +++ b/__init__.py @@ -0,0 +1,44 @@ +import fiftyone.operators as foo +import fiftyone.operators.types as types + +from fiftyone.docs_search.query_index import query_index + + +class SearchDocs(foo.DynamicOperator): + def __init__(self): + super().__init__( + "search-docs", + "Searches the FiftyOne docs", + ) + + def resolve_input(self, ctx): + inputs = types.Object() + inputs.str("query", label="Query", required=True) + return types.Property(inputs) + + def execute(self, ctx): + results = query_index( + ctx.params.get("query") + ) + links = [] + for url, text, score in results: + links.append({ + "href": url, + "label": text + }) + return {"links": links} + + def resolve_output(self, ctx): + outputs = types.Object() + outputs.define_property("links", types.List(types.Link())) + return types.Property(outputs) + + +op = None + +def register(): + op = SearchDocs() + foo.register_operator(op) + +def unregister(): + foo.unregister_operator(op) diff --git a/fiftyone.yml b/fiftyone.yml new file mode 100644 index 0000000..c469db3 --- /dev/null +++ b/fiftyone.yml @@ -0,0 +1,2 @@ +fiftyone: + version: '*' \ No newline at end of file From f6042b1b01f94a50fd36da68347f31520617e6bb Mon Sep 17 00:00:00 2001 From: Ritchie Martori Date: Mon, 17 Apr 2023 15:08:01 -0700 Subject: [PATCH 2/2] operator yaml updates --- __init__.py | 4 ++-- fiftyone.yml | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/__init__.py b/__init__.py index e42ce69..36b42bd 100644 --- a/__init__.py +++ b/__init__.py @@ -7,8 +7,8 @@ class SearchDocs(foo.DynamicOperator): def __init__(self): super().__init__( - "search-docs", - "Searches the FiftyOne docs", + "@voxel51/search-docs", + "Search the FiftyOne docs", ) def resolve_input(self, ctx): diff --git a/fiftyone.yml b/fiftyone.yml index c469db3..e526ad4 100644 --- a/fiftyone.yml +++ b/fiftyone.yml @@ -1,2 +1,6 @@ fiftyone: - version: '*' \ No newline at end of file + version: ~0.21.0 +name: '@voxel51/fiftyone-docs-search' +operators: + - name: '@voxel51/search-docs' + description: Search https://docs.voxel51.com with an LLM! \ No newline at end of file