Hi,
I am trying to vectorize some pdfs with Azure OpenAI and Weaviate Java client. But it throws exception about missing OpenAI Key, which is wrong since it should use Azure endpoint.
Schema:
Map<String, Object> moduleConfig = new HashMap<>() {{
put("text2vec-openai", new HashMap<>(){{
put("resourceName", "canada-aoai");
put("deploymentId", "embedding");
}});
}};
Map<String, Object> moduleConfigSkip = new HashMap<>() {{
put("text2vec-openai", new HashMap<>(){{
put("skip", true);
}});
}};
Map<String, Object> moduleConfigNoSkip = new HashMap<>() {{
put("text2vec-openai", new HashMap<>(){{
put("skip", false);
}});
}};
Result<Boolean> run = client.schema().classCreator()
.withClass(WeaviateClass.builder()
.className("CVs")
.description("collection of CVs")
.vectorizer("text2vec-openai")
.moduleConfig(moduleConfig)
.properties(List.of(
Property.builder().name("title").dataType(List.of("text"))
.moduleConfig(moduleConfigSkip).build(),
Property.builder().name("filepath").dataType(List.of("text"))
.moduleConfig(moduleConfigSkip).build(), Property.builder().name("contentVector").dataType(List.of("text"))
.moduleConfig(moduleConfigNoSkip).build()
))
.build()).run();
WeaviateClient:
Map<String, String> headers = new HashMap<>() { {
put("X-Azure-Api-Key", "<MY_AZURE_OpenAI_Key>");
} };
Config config = new Config("http", "localhost:8080", headers);
WeaviateClient client = new WeaviateClient(config);
Adding pdf Objects to Weaviate(Resume is POJO with title, filepath, contentVector as fields):
Gson gson = new Gson();
String json = gson.toJson(resume);
Map<String, Object> map = gson.fromJson(json, new TypeToken<Map<String, Object>>() {}.getType());
Result<WeaviateObject> result = client.data().creator().withClassName("CVs").withProperties(map).run();
System.out.println(result.getError().getMessages());
I also tried using ObjectsBatcher to add the Resume objects. Then I get error when I try yo query:
client.graphQL().get().withClassName("CVs")
.withFields(Field.builder().name("title").build())
.withNearText(NearTextArgument.builder().concepts(new String[]{"springboot"}).build())
.withLimit(3)
.run().getResult();
Maybe I am missing something small and trivial. But cannot make it out.
I am using docker-compose locally with text2vec-openai module enabled.
Error I get : API Key: no api key found neither in request header: X-Openai-Api-Key nor in environment variable under OPENAI_APIKEY
Thanks
Soham