Skip to content

Commit

Permalink
TS v3 Doc Changes (#2136)
Browse files Browse the repository at this point in the history
Co-authored-by: Sebastian Witalec <[email protected]>
  • Loading branch information
malgamves and sebawita authored Jun 4, 2024
1 parent 238fcad commit 04ced1e
Show file tree
Hide file tree
Showing 230 changed files with 29,461 additions and 22,381 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jeopardy_1k.csv

# Misc
.DS_Store
.env
.env.local
.env.development.local
.env.test.local
Expand Down
12 changes: 6 additions & 6 deletions .vscode/python.code-snippets
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
{
"Edu demo WCS connect": {
"prefix": "edu-demo-wcs-connect",
"Edu demo WCD connect": {
"prefix": "edu-demo-wcd-connect",
"body": [
"import weaviate",
"import weaviate.classes as wvc",
"import os",
"",
"client = weaviate.connect_to_wcs(",
" cluster_url=os.getenv(\"WCS_DEMO_URL\"),",
" auth_credentials=weaviate.auth.AuthApiKey(os.getenv(\"WCS_DEMO_RO_KEY\")),",
" cluster_url=os.getenv(\"WCD_DEMO_URL\"),",
" auth_credentials=weaviate.auth.AuthApiKey(os.getenv(\"WCD_DEMO_RO_KEY\")),",
" headers={",
" \"X-OpenAI-Api-Key\": os.getenv(\"OPENAI_APIKEY\"),",
" \"X-Cohere-Api-Key\": os.getenv(\"COHERE_APIKEY\"),",
" },",
")"
")",
""
],
"description": "Connect to WCS edu demo instance"
"description": "Connect to WCD edu demo instance"
},
"Code snippet section": {
"prefix": "code-section",
Expand Down
4 changes: 2 additions & 2 deletions _includes/code/DELwcs.client.instantiation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import PyClientCode from '!!raw-loader!/_includes/code/client-libraries/python_v
<TabItem value="py" label="Python Client v4">
<FilteredTextBlock
text={PyClientCode}
startMarker="# WCSQuickStartInstantiation"
endMarker="# END WCSQuickStartInstantiation"
startMarker="# WCDQuickStartInstantiation"
endMarker="# END WCDQuickStartInstantiation"
language="py"
/>
</TabItem>
Expand Down
46 changes: 14 additions & 32 deletions _includes/code/client-libraries/migrate-additional-ts3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// ConnectCloud
import weaviate from 'weaviate-client'

const client = await weaviate.connectToWCS(
const client = await weaviate.connectToWeaviateCloud(
'WEAVIATE_INSTANCE_URL', { // Replace WEAVIATE_INSTANCE_URL with your instance URL
authCredentials: new weaviate.ApiKey('WEAVIATE_INSTANCE_API_KEY'),
headers: {
Expand All @@ -20,42 +20,26 @@ console.log(client)
// ConnectLocal
import weaviate from 'weaviate-client'

const client = await weaviate.connectToLocal({
httpHost: 'localhost',
httpPort: 8080,
grpcHost: 'localhost',
grpcPort: 50051,
headers: {
'X-OpenAI-Api-Key': process.env.OPENAI_API_KEY || ''
}
}
)
const client = await weaviate.connectToLocal()

console.log(client)
// END ConnectLocal

// ConnectCustom
import weaviate from 'weaviate-client'

const client = await weaviate.client({
rest: {
host: 'WEAVIATE_INSTANCE_HOST_NAME',
port: 8080,
secure: true
},
grpc: {
host: 'WEAVIATE_INSTANCE_HOST_NAME',
port: 50051,
secure: true
},
auth: {
apiKey: process.env.WEAVIATE_API_KEY || ''
},
headers: {
'X-OpenAI-Api-Key': process.env.OPENAI_API_KEY || ''
}
const client = await weaviate.connectToCustom({
httpHost: 'localhost',
httpPort: 8080,
grpcHost: 'localhost',
grpcPort: 50051,
grpcSecure: true,
httpSecure: true,
authCredentials: new weaviate.ApiKey('WEAVIATE_INSTANCE_API_KEY'),
headers: {
'X-Cohere-Api-Key': process.env.COHERE_API_KEY || '' // Replace with your inference API key
}
)
})

console.log(client)
// END ConnectCustom
Expand All @@ -67,9 +51,7 @@ console.log(client)
// CollectionEx
const myCollection = client.collections.get('JeopardyQuestion');

const result = await myCollection.query.fetchObjects({
returnProperties: ['question'],
})
const result = await myCollection.query.fetchObjects()

console.log(JSON.stringify(result.objects, null, 2));
// END CollectionEx
Expand Down
2 changes: 1 addition & 1 deletion _includes/code/client-libraries/migrate-ts2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async function main() {
// END CompleteScript

// CompleteScript // CreateClient
// connect to your Weaviate instance on WCS
// connect to your Weaviate instance on WCD
const client: WeaviateClient = weaviate.client({
scheme: process.env.WEAVIATE_SCHEME_URL || '',
host: process.env.WEAVIATE_URL || '',
Expand Down
6 changes: 3 additions & 3 deletions _includes/code/client-libraries/migrate-ts3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ async function main() {
// END CompleteScript

// CompleteScript // CreateClient
// connect to your Weaviate instance on WCS
const client = await weaviate.connectToWCS(
// connect to your Weaviate instance on WCD
const client = await weaviate.connectToWeaviateCloud(
process.env.WEAVIATE_URL || '',
{
authCredentials: new weaviate.ApiKey(process.env.WEAVIATE_API_KEY || ''),
Expand All @@ -26,7 +26,7 @@ async function main() {
// create a new collection
await client.collections.create({
name: collectionName,
vectorizers: weaviate.configure.vectorizer.text2VecOpenAI("default"),
vectorizers: weaviate.configure.vectorizer.text2VecOpenAI(),
})
// END CompleteScript // END CreateCollection

Expand Down
8 changes: 4 additions & 4 deletions _includes/code/client-libraries/python_slow_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import weaviate

# Set these environment variables
URL = os.getenv("WCS_URL")
APIKEY = os.getenv("WCS_API_KEY")
URL = os.getenv("WCD_URL")
APIKEY = os.getenv("WCD_API_KEY")

# Connect to Weaviate Cloud
client = weaviate.connect_to_wcs(
Expand All @@ -37,8 +37,8 @@
from weaviate.auth import AuthApiKey

# Set these environment variables
URL = os.getenv("WCS_URL")
APIKEY = os.getenv("WCS_API_KEY")
URL = os.getenv("WCD_URL")
APIKEY = os.getenv("WCD_API_KEY")

# Connect to Weaviate Cloud
client = weaviate.connect_to_wcs(
Expand Down
32 changes: 16 additions & 16 deletions _includes/code/client-libraries/python_v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,33 +77,33 @@
finally:
client.close()

# WCSInstantiation
# WCDInstantiation
import weaviate
import os

client = weaviate.connect_to_wcs(
cluster_url=os.getenv("WCS_DEMO_URL"), # Replace with your Weaviate Cloud URL
auth_credentials=weaviate.auth.AuthApiKey(os.getenv("WCS_DEMO_RO_KEY")), # Replace with your Weaviate Cloud key
cluster_url=os.getenv("WCD_DEMO_URL"), # Replace with your Weaviate Cloud URL
auth_credentials=weaviate.auth.AuthApiKey(os.getenv("WCD_DEMO_RO_KEY")), # Replace with your Weaviate Cloud key
headers={'X-OpenAI-Api-key': os.getenv("OPENAI_APIKEY")} # Replace with your OpenAI API key
)
# END WCSInstantiation
# END WCDInstantiation

try:
assert client.is_ready()
finally:
client.close()

# WCSwOIDCInstantiation
# WCDwOIDCInstantiation
import weaviate

client = weaviate.connect_to_wcs(
cluster_url=os.getenv("WCS_DEMO_URL"), # Replace with your Weaviate Cloud URL
cluster_url=os.getenv("WCD_DEMO_URL"), # Replace with your Weaviate Cloud URL
auth_credentials=weaviate.auth.AuthClientPassword(
username=os.getenv("WCS_USERNAME"), # Your Weaviate Cloud username
password=os.getenv("WCS_PASSWORD") # Your Weaviate Cloud password
username=os.getenv("WCD_USERNAME"), # Your Weaviate Cloud username
password=os.getenv("WCD_PASSWORD") # Your Weaviate Cloud password
)
)
# END WCSwOIDCInstantiation
# END WCDwOIDCInstantiation

try:
assert client.is_ready()
Expand Down Expand Up @@ -213,16 +213,16 @@
client.close()


# WCSQuickStartInstantiation
# WCDQuickStartInstantiation
import weaviate
import os

with weaviate.connect_to_wcs(
cluster_url=os.getenv("WCS_DEMO_URL"), # Replace with your Weaviate Cloud URL
auth_credentials=weaviate.auth.AuthApiKey(os.getenv("WCS_DEMO_RO_KEY")) # Replace with your Weaviate Cloud key
cluster_url=os.getenv("WCD_DEMO_URL"), # Replace with your Weaviate Cloud URL
auth_credentials=weaviate.auth.AuthApiKey(os.getenv("WCD_DEMO_RO_KEY")) # Replace with your Weaviate Cloud key
) as client: # Use this context manager to ensure the connection is closed
client.collections.list_all()
# END WCSQuickStartInstantiation
# END WCDQuickStartInstantiation


# =====================================================================================
Expand Down Expand Up @@ -691,10 +691,10 @@
# Query examples
# =====================================================================================

# Connect to WCS instance for query examples
# Connect to WCD instance for query examples
client = weaviate.connect_to_wcs(
cluster_url=os.getenv("WCS_DEMO_URL"),
auth_credentials=weaviate.auth.AuthApiKey(os.getenv("WCS_DEMO_RO_KEY")),
cluster_url=os.getenv("WCD_DEMO_URL"),
auth_credentials=weaviate.auth.AuthApiKey(os.getenv("WCD_DEMO_RO_KEY")),
headers={
"X-OpenAI-Api-Key": os.getenv("OPENAI_APIKEY"),
}
Expand Down
10 changes: 9 additions & 1 deletion _includes/code/embedded.instantiate.simple.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,17 @@ import PyCode from '!!raw-loader!/_includes/code/tutorials/connect.py';
)
```

</TabItem>

<TabItem value="js" label="JS/TS Client v3">

```js
// Coming soon
```

</TabItem>

<TabItem value="js" label="JavaScript/TypeScript">
<TabItem value="js2" label="JS/TS Client v2">

```js
import weaviate, { EmbeddedOptions } from 'weaviate-ts-embedded';
Expand Down
2 changes: 1 addition & 1 deletion _includes/code/generative.feedback.loops.description.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ for description in descriptions:
```
</TabItem>

<TabItem value="ts" label="TypeScript">
<TabItem value="js" label="TypeScript">

```ts
const generate_prompt: string = 'Please write a description for the following AirBnB Listing in English. NAME: {name} HOST_NAME {host_name} NEIGHBOURHOOD {neighbourhood} NEIGHBOURHOOD_GROUP {neighbourhood_group} PRICE {price}. Please do not make up any information about the property in your description.';
Expand Down
2 changes: 1 addition & 1 deletion _includes/code/generative.feedback.loops.loop.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ for ad in ads:

</TabItem>

<TabItem value="ts" label="TypeScript">
<TabItem value="js" label="TypeScript">

```ts
const generate_prompt: string = 'Please write a description for the following AirBnB Listing in English. NAME: {name} HOST_NAME {host_name} NEIGHBOURHOOD {neighbourhood} NEIGHBOURHOOD_GROUP {neighbourhood_group} PRICE {price}. Please do not make up any information about the property in your description.';
Expand Down
2 changes: 1 addition & 1 deletion _includes/code/generative.feedback.loops.search.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ client.query.get("Listing", "description").with_near_text({
```
</TabItem>

<TabItem value="ts" label="TypeScript">
<TabItem value="js" label="TypeScript">

```ts
client.graphql
Expand Down
4 changes: 2 additions & 2 deletions _includes/code/generative.groupedtask.examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
client.close()

client = weaviate.connect_to_wcs(
cluster_url=os.getenv("WCS_DEMO_URL"),
auth_credentials=weaviate.auth.AuthApiKey(os.getenv("WCS_DEMO_RO_KEY")),
cluster_url=os.getenv("WCD_DEMO_URL"),
auth_credentials=weaviate.auth.AuthApiKey(os.getenv("WCD_DEMO_RO_KEY")),
headers={
"X-OpenAI-Api-Key": os.getenv("OPENAI_APIKEY"),
}
Expand Down
4 changes: 2 additions & 2 deletions _includes/code/generative.singleprompt.examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
client.close()

client = weaviate.connect_to_wcs(
cluster_url=os.getenv("WCS_DEMO_URL"),
auth_credentials=weaviate.auth.AuthApiKey(os.getenv("WCS_DEMO_RO_KEY")),
cluster_url=os.getenv("WCD_DEMO_URL"),
auth_credentials=weaviate.auth.AuthApiKey(os.getenv("WCD_DEMO_RO_KEY")),
headers={
"X-OpenAI-Api-Key": os.getenv("OPENAI_APIKEY"),
}
Expand Down
4 changes: 2 additions & 2 deletions _includes/code/graphql.additional.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
client.close()

client = weaviate.connect_to_wcs(
cluster_url=os.getenv("WCS_DEMO_URL"),
auth_credentials=weaviate.auth.AuthApiKey(os.getenv("WCS_DEMO_RO_KEY")),
cluster_url=os.getenv("WCD_DEMO_URL"),
auth_credentials=weaviate.auth.AuthApiKey(os.getenv("WCD_DEMO_RO_KEY")),
headers={
"X-OpenAI-Api-Key": os.getenv("OPENAI_APIKEY"),
}
Expand Down
4 changes: 2 additions & 2 deletions _includes/code/graphql.aggregate.simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
client.close()

client = weaviate.connect_to_wcs(
cluster_url=os.getenv("WCS_DEMO_URL"),
auth_credentials=weaviate.auth.AuthApiKey(os.getenv("WCS_DEMO_RO_KEY")),
cluster_url=os.getenv("WCD_DEMO_URL"),
auth_credentials=weaviate.auth.AuthApiKey(os.getenv("WCD_DEMO_RO_KEY")),
headers={
"X-OpenAI-Api-Key": os.getenv("OPENAI_APIKEY"),
}
Expand Down
4 changes: 2 additions & 2 deletions _includes/code/graphql.filters.nearText.generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
client.close()

client = weaviate.connect_to_wcs(
cluster_url=os.getenv("WCS_DEMO_URL"),
auth_credentials=weaviate.auth.AuthApiKey(os.getenv("WCS_DEMO_RO_KEY")),
cluster_url=os.getenv("WCD_DEMO_URL"),
auth_credentials=weaviate.auth.AuthApiKey(os.getenv("WCD_DEMO_RO_KEY")),
headers={
"X-OpenAI-Api-Key": os.getenv("OPENAI_APIKEY"),
}
Expand Down
4 changes: 2 additions & 2 deletions _includes/code/graphql.filters.nearText.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
client.close()

client = weaviate.connect_to_wcs(
cluster_url=os.getenv("WCS_DEMO_URL"),
auth_credentials=weaviate.auth.AuthApiKey(os.getenv("WCS_DEMO_RO_KEY")),
cluster_url=os.getenv("WCD_DEMO_URL"),
auth_credentials=weaviate.auth.AuthApiKey(os.getenv("WCD_DEMO_RO_KEY")),
headers={
"X-OpenAI-Api-Key": os.getenv("OPENAI_APIKEY"),
}
Expand Down
4 changes: 2 additions & 2 deletions _includes/code/graphql.filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
client.close()

client = weaviate.connect_to_wcs(
cluster_url=os.getenv("WCS_DEMO_URL"),
auth_credentials=weaviate.auth.AuthApiKey(os.getenv("WCS_DEMO_RO_KEY")),
cluster_url=os.getenv("WCD_DEMO_URL"),
auth_credentials=weaviate.auth.AuthApiKey(os.getenv("WCD_DEMO_RO_KEY")),
headers={
"X-OpenAI-Api-Key": os.getenv("OPENAI_APIKEY"),
}
Expand Down
4 changes: 2 additions & 2 deletions _includes/code/graphql.get.simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
client.close()

client = weaviate.connect_to_wcs(
cluster_url=os.getenv("WCS_DEMO_URL"),
auth_credentials=weaviate.auth.AuthApiKey(os.getenv("WCS_DEMO_RO_KEY")),
cluster_url=os.getenv("WCD_DEMO_URL"),
auth_credentials=weaviate.auth.AuthApiKey(os.getenv("WCD_DEMO_RO_KEY")),
headers={
"X-OpenAI-Api-Key": os.getenv("OPENAI_APIKEY"),
}
Expand Down
4 changes: 2 additions & 2 deletions _includes/code/graphql.get.simple.v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ def check_results(result_in):

# Actual client instantiation
client = weaviate.Client(
url=os.getenv("WCS_EDU_DEMO_URL"),
auth_client_secret=weaviate.auth.AuthApiKey(os.getenv("WCS_EDU_DEMO_RO_KEY")),
url=os.getenv("WCD_EDU_DEMO_URL"),
auth_client_secret=weaviate.auth.AuthApiKey(os.getenv("WCD_EDU_DEMO_RO_KEY")),
additional_headers={"X-OpenAI-Api-Key": os.getenv("OPENAI_APIKEY")},
)

Expand Down
Loading

0 comments on commit 04ced1e

Please sign in to comment.