Closed smarttang closed 2 months ago
package main
import ( "context" "github.com/tmc/langchaingo/llms/ollama" "github.com/weaviate/weaviate-go-client/v4/weaviate" "github.com/weaviate/weaviate-go-client/v4/weaviate/graphql" "github.com/weaviate/weaviate/entities/models" "log" )
func main() { className := "dbber" cfg := weaviate.Config{ Host: "localhost:8080", Scheme: "http", }
client, err := weaviate.NewClient(cfg) if err != nil { panic(err) } classObj := &models.Class{ Class: className, Vectorizer: "none", Properties: []*models.Property{ { DataType: []string{"string"}, Name: "category", }, { DataType: []string{"string"}, Name: "question", }, { DataType: []string{"string"}, Name: "answer", }, }, } // 创建class err = client.Schema().ClassCreator().WithClass(classObj).Do(context.Background()) if err != nil { log.Fatal(err) } // 构建数据 //var objects []*models.Object objects := &models.Object{ Class: className, Properties: map[string]any{ "category": "XXXXXWwww", "question": "标签1,标签2,标签3", "answer": "生产安全很重要", }, } // 批量写入数据 batchRes, err := client.Batch().ObjectsBatcher().WithObjects(objects).Do(context.Background()) if err != nil { panic(err) } for _, res := range batchRes { if res.Result.Errors != nil { panic(res.Result.Errors.Error) } } // CreateCMB() return float64 nearVector := client.GraphQL().NearVectorArgBuilder().WithVector(CreateCMB()) log.Println(client.GraphQL().Get().WithClassName(className).WithNearVector(nearVector).WithFields(graphql.Field{Name: "answer"}).Do(context.Background()))
}
this sounds like a support issue - please use our support forum and provide a reproducible example and the error you are seeing, thx!
package main
import ( "context" "github.com/tmc/langchaingo/llms/ollama" "github.com/weaviate/weaviate-go-client/v4/weaviate" "github.com/weaviate/weaviate-go-client/v4/weaviate/graphql" "github.com/weaviate/weaviate/entities/models" "log" )
func main() { className := "dbber" cfg := weaviate.Config{ Host: "localhost:8080", Scheme: "http", }
}