Skip to content

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

grvsahil
Copy link
Contributor

@grvsahil grvsahil commented Apr 2, 2025

Description

  • Made the destination of cohere processors configurable.
  • Updated description of the cohere processors.

Fixes #2231

Quick checks

  • I have followed the Code Guidelines.
  • There is no other pull request for the same update/change.
  • I have written unit tests.
  • I have made sure that the PR is of reasonable size and can be easily reviewed.

@grvsahil grvsahil self-assigned this Apr 2, 2025
@grvsahil grvsahil requested a review from a team as a code owner April 2, 2025 13:24
Copy link
Contributor

@maha-hajja maha-hajja left a 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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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"`,
Copy link
Contributor

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?

Suggested change
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"`,

Copy link
Contributor Author

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return cerrors.Errorf("error reference set: %w", err)
return cerrors.Errorf("error setting reference: %w", err)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: The destination of cohere processors should be configurable
2 participants