-
Notifications
You must be signed in to change notification settings - Fork 1
Implement custom types for inference and control plane #46
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
Conversation
src/pinecone/control.rs
Outdated
/// use pinecone_sdk::utils::errors::PineconeError; | ||
/// | ||
/// # #[tokio::main] | ||
/// # async fn main() -> Result<(), PineconeError>{ | ||
/// let pinecone = PineconeClient::new(None, None, None, None).unwrap(); | ||
/// | ||
/// // List all indexes in the project. | ||
/// let index_list_response: Result<IndexList, PineconeError> = pinecone.list_indexes().await; | ||
/// let index_list_response = pinecone.list_indexes().await; |
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.
I included the type here previously to be clear about what is being returned, is there a reason for removing it?
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.
I thought we previously said not to include it in docstrings examples and only to include it in the README example, but I may be remembering wrong and I'm okay adding it back
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.
Really nice
src/models/embeddings_list.rs
Outdated
/// The embeddings generated by the model. | ||
pub data: Vec<Vec<f32>>, |
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.
I think we should still have types to represent the Embedding, since in the future we will introduce other responses alongside values
like a sparse embedding that will have a different type than Vec<f32>
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.
I guess when we cross that bridge we may find ourselves wanting to re-type these fields as Optional, but let's keep it simple for now.
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.
This looks good to me, but would like to have input from @austin-denoble and @haruska
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.
Very nice, looks good to me. I really appreciate the organization here. 🚢
src/models/openapi.rs
Outdated
CollectionList, CollectionModel, ConfigureIndexRequest, ConfigureIndexRequestSpec, | ||
ConfigureIndexRequestSpecPod, CreateCollectionRequest, DeletionProtection, | ||
EmbedRequestParameters, IndexModelSpec, IndexModelStatus, IndexSpec, PodSpec, | ||
PodSpecMetadataConfig, ServerlessSpec, |
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.
In Rust, does this essentially re-export these models from the models
module for easier organization?
We do something similar in TypeScript with mixing generated types and custom types.
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.
Yes, outside the sdk you'd be able to import these openapi types through pinecone::models
instead of the openapi folder. The openapi types are still accessible through pinecone::openapi::<type>
though because we need to be able to access them from the sibling module, but I can see if there's a way to change that in a follow-up to this PR.
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.
Good improvement. I'd look into getting rid of the openapi::*
re-export if possible to limit the surface area of the models
module.
Problem
Currently, the SDK uses the generated types, however some of these are difficult to use from the user perspective (poorly defined, multiple versions defined, etc).
Solution
We implement a custom
EmbeddingsListUsage
,EmbeddingsList
,IndexList
,IndexModel
, andMetric
type in amodels
directory. We also export allopenapi
types to the same directory so that the imports will all be consistent.Type of Change
Test Plan
Test cases should pass.