-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #164 from NimbleBoxAI/yash/multiapi-bugfix
[chore] automate generation of components list
- Loading branch information
Showing
11 changed files
with
195 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
Components List | ||
=============== | ||
|
||
.. this is a jinja template document, run scripts/list_builtins.py to generate components-list.rst | ||
There are several components that are shipped with the ``chainfury``. You can find how to access the underlying function | ||
via the `components page`_. | ||
|
||
.. code-block::python | ||
# load the registries you can do these imports | ||
from chainfury import programatic_actions_registry, ai_actions_registry | ||
Programatic Actions | ||
------------------- | ||
|
||
Programatic means that these are generally not an LLM call rather something more standard like calling an API, | ||
transforming the data, etc. | ||
|
||
|
||
* `serper-api` - Search the web with Serper. Copy: ``programatic_actions_registry.get("serper-api")`` | ||
|
||
* `call_api_requests` - Call an API using the requests library. Copy: ``programatic_actions_registry.get("call_api_requests")`` | ||
|
||
* `regex_search` - Perform a regex search on the text and get items in an array. Copy: ``programatic_actions_registry.get("regex_search")`` | ||
|
||
* `regex_substitute` - Perform a regex substitution on the text and get the result. Copy: ``programatic_actions_registry.get("regex_substitute")`` | ||
|
||
* `json_translator` - Extract a value from a JSON object using a list of keys. Copy: ``programatic_actions_registry.get("json_translator")`` | ||
|
||
|
||
AI Action Components | ||
-------------------- | ||
|
||
These actions generally take the input, create a custom prompt, call the Model and respond back with the result. | ||
|
||
|
||
* `hello-world` - Python function loaded from a file used as an AI action. Copy: ``ai_actions_registry.get("hello-world")`` | ||
|
||
* `deep-rap-quote` - J-type action will write a deep poem in the style of a character. Copy: ``ai_actions_registry.get("deep-rap-quote")`` | ||
|
||
|
||
Memory Components | ||
----------------- | ||
|
||
Memory components are used to store data, which can be a Vector DB or Redis, etc. | ||
|
||
|
||
* `qdrant-write` - Write to the Qdrant DB using the Qdrant client. Copy: ``memory_registry.get_write("qdrant-write")`` | ||
|
||
* `qdrant-read` - Function to read from the Qdrant DB using the Qdrant client. Copy: ``memory_registry.get_read("qdrant-read")`` | ||
|
||
|
||
Model Components | ||
---------------- | ||
|
||
Model are the different GenAI models that can be used from the ``chainfury``. | ||
|
||
|
||
* `stability-text-to-image` - Generate a new image from a text prompt. Copy: ``model_registry.get("stability-text-to-image")`` | ||
|
||
* `chatnbx` - Chat with the ChatNBX API with OpenAI compatability, see more at https://chat.nbox.ai/. Copy: ``model_registry.get("chatnbx")`` | ||
|
||
* `nbx-deploy` - Call NimbleBox LLMOps deploy API. Copy: ``model_registry.get("nbx-deploy")`` | ||
|
||
* `openai-completion` - Given a prompt, the model will return one or more predicted completions, and can also return the probabilities of alternative tokens at each position. Copy: ``model_registry.get("openai-completion")`` | ||
|
||
* `openai-chat` - Given a list of messages describing a conversation, the model will return a response. Copy: ``model_registry.get("openai-chat")`` | ||
|
||
* `openai-embedding` - Given a list of messages create embeddings for each message. Copy: ``model_registry.get("openai-embedding")`` | ||
|
||
|
||
.. all the links are here | ||
.. _components page: https://qdrant.tech/documentation/tutorials/bulk-upload/#upload-directly-to-disk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
Components List | ||
=============== | ||
|
||
.. this is a jinja template document, run scripts/list_builtins.py to generate components-list.rst | ||
There are several components that are shipped with the ``chainfury``. You can find how to access the underlying function | ||
via the `components page`_. | ||
|
||
.. code-block::python | ||
# load the registries you can do these imports | ||
from chainfury import programatic_actions_registry, ai_actions_registry | ||
Programatic Actions | ||
------------------- | ||
|
||
Programatic means that these are generally not an LLM call rather something more standard like calling an API, | ||
transforming the data, etc. | ||
|
||
{% for component in pc %} | ||
* `{{ component.id }}` - {{ component.description }} | ||
{% endfor %} | ||
|
||
AI Action Components | ||
-------------------- | ||
|
||
These actions generally take the input, create a custom prompt, call the Model and respond back with the result. | ||
|
||
{% for component in ac %} | ||
* `{{ component.id }}` - {{ component.description }} | ||
{% endfor %} | ||
|
||
Memory Components | ||
----------------- | ||
|
||
Memory components are used to store data, which can be a Vector DB or Redis, etc. | ||
|
||
{% for component in mc %} | ||
* `{{ component.id }}` - {{ component.description }} | ||
{% endfor %} | ||
|
||
Model Components | ||
---------------- | ||
|
||
Model are the different GenAI models that can be used from the ``chainfury``. | ||
|
||
{% for component in moc %} | ||
* `{{ component.id }}` - {{ component.description }} | ||
{% endfor %} | ||
|
||
.. all the links are here | ||
.. _components page: https://qdrant.tech/documentation/tutorials/bulk-upload/#upload-directly-to-disk | ||
|
Submodule cf_internal
updated
from be5b37 to 5738de
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
from fire import Fire | ||
import jinja2 as j2 | ||
from chainfury import programatic_actions_registry, ai_actions_registry, memory_registry, model_registry | ||
|
||
|
||
def main(src_file: str, trg_file: str, v: bool = False): | ||
with open(src_file, "r") as f: | ||
temp = j2.Template(f.read()) | ||
|
||
# create the components list | ||
pc = [] | ||
for node_id, node in programatic_actions_registry.nodes.items(): | ||
pc.append( | ||
{ | ||
"id": node.id, | ||
"description": node.description.rstrip(".") + f'. Copy: ``programatic_actions_registry.get("{node.id}")``', | ||
} | ||
) | ||
|
||
ac = [] | ||
for node_id, node in ai_actions_registry.nodes.items(): | ||
ac.append( | ||
{ | ||
"id": node.id, | ||
"description": node.description.rstrip(".") + f'. Copy: ``ai_actions_registry.get("{node.id}")``', | ||
} | ||
) | ||
|
||
mc = [] | ||
for node_id, node in memory_registry._memories.items(): | ||
fn = "get_read" if node.id.endswith("-read") else "get_write" | ||
mc.append( | ||
{ | ||
"id": node.id, | ||
"description": node.description.rstrip(".") + f'. Copy: ``memory_registry.{fn}("{node.id}")``', | ||
} | ||
) | ||
|
||
moc = [] | ||
for model_id, model in model_registry.models.items(): | ||
moc.append( | ||
{ | ||
"id": model_id, | ||
"description": model.description.rstrip(".") + f'. Copy: ``model_registry.get("{model_id}")``', | ||
} | ||
) | ||
|
||
op = temp.render(pc=pc, ac=ac, mc=mc, moc=moc) | ||
if v: | ||
print(op) | ||
print("Writing to", trg_file) | ||
|
||
with open(trg_file, "w") as f: | ||
f.write(op) | ||
|
||
|
||
if __name__ == "__main__": | ||
Fire(main) |