Skip to content

Commit 76a1431

Browse files
Support generative GQL search (#35)
1 parent f5598f5 commit 76a1431

14 files changed

+296
-60
lines changed

ci/docker-compose-azure-cc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ services:
1010
- --scheme
1111
- http
1212
- --write-timeout=600s
13-
image: semitechnologies/weaviate:1.18.0
13+
image: semitechnologies/weaviate:1.18.2
1414
ports:
1515
- 8081:8081
1616
restart: on-failure:0

ci/docker-compose-okta-cc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ services:
1010
- --scheme
1111
- http
1212
- --write-timeout=600s
13-
image: semitechnologies/weaviate:1.18.0
13+
image: semitechnologies/weaviate:1.18.2
1414
ports:
1515
- 8082:8082
1616
restart: on-failure:0

ci/docker-compose-okta-users.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ services:
1010
- --scheme
1111
- http
1212
- --write-timeout=600s
13-
image: semitechnologies/weaviate:1.18.0
13+
image: semitechnologies/weaviate:1.18.2
1414
ports:
1515
- 8083:8083
1616
restart: on-failure:0

ci/docker-compose-openai.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
version: '3.4'
3+
services:
4+
weaviate_openai:
5+
command:
6+
- --host
7+
- 0.0.0.0
8+
- --port
9+
- '8086'
10+
- --scheme
11+
- http
12+
image: semitechnologies/weaviate:1.18.2
13+
ports:
14+
- 8086:8086
15+
restart: on-failure:0
16+
environment:
17+
QUERY_DEFAULTS_LIMIT: 25
18+
AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true'
19+
PERSISTENCE_DATA_PATH: '/var/lib/weaviate'
20+
DEFAULT_VECTORIZER_MODULE: 'text2vec-openai'
21+
ENABLE_MODULES: 'text2vec-openai,generative-openai'
22+
CLUSTER_HOSTNAME: 'node1'
23+
...

ci/docker-compose-wcs-noscope.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

ci/docker-compose-wcs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ services:
1010
- --scheme
1111
- http
1212
- --write-timeout=600s
13-
image: semitechnologies/weaviate:1.18.0
13+
image: semitechnologies/weaviate:1.18.2
1414
ports:
1515
- 8085:8085
1616
restart: on-failure:0

ci/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
version: '3.4'
33
services:
44
weaviate:
5-
image: semitechnologies/weaviate:1.18.0
5+
image: semitechnologies/weaviate:1.18.2
66
restart: on-failure:0
77
ports:
88
- "8080:8080"

src/cluster/journey.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ const {
77
SOUP_CLASS_NAME,
88
} = require('../utils/testData');
99

10-
const EXPECTED_WEAVIATE_VERSION = '1.18.0';
11-
const EXPECTED_WEAVIATE_GIT_HASH = '8606543';
10+
const EXPECTED_WEAVIATE_VERSION = '1.18.2';
11+
const EXPECTED_WEAVIATE_GIT_HASH = '723b88a';
1212

1313
describe('cluster nodes endpoint', () => {
1414
const client = weaviate.client({

src/connection/journey.test.ts

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -138,31 +138,6 @@ describe('connection', () => {
138138
});
139139
});
140140

141-
it('makes a scopeless WCS logged-in request with username/password', () => {
142-
if (process.env.WCS_DUMMY_CI_PW == undefined || process.env.WCS_DUMMY_CI_PW == '') {
143-
console.warn('Skipping because `WCS_DUMMY_CI_PW` is not set');
144-
return;
145-
}
146-
const client = weaviate.client({
147-
scheme: 'http',
148-
host: 'localhost:8086',
149-
authClientSecret: new AuthUserPasswordCredentials({
150-
username: '[email protected]',
151-
password: process.env.WCS_DUMMY_CI_PW,
152-
}),
153-
});
154-
155-
return client.misc
156-
.metaGetter()
157-
.do()
158-
.then((res: any) => {
159-
expect(res.version).toBeDefined();
160-
})
161-
.catch((e: any) => {
162-
throw new Error('it should not have errord: ' + e);
163-
});
164-
});
165-
166141
it('makes a logged-in request with API key', () => {
167142
const client = weaviate.client({
168143
scheme: 'http',

src/graphql/generate.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
export interface GenerateArgs {
2+
groupedTask?: string;
3+
singlePrompt?: string;
4+
}
5+
6+
export interface GenerateParts {
7+
singleResult?: string;
8+
groupedResult?: string;
9+
results: string[];
10+
}
11+
12+
export class GraphQLGenerate {
13+
private groupedTask?: string;
14+
private singlePrompt?: string;
15+
16+
constructor(args: GenerateArgs) {
17+
this.groupedTask = args.groupedTask;
18+
this.singlePrompt = args.singlePrompt;
19+
}
20+
21+
toString(): string {
22+
this.validate();
23+
24+
let str = 'generate(';
25+
const results = ['error'];
26+
if (this.singlePrompt) {
27+
str += `singleResult:{prompt:"${this.singlePrompt.replace(/[\n\r]+/g, '')}"}`;
28+
results.push('singleResult');
29+
}
30+
if (this.groupedTask) {
31+
str += `groupedResult:{task:"${this.groupedTask.replace(/[\n\r]+/g, '')}"}`;
32+
results.push('groupedResult');
33+
}
34+
str += `){${results.join(' ')}}`;
35+
return str;
36+
}
37+
38+
private validate() {
39+
if (!this.groupedTask && !this.singlePrompt) {
40+
throw new Error('must provide at least one of `singlePrompt` or `groupTask`');
41+
}
42+
if (this.groupedTask !== undefined && this.groupedTask == '') {
43+
throw new Error('groupedTask must not be empty');
44+
}
45+
if (this.singlePrompt !== undefined && this.singlePrompt == '') {
46+
throw new Error('singlePrompt must not be empty');
47+
}
48+
}
49+
}

0 commit comments

Comments
 (0)