-
Notifications
You must be signed in to change notification settings - Fork 19
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
feat(pinecone): Add rerank task for Pinecone component #773
base: main
Are you sure you want to change the base?
feat(pinecone): Add rerank task for Pinecone component #773
Conversation
Define task in pinecone's definition.json Define inputs and outputs of component in task.json
URL is no longer required as Rerank task does not require an index
…tput response Implement required structs to parse input data to API request and parse API output to component output Introduce new client to make rerank task
…changes run campogen to update documentation with new changes
Test DetailsTested locally by creating a pinecone component's rerank task and verified data using sample input from API documentation Sample Pipeline Recipe:
Input:Component Output: |
… formed remove api version 2024-10 from headers as this is latest stable version now and supports rerank api by default
…client pinecone is redirecting towards oldest stable version that does not support rerank endpoint also recommended by pinecone in their documentation to specify api version in headers
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.
Thanks for your contribution!
I left a few comments that we need you to modify.
And, if possible, please also help us add the test code.
} | ||
|
||
return &rerankReq{ | ||
Model: "bge-reranker-v2-m3", |
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.
Though it only provides a model now, we can make it a field with a default value.
You can refer to this.
"instillUIOrder": 0, | ||
"properties": { | ||
"query": { | ||
"description": "The query to rerank the documents", |
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.
"description": "The query to rerank the documents", | |
"description": "The query to rerank the documents.", |
Now, we always add period in the end for description fields.
"type": "string" | ||
}, | ||
"documents": { | ||
"description": "The documents to rerank", |
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.
"description": "The documents to rerank", | |
"description": "The documents to rerank.", |
"type": "array" | ||
}, | ||
"top-n": { | ||
"description": "The number of results to return sorted by relevance. Defaults to the number of inputs.\n\n", |
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.
"description": "The number of results to return sorted by relevance. Defaults to the number of inputs.\n\n", | |
"description": "The number of results to return sorted by relevance. Defaults to the number of inputs.", |
"instillUIOrder": 0, | ||
"properties": { | ||
"documents": { | ||
"description": "Reranked documents", |
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.
"description": "Reranked documents", | |
"description": "Reranked documents.", |
"type": "string" | ||
}, | ||
"instillUIOrder": 0, | ||
"title": "Reranked documents", |
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.
"title": "Reranked documents", | |
"title": "Reranked Documents", |
resp := rerankResp{} | ||
req.SetResult(&resp).SetBody(inputStruct.asRequest()) | ||
if _, err := req.Post(rerankPath); err != nil { | ||
job.Error.Error(ctx, httpclient.WrapURLError(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.
Recently, I found the clients don't reply the meaningful error message in err
when sending http request.
Could you add the errMsg like this?
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.
WrapURLError is a helper to add an end-user message to http transport errors.
This message is extracted in ErrorHandler interface for component job.
@@ -145,7 +167,34 @@ func (e *execution) Execute(ctx context.Context, jobs []*base.Job) error { | |||
job.Error.Error(ctx, err) | |||
continue | |||
} | |||
case taskRerank: |
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.
It'd be good to have the test code if possible.
Because
This commit