-
Notifications
You must be signed in to change notification settings - Fork 4
/
libproject.go
63 lines (54 loc) · 1.88 KB
/
libproject.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package cmdinstance
import (
"fmt"
"os"
"path"
"github.com/tzapio/tzap/pkg/embed/localdb"
"github.com/tzapio/tzap/pkg/project"
"github.com/tzapio/tzap/pkg/types"
)
type LibProject struct {
projectName project.ProjectName
projectDir string
baseDir string
embeddingCollection types.DBCollectionInterface[types.Vector]
}
func NewLocalLibProject(baseDir string, name project.ProjectName) (project.Project, error) {
projectDir := path.Join(baseDir, "./.tzap-data", string(name))
if _, err := os.Stat(projectDir); os.IsNotExist(err) {
return nil, fmt.Errorf("localLib directory not found: %v", err)
}
embeddingCollection, err := localdb.NewFileDB[types.Vector](path.Join(projectDir, "fileembeddings.db"))
if err != nil {
return nil, err
}
localProject := &LibProject{
projectName: name,
baseDir: baseDir,
projectDir: projectDir,
embeddingCollection: embeddingCollection,
}
return localProject, nil
}
func (l *LibProject) CanIndex() bool {
return false
}
// GetEmbeddingsCache implements project.Project
func (*LibProject) GetEmbeddingsCache() types.DBCollectionInterface[string] {
panic("Local LibProject does not implement GetEmbeddingsCache() - Do not index libproject")
}
// GetTimestampCache implements project.Project
func (*LibProject) GetTimestampCache() types.DBCollectionInterface[int64] {
panic("Local LibProject does not implement GetTimestampCache() - Do not index libproject")
}
func (l *LibProject) GetEmbeddingCollection() types.DBCollectionInterface[types.Vector] {
return l.embeddingCollection
}
// GetFiles implements project.Project
func (*LibProject) GetFiles() ([]types.FileReader, error) {
panic("Local LibProject does not implement GetFiles() - Do not index libproject")
}
// GetProjectName implements project.Project
func (l *LibProject) GetProjectName() project.ProjectName {
return l.projectName
}