-
Notifications
You must be signed in to change notification settings - Fork 4
Add F# sample #82
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
Add F# sample #82
Conversation
Thanks! |
You mentioned implicit conversions warnings. Could you post them here? I'd like to look into that. |
|
Thanks. Because |
I think having small assembly Pinecone.FSharp is fine which can provide tailored experience is well known pattern. That way you can have idiomatic API in both languages. |
example/Example.FSharp/Program.fs
Outdated
// Free tier is limited to 1 index only | ||
let indexName = "test-index" | ||
let! indexList = pinecone.ListIndexes() | ||
if not (indexList |> Array.contains indexName) then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
8000The reason will be displayed to describe this comment to others. Learn more.
I prefer indexList |> Array.contains indexName |> not
example/Example.FSharp/Program.fs
Outdated
|
||
// Query the index by embedding and metadata filter | ||
let! results = index.Query((Array.zeroCreate<float32> 1536), 3u, filter = priceRange, includeMetadata = true) | ||
let tt = results |> Seq.collect (fun v -> v.Metadata) |
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 is not used
example/Example.FSharp/Program.fs
Outdated
// Query the index by embedding and metadata filter | ||
let! results = index.Query((Array.zeroCreate<float32> 1536), 3u, filter = priceRange, includeMetadata = true) | ||
let tt = results |> Seq.collect (fun v -> v.Metadata) | ||
printfn "%s" (results |> Seq.collect (fun v -> v.Metadata) |> Seq.map string |> String.concat "\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.
I would write this as
results
|> Seq.collect _.Metadata
|> Seq.map string
|> String.concat "\n"
|> printfn "%s"
example/Example.FSharp/Program.fs
Outdated
printfn "%s" (results |> Seq.collect (fun v -> v.Metadata) |> Seq.map string |> String.concat "\n") | ||
|
||
// Remove the example vectors we just added | ||
do! index.Delete(["first"; "second"]) |
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.
Square brackets are not needed
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.
Does not work without them. Maybe due to overloads.
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.
or you was talking about round brackets?
example/Example.FSharp/Program.fs
Outdated
do! index.Update("second", metadata = createMetadata["price", 99]) | ||
|
||
// Query the index by embedding and metadata filter | ||
let! results = index.Query((Array.zeroCreate<float32> 1536), 3u, filter = priceRange, includeMetadata = true) |
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 float32 required?
example/Example.FSharp/Program.fs
Outdated
use! index = pinecone.GetIndex(indexName) | ||
|
||
let tags = [|"tag1" ; "tag2"|] | ||
let first: Vector = Vector(Id = "first", Values = Array.zeroCreate 1536, Metadata = createMetadata["new", true; "price", 50; "tags", tags]) |
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.
Seems like type specitifcation is not required
@neon-sunset can you please take a look? |
No description provided.