Chain of models
This functionality for now is not supported when using async
mode.
There are cases where the overall task is complex, and your application might involve a chain of distinct models. The Nebuly SDK offers a convenient method to encapsulate all these models within a unified workflow.
This functionality is possible using the new_interaction
context manager, which you can employ to gather a lengthy and intricate sequence of models into a single input-output interaction:
Within the context manager, you have the option to utilize three methods as needed:
set_input
: This method is beneficial for explicitly defining the input for the model chain.set_history
: It can be employed to specify the previous history of interactions.set_output
: This method is valuable for explicitly defining the output of the model chain.
It’s important to note that all these methods are optional, and if not used, the data will be automatically inferred.
Example
Let’s illustrate this with an example in which we use two models to assess the sentiment and topic of a LinkedIn post:
In this example, the SDK will collect all the workflow inside a single input-output interaction, and send it to the server. You can find a detailed explanation of the allowed nebuly additional keyword arguments below:
An id or username uniquely identifying the end-user. We recommend hashing their username or email address, in order to avoid sending us any identifying information.
Tag user interactions by adding key-value pairs using this parameter. Each key represents the tag name, and the corresponding value is the tag value.
For example, if you want to tag an interaction with the model version used to reply to user input, provide it as an argument for nebuly_tags, e.g. {"version": "v1.0.0"}
. You have the flexibility to define custom tags, making them available as potential filters on the Nebuly platform.
You can use this field to temporarily override the Nebuly API key for the selected model call. The interaction will be stored in the project associated with the provided API key.