Skip to content

Commit ac153ad

Browse files
committed
add zilliz cloud support and update the doc
1 parent 713a8a7 commit ac153ad

File tree

6 files changed

+89
-19
lines changed

6 files changed

+89
-19
lines changed

README.md

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ A smart qa bot that can answer questions based on existing documents.
2020
#### Edit the `config/application.yaml`
2121

2222
1. Config the `markdown.files.location` to the directory of the markdown files
23-
2. Config the `milvus.host` and `milvus.port` to the Milvus server
24-
3. Config other parameters as needed
23+
2. Config the `markdown.files.scheduleEnabled` to `true` if you want to auto update the markdown files
24+
3. Config the `milvus.host` and `milvus.port` to the Milvus server
25+
4. Config the `milvus.useZillzCloud`, `milvus.zillizCloudUri` and `milvus.zillizCloudToken` if you are using Zilliz Cloud
26+
5. Config other parameters as needed
2527

2628
#### Edit the `qa-bot.conf`
2729

@@ -48,19 +50,30 @@ Refer [apollo pr](https://github.com/apolloconfig/apollo/pull/4908/) for an exam
4850
```html
4951

5052
<html>
51-
<head>
52-
<!-- add qa bot -->
53-
<link rel="stylesheet" href="http://${your-server-url}:9090/qa-bot.css">
54-
<script src="http://${your-server-url}:9090/qa-bot.js"></script>
55-
<script>
56-
QABot.initialize({
57-
"serverUrl": "http://${your-server-url}:9090/qa",
58-
"documentSiteUrlPrefix": "https://${your-documentation-site-prefix-url}"
59-
});
60-
</script>
61-
</head>
62-
<body>
63-
64-
</body>
53+
<head>
54+
...
55+
</head>
56+
<body>
57+
...
58+
</body>
59+
<!-- add qa bot -->
60+
<script>
61+
(function() {
62+
var link = document.createElement('link');
63+
link.rel = 'stylesheet';
64+
link.href = 'http://${your-server-url}:9090/qa-bot.css';
65+
document.head.appendChild(link);
66+
67+
var script = document.createElement('script');
68+
script.src = 'http://${your-server-url}:9090/qa-bot.js';
69+
script.onload = function () {
70+
QABot.initialize({
71+
"serverUrl": "http://${your-server-url}:9090/qa",
72+
"documentSiteUrlPrefix": "https://${your-documentation-site-prefix-url}"
73+
});
74+
};
75+
document.body.appendChild(script);
76+
})();
77+
</script>
6578
</html>
6679
```

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<openai-gpt3-java.version>0.12.0</openai-gpt3-java.version>
2020
<guava.version>31.1-jre</guava.version>
2121
<flexmark.version>0.62.2</flexmark.version>
22-
<milvus.version>2.2.5</milvus.version>
22+
<milvus.version>2.2.7</milvus.version>
2323
</properties>
2424

2525
<dependencyManagement>

src/main/java/com/apolloconfig/apollo/ai/qabot/config/MilvusConfig.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ public class MilvusConfig {
1313
private int port;
1414
private String collection;
1515

16+
private boolean useZillzCloud;
17+
18+
private String zillizCloudUri;
19+
20+
private String zillizCloudToken;
21+
1622
public String getHost() {
1723
return host;
1824
}
@@ -36,4 +42,28 @@ public void setPort(int port) {
3642
public void setCollection(String collection) {
3743
this.collection = collection;
3844
}
45+
46+
public boolean isUseZillzCloud() {
47+
return useZillzCloud;
48+
}
49+
50+
public void setUseZillzCloud(boolean useZillzCloud) {
51+
this.useZillzCloud = useZillzCloud;
52+
}
53+
54+
public String getZillizCloudUri() {
55+
return zillizCloudUri;
56+
}
57+
58+
public void setZillizCloudUri(String zillizCloudUri) {
59+
this.zillizCloudUri = zillizCloudUri;
60+
}
61+
62+
public String getZillizCloudToken() {
63+
return zillizCloudToken;
64+
}
65+
66+
public void setZillizCloudToken(String zillizCloudToken) {
67+
this.zillizCloudToken = zillizCloudToken;
68+
}
3969
}

src/main/java/com/apolloconfig/apollo/ai/qabot/milvus/MilvusClientFactory.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,24 @@ public static MilvusServiceClient getClient(String host, int port) {
2323
return clients.get(key);
2424
}
2525

26+
public static MilvusServiceClient getCloudClient(String uri, String token) {
27+
if (!clients.containsKey(uri)) {
28+
synchronized (INSTANCE) {
29+
if (!clients.containsKey(uri)) {
30+
clients.put(uri, INSTANCE.createCloudClient(uri, token));
31+
}
32+
}
33+
}
34+
35+
return clients.get(uri);
36+
}
37+
2638
private MilvusServiceClient createClient(String host, int port) {
2739
return new MilvusServiceClient(
2840
ConnectParam.newBuilder().withHost(host).withPort(port).build());
2941
}
3042

43+
private MilvusServiceClient createCloudClient(String uri, String token) {
44+
return new MilvusServiceClient(ConnectParam.newBuilder().withUri(uri).withToken(token).build());
45+
}
3146
}

src/main/java/com/apolloconfig/apollo/ai/qabot/milvus/MilvusService.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,14 @@ class MilvusService implements VectorDBService {
4646

4747
public MilvusService(MilvusConfig milvusConfig) {
4848
this.milvusConfig = milvusConfig;
49-
this.milvusServiceClient = MilvusClientFactory.getClient(milvusConfig.getHost(),
50-
milvusConfig.getPort());
49+
if (milvusConfig.isUseZillzCloud()) {
50+
this.milvusServiceClient = MilvusClientFactory.getCloudClient(
51+
milvusConfig.getZillizCloudUri(),
52+
milvusConfig.getZillizCloudToken());
53+
} else {
54+
this.milvusServiceClient = MilvusClientFactory.getClient(milvusConfig.getHost(),
55+
milvusConfig.getPort());
56+
}
5157
this.ensureCollections();
5258
}
5359

src/main/resources/application.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ milvus:
4747
host: localhost
4848
# the milvus database port
4949
port: 19530
50+
# whether to use the milvus database cloud
51+
useZillzCloud: false
52+
# the zilliz cloud uri
53+
zillizCloudUri: https://xxx.zillizcloud.com
54+
# the zilliz cloud token
55+
zillizCloudToken: xxxxxxxxxxxx
5056
# the milvus database collection name, no need to create it manually
5157
collection: docs
5258

0 commit comments

Comments
 (0)