Giter Site home page Giter Site logo

Comments (5)

AitoD avatar AitoD commented on August 22, 2024

I fixed this by changing the id to uuid so it doesnt overwrite the previously stored files when uploading new stuff.

Will add a pr later today.

from vault-ai.

Yobo123o avatar Yobo123o commented on August 22, 2024

Any updates on this issue? @AitoD Can you please elaborate on what you changed to use uuids rather than ids? I am running into the overwriting issue when trying to compile a knowledge-base.

from vault-ai.

Ctrl-Alt-Rage avatar Ctrl-Alt-Rage commented on August 22, 2024

@AitoD

I tried changing a few things in the pinecone.go and postapi files but kept experiencing issues with npm start giving me an error of.

postapi\pinecone.go:29:14: uuid.New undefined (type string has no field or method New) ... error

and

postapi\pinecone.go:97:2: syntax error: non-declaration statement outside function body ... error

from vault-ai.

obaqueiro avatar obaqueiro commented on August 22, 2024

Got it. I think this works:

diff --git a/vault-web-server/postapi/pinecone.go b/vault-web-server/postapi/pinecone.go
index 2d8f1bd..0f9fae3 100644
--- a/vault-web-server/postapi/pinecone.go
+++ b/vault-web-server/postapi/pinecone.go
@@ -11,6 +11,7 @@ import (
        "math"
        "net/http"
        "strconv"
+       googleid "github.com/google/uuid"
 )
 
 type PineconeVector struct {
@@ -27,8 +28,9 @@ func upsertEmbeddingsToPinecone(embeddings [][]float32, chunks []Chunk, uuid str
        vectors := make([]PineconeVector, len(embeddings))
        for i, embedding := range embeddings {
                chunk := chunks[i]
+               myuuid := googleid.NewString()
                vectors[i] = PineconeVector{
-                       ID:     fmt.Sprintf("id-%d", i),
+                       ID:     fmt.Sprintf("id-%s", myuuid),
                        Values: embedding,
                        Metadata: map[string]string{
                                "file_name": chunk.Title,


Basically import google uuid library with a different name so as not to be overwritten by func param, and then use it to generate a uuid.


I don't have the code handy but it seems to me that the code that needs to be changed is:

ID: fmt.Sprintf("id-%d", i)

According to ChatGPT one way to generate a UUID in go is :

package main

import (
    "github.com/satori/go.uuid"
)

func main() {
    myuuid, err := uuid.NewV4()
}

So that may do the trick. I'll try it later when I have access to the code.

from vault-ai.

Ctrl-Alt-Rage avatar Ctrl-Alt-Rage commented on August 22, 2024

Got it. I think this works:

diff --git a/vault-web-server/postapi/pinecone.go b/vault-web-server/postapi/pinecone.go
index 2d8f1bd..0f9fae3 100644
--- a/vault-web-server/postapi/pinecone.go
+++ b/vault-web-server/postapi/pinecone.go
@@ -11,6 +11,7 @@ import (
        "math"
        "net/http"
        "strconv"
+       googleid "github.com/google/uuid"
 )
 
 type PineconeVector struct {
@@ -27,8 +28,9 @@ func upsertEmbeddingsToPinecone(embeddings [][]float32, chunks []Chunk, uuid str
        vectors := make([]PineconeVector, len(embeddings))
        for i, embedding := range embeddings {
                chunk := chunks[i]
+               myuuid := googleid.NewString()
                vectors[i] = PineconeVector{
-                       ID:     fmt.Sprintf("id-%d", i),
+                       ID:     fmt.Sprintf("id-%s", myuuid),
                        Values: embedding,
                        Metadata: map[string]string{
                                "file_name": chunk.Title,

Basically import google uuid library with a different name so as not to be overwritten by func param, and then use it to generate a uuid.

I don't have the code handy but it seems to me that the code that needs to be changed is:

ID: fmt.Sprintf("id-%d", i)

According to ChatGPT one way to generate a UUID in go is :

package main

import (
    "github.com/satori/go.uuid"
)

func main() {
    myuuid, err := uuid.NewV4()
}

So that may do the trick. I'll try it later when I have access to the code.

Would I be putting this in the pinecone.go file? I received a syntax error so I imagine it's because I'm doing something wrong haha

from vault-ai.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.