-
Notifications
You must be signed in to change notification settings - Fork 55
feat: configurable cohere processors destination #2235
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice work! added some small nitpicks nothing too big
@@ -113,6 +116,12 @@ func (p *EmbedProcessor) Open(ctx context.Context) error { | |||
} | |||
p.inputFieldRefResolver = &inputResolver | |||
|
|||
outputResolver, err := sdk.NewReferenceResolver(p.config.OutputField) | |||
if err != nil { | |||
return cerrors.Errorf(`failed to create a field resolver for %v parameter: %w`, p.config.OutputField, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return cerrors.Errorf(`failed to create a field resolver for %v parameter: %w`, p.config.OutputField, err) | |
return cerrors.Errorf("failed to create a field resolver for %v parameter: %w", p.config.OutputField, err) |
@@ -33,7 +33,7 @@ func ExampleCommandProcessor() { | |||
Summary: `Generate responses using Cohere's command model`, | |||
Description: ` | |||
This example demonstrates how to use the Cohere command processor to generate responses for a record's ` + "`.Payload.After`" + ` field. | |||
The processor sends the input text to the Cohere API and replaces it with the model's response.`, | |||
The processor sends the input text from the configured "request.body" to the Cohere API and stores the model's response into the configured "response.body"`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this what we meant here?
The processor sends the input text from the configured "request.body" to the Cohere API and stores the model's response into the configured "response.body"`, | |
The processor sends the input text from the configured "inputField" to the Cohere API and stores the model's response into the configured "outputField"`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The embed processor currently uses inputField/outputField for the same purpose as request.body/response.body in rerank and command processors. That's why it is like this.
@@ -53,7 +53,9 @@ type embedProcConfig struct { | |||
// The maximum waiting time before retrying. | |||
BackoffRetryMax time.Duration `json:"backoffRetry.max" default:"5s"` | |||
// Specifies the field from which the request body should be created. | |||
InputField string `json:"inputField" validate:"regex=^\\.(Payload|Key).*" default:".Payload.After"` | |||
InputField string `json:"inputField" default:".Payload.After"` | |||
// OutputField specifies in which field should the response body be saved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// OutputField specifies in which field should the response body be saved. | |
// OutputField specifies which field will the response body be saved at. |
|
||
ref, err := refRes.Resolve(r) | ||
if err != nil { | ||
return cerrors.Errorf("error reference resolver: %w", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return cerrors.Errorf("error reference resolver: %w", err) | |
return cerrors.Errorf("error resolving reference: %w", err) |
|
||
err = ref.Set(data) | ||
if err != nil { | ||
return cerrors.Errorf("error reference set: %w", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return cerrors.Errorf("error reference set: %w", err) | |
return cerrors.Errorf("error setting reference: %w", err) |
Description
Fixes #2231
Quick checks