Skip to content

Commit

Permalink
DR-471 v126 release tasks (#2251)
Browse files Browse the repository at this point in the history
* DR-471 v1.26 release tasks

* DR-471 v1.26 release tasks

* DR-474 create blog post skeleton (#2253)

* DR-474 create blog release notes skeleton

* bold city

* include

* include not showing up

* solved

* Refesh (#2294)

* Webinars Update (#2272)

* Update

* Blog Update

* Minor fixes iosblog (#2275)

* fix dates, title, linkedIn and twitter links

* Webinars Update (#2272) (#2274)

* Update

* Blog Update

Co-authored-by: Shan-Weaviate <[email protected]>

---------

Co-authored-by: AJ Chan <[email protected]>
Co-authored-by: Shan-Weaviate <[email protected]>

* Update docusaurus.config.js (#2277)

* People Update (#2278)

* Episode Update (#2279)

* Add `Kagome` Korean tokenizer docs (#2281)

* Draft Kagome tokenizer docs

* Add 'USE_GSE'

* add tokenization examples

* Update kagome available version

* 20240705 update banner (#2284)

* Draft banner

* Update time

* add many shot ICL paper (#2285)

* CTA Update (#2286)

* DR-521 release py4.6.6 core1.25.7 (#2283)

* Correct version links (#2287)

* DR-522 align section names with semantic naming (#2288)

* DR-522 align section names with semantic naming

* DR-522 align section names with semantic naming

* staging

* staging

* redirects

* add axn paper (#2289)

* add axn paper

* Update index.mdx

* Title Update (#2290)

* Fix version include (#2291)

---------

Co-authored-by: Shan-Weaviate <[email protected]>
Co-authored-by: AJ Chan <[email protected]>
Co-authored-by: AJ Chan <[email protected]>
Co-authored-by: JP Hwang <[email protected]>
Co-authored-by: Zain Hasan <[email protected]>

* DR-523 blog helm changes (#2295)

* DR-489 docs scalar quantization (#2296)

* DR-489 sq compression

* redirects

* old links

* links

* clean up

* clean up

* multi-vector

* background

* background

* staging

* pause

* py clients

* ts client

* not yet supported

* DR-502 docs default maxConnections (#2304)

* DR-476 blog async replication (#2324)

* DR-476 blog async replication

* length

* DR-490 docs dashboards for async (#2325)

* DR-471 v1.26 release tasks

* DR-471 v1.26 release tasks

* DR-474 create blog post skeleton (#2253)

* DR-474 create blog release notes skeleton

* bold city

* include

* include not showing up

* solved

* Refesh (#2294)

* Webinars Update (#2272)

* Update

* Blog Update

* Minor fixes iosblog (#2275)

* fix dates, title, linkedIn and twitter links

* Webinars Update (#2272) (#2274)

* Update

* Blog Update

Co-authored-by: Shan-Weaviate <[email protected]>

---------

Co-authored-by: AJ Chan <[email protected]>
Co-authored-by: Shan-Weaviate <[email protected]>

* Update docusaurus.config.js (#2277)

* People Update (#2278)

* Episode Update (#2279)

* Add `Kagome` Korean tokenizer docs (#2281)

* Draft Kagome tokenizer docs

* Add 'USE_GSE'

* add tokenization examples

* Update kagome available version

* 20240705 update banner (#2284)

* Draft banner

* Update time

* add many shot ICL paper (#2285)

* CTA Update (#2286)

* DR-521 release py4.6.6 core1.25.7 (#2283)

* Correct version links (#2287)

* DR-522 align section names with semantic naming (#2288)

* DR-522 align section names with semantic naming

* DR-522 align section names with semantic naming

* staging

* staging

* redirects

* add axn paper (#2289)

* add axn paper

* Update index.mdx

* Title Update (#2290)

* Fix version include (#2291)

---------

Co-authored-by: Shan-Weaviate <[email protected]>
Co-authored-by: AJ Chan <[email protected]>
Co-authored-by: AJ Chan <[email protected]>
Co-authored-by: JP Hwang <[email protected]>
Co-authored-by: Zain Hasan <[email protected]>

* DR-523 blog helm changes (#2295)

* DR-489 docs scalar quantization (#2296)

* DR-489 sq compression

* redirects

* old links

* links

* clean up

* clean up

* multi-vector

* background

* background

* staging

* pause

* py clients

* ts client

* not yet supported

* DR-502 docs default maxConnections (#2304)

* DR-490 docs dashboards for async

* image

* alt ttxt

---------

Co-authored-by: JP Hwang <[email protected]>
Co-authored-by: Shan-Weaviate <[email protected]>
Co-authored-by: AJ Chan <[email protected]>
Co-authored-by: AJ Chan <[email protected]>
Co-authored-by: JP Hwang <[email protected]>
Co-authored-by: Zain Hasan <[email protected]>

* DR-482 blog dashboards for async indexes (#2326)

* DR-482 blog dashboards

* staging

* DR-484 docs async replication (#2309)

* replication

* DR-484 docs async repairs

* types

* basic

* code examples

* staging

* wording

* shorten

* blog link

* DR-483 docs improved range queries (#2330)

* DR-483 docs improved range queries

* DR-483 docs improved range queries

* range page

* py4

* py4

* chart

* DR-475 blog range queries (#2331)

* DR-475 blog range queries

* staging

* [Draft] Anthropic provider integration pages (#2273)

* First revision

* Update maxTokens text & code

* Add Anthropic to top level list

* [Draft] Tenant offloading  (#2280)

* Tenant offloading draft

* Update status names

* Update as per comments

* Update timeout value to reflect change

* [Draft] 1.26/api based modules (#2282)

* wip

* Update docs for

* [Draft] Async python docs (#2311)

* wip

* wip

* Add async draft

* typo fix

* Address TS comments

* Another fix

* Update tenant activity status used (#2338)

* DR-533 review feedback (#2340)

* DR-481 blog sq (#2341)

* DR-534 add illustrations (#2342)

* DR-534 add illustrations

* DR-534 illustrations

* DR-534 illustrations

* Update hero image (#2345)

* Draft blog (#2313)

* DR-536 py 3 code example for range index (#2347)

* DR-536 py3 code example

* DR-536 py3 code example

* Add 'OFFLOAD_S3_BUCKET_AUTO_CREATE' to the docs (#2351)

* Add 'OFFLOAD_S3_BUCKET_AUTO_CREATE' to the docs

* Update note re AWS permissions

* clarify permission language

* 20240718/add links in blogs (#2352)

* Add links in docs

* Minor updates

* DR-478 blog multi target vector (#2356)

* DR-471 v1.26 release tasks

* DR-471 v1.26 release tasks

* DR-474 create blog post skeleton (#2253)

* DR-474 create blog release notes skeleton

* bold city

* include

* include not showing up

* solved

* Refesh (#2294)

* Webinars Update (#2272)

* Update

* Blog Update

* Minor fixes iosblog (#2275)

* fix dates, title, linkedIn and twitter links

* Webinars Update (#2272) (#2274)

* Update

* Blog Update

Co-authored-by: Shan-Weaviate <[email protected]>

---------

Co-authored-by: AJ Chan <[email protected]>
Co-authored-by: Shan-Weaviate <[email protected]>

* Update docusaurus.config.js (#2277)

* People Update (#2278)

* Episode Update (#2279)

* Add `Kagome` Korean tokenizer docs (#2281)

* Draft Kagome tokenizer docs

* Add 'USE_GSE'

* add tokenization examples

* Update kagome available version

* 20240705 update banner (#2284)

* Draft banner

* Update time

* add many shot ICL paper (#2285)

* CTA Update (#2286)

* DR-521 release py4.6.6 core1.25.7 (#2283)

* Correct version links (#2287)

* DR-522 align section names with semantic naming (#2288)

* DR-522 align section names with semantic naming

* DR-522 align section names with semantic naming

* staging

* staging

* redirects

* add axn paper (#2289)

* add axn paper

* Update index.mdx

* Title Update (#2290)

* Fix version include (#2291)

---------

Co-authored-by: Shan-Weaviate <[email protected]>
Co-authored-by: AJ Chan <[email protected]>
Co-authored-by: AJ Chan <[email protected]>
Co-authored-by: JP Hwang <[email protected]>
Co-authored-by: Zain Hasan <[email protected]>

* DR-523 blog helm changes (#2295)

* DR-489 docs scalar quantization (#2296)

* DR-489 sq compression

* redirects

* old links

* links

* clean up

* clean up

* multi-vector

* background

* background

* staging

* pause

* py clients

* ts client

* not yet supported

* DR-502 docs default maxConnections (#2304)

* DR-476 blog async replication (#2324)

* DR-476 blog async replication

* length

* DR-490 docs dashboards for async (#2325)

* DR-471 v1.26 release tasks

* DR-471 v1.26 release tasks

* DR-474 create blog post skeleton (#2253)

* DR-474 create blog release notes skeleton

* bold city

* include

* include not showing up

* solved

* Refesh (#2294)

* Webinars Update (#2272)

* Update

* Blog Update

* Minor fixes iosblog (#2275)

* fix dates, title, linkedIn and twitter links

* Webinars Update (#2272) (#2274)

* Update

* Blog Update

Co-authored-by: Shan-Weaviate <[email protected]>

---------

Co-authored-by: AJ Chan <[email protected]>
Co-authored-by: Shan-Weaviate <[email protected]>

* Update docusaurus.config.js (#2277)

* People Update (#2278)

* Episode Update (#2279)

* Add `Kagome` Korean tokenizer docs (#2281)

* Draft Kagome tokenizer docs

* Add 'USE_GSE'

* add tokenization examples

* Update kagome available version

* 20240705 update banner (#2284)

* Draft banner

* Update time

* add many shot ICL paper (#2285)

* CTA Update (#2286)

* DR-521 release py4.6.6 core1.25.7 (#2283)

* Correct version links (#2287)

* DR-522 align section names with semantic naming (#2288)

* DR-522 align section names with semantic naming

* DR-522 align section names with semantic naming

* staging

* staging

* redirects

* add axn paper (#2289)

* add axn paper

* Update index.mdx

* Title Update (#2290)

* Fix version include (#2291)

---------

Co-authored-by: Shan-Weaviate <[email protected]>
Co-authored-by: AJ Chan <[email protected]>
Co-authored-by: AJ Chan <[email protected]>
Co-authored-by: JP Hwang <[email protected]>
Co-authored-by: Zain Hasan <[email protected]>

* DR-523 blog helm changes (#2295)

* DR-489 docs scalar quantization (#2296)

* DR-489 sq compression

* redirects

* old links

* links

* clean up

* clean up

* multi-vector

* background

* background

* staging

* pause

* py clients

* ts client

* not yet supported

* DR-502 docs default maxConnections (#2304)

* DR-490 docs dashboards for async

* image

* alt ttxt

---------

Co-authored-by: JP Hwang <[email protected]>
Co-authored-by: Shan-Weaviate <[email protected]>
Co-authored-by: AJ Chan <[email protected]>
Co-authored-by: AJ Chan <[email protected]>
Co-authored-by: JP Hwang <[email protected]>
Co-authored-by: Zain Hasan <[email protected]>

* DR-482 blog dashboards for async indexes (#2326)

* DR-482 blog dashboards

* staging

* DR-484 docs async replication (#2309)

* replication

* DR-484 docs async repairs

* types

* basic

* code examples

* staging

* wording

* shorten

* blog link

* DR-483 docs improved range queries (#2330)

* DR-483 docs improved range queries

* DR-483 docs improved range queries

* range page

* py4

* py4

* chart

* DR-475 blog range queries (#2331)

* DR-475 blog range queries

* staging

* [Draft] Anthropic provider integration pages (#2273)

* First revision

* Update maxTokens text & code

* Add Anthropic to top level list

* [Draft] Tenant offloading  (#2280)

* Tenant offloading draft

* Update status names

* Update as per comments

* Update timeout value to reflect change

* [Draft] 1.26/api based modules (#2282)

* wip

* Update docs for

* [Draft] Async python docs (#2311)

* wip

* wip

* Add async draft

* typo fix

* Address TS comments

* Another fix

* Update tenant activity status used (#2338)

* DR-533 review feedback (#2340)

* DR-481 blog sq (#2341)

* DR-534 add illustrations (#2342)

* DR-534 add illustrations

* DR-534 illustrations

* DR-534 illustrations

* Update hero image (#2345)

* Draft blog (#2313)

* DR-536 py 3 code example for range index (#2347)

* DR-536 py3 code example

* DR-536 py3 code example

* Add 'OFFLOAD_S3_BUCKET_AUTO_CREATE' to the docs (#2351)

* Add 'OFFLOAD_S3_BUCKET_AUTO_CREATE' to the docs

* Update note re AWS permissions

* clarify permission language

* 20240718/add links in blogs (#2352)

* Add links in docs

* Minor updates

* DR-478 blog multi target vector search

* hide blog

---------

Co-authored-by: JP Hwang <[email protected]>
Co-authored-by: Shan-Weaviate <[email protected]>
Co-authored-by: AJ Chan <[email protected]>
Co-authored-by: AJ Chan <[email protected]>
Co-authored-by: JP Hwang <[email protected]>
Co-authored-by: Zain Hasan <[email protected]>

* DR-486 docs multi target vector (#2357)

* DR-486 docs multi target vector

* DR-486 docs multi target vector

* DR-486 docs multi target vector

* details-one

* combine

* weights

* relative

* staging

* DR-540 rc updates and limitations (#2359)

* DR-540 RC updates and limitations

* rangeable

* blog

* offload

* DR-538 blog review contributions (#2360)

* DR-538 blog review contributions

* visible as rel notes

* rangeable index

* async

* anthropic

* offload

* async py

* review

---------

Co-authored-by: JP Hwang <[email protected]>
Co-authored-by: Shan-Weaviate <[email protected]>
Co-authored-by: AJ Chan <[email protected]>
Co-authored-by: AJ Chan <[email protected]>
Co-authored-by: JP Hwang <[email protected]>
Co-authored-by: Zain Hasan <[email protected]>
  • Loading branch information
7 people authored Jul 23, 2024
1 parent bb1c016 commit 5096380
Show file tree
Hide file tree
Showing 97 changed files with 3,449 additions and 5,543 deletions.
72 changes: 72 additions & 0 deletions _includes/code/client-libraries/minimal_fastapi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# START FastAPI Example
from contextlib import asynccontextmanager
from fastapi import FastAPI, HTTPException
import os
import weaviate
from weaviate.collections.classes.internal import GenerativeSearchReturnType

cohere_api_key = os.getenv("COHERE_API_KEY") # Best practice: store your API keys in environment variables

# Initialize the Weaviate client
async_client = weaviate.use_async_with_local(
headers={
"X-Cohere-Api-Key": cohere_api_key # Replace with your Cohere API key
}
)


@asynccontextmanager
async def lifespan(app: FastAPI): # See https://fastapi.tiangolo.com/advanced/events/#lifespan-function
# Connect the client to Weaviate
await async_client.connect()
yield
# Close the connection to Weaviate
await async_client.close()


app = FastAPI(lifespan=lifespan)


@app.get("/")
async def read_root():
collection = async_client.collections.get("Movie")
obj_count = await collection.aggregate.over_all(total_count=True)
return {"object_count": obj_count.total_count}


@app.get("/search")
async def search(query: str) -> dict:
if not await async_client.is_ready():
raise HTTPException(status_code=503, detail="Weaviate is not ready")

collection = async_client.collections.get("Movie")
print(query)
response: GenerativeSearchReturnType = await collection.generate.hybrid(
query=query,
target_vector="overview_vector",
single_prompt=f"""
The user searched for query: {query}.
Based on the following overview, simply recommend or not whether the
user might want to watch the movie. Do not offer any follow-ups or additional info.
MOVIE TITLE: {{title}}. OVERVIEW: {{overview}}
""",
limit=3,
)

return {
"responses": [
{
"title": object.properties["title"],
"overview": object.properties["overview"],
"recommendation": object.generated,
}
for object in response.objects
]
}


if __name__ == "__main__":
import uvicorn

uvicorn.run(app, host="0.0.0.0", port=8000)
# END FastAPI Example
269 changes: 267 additions & 2 deletions _includes/code/client-libraries/python_v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@
additional_config=AdditionalConfig(
timeout=Timeout(init=30, query=60, insert=120), # Values in seconds
),
skip_init_checks=False
)

client.connect() # When directly instantiating, you need to connect manually
Expand All @@ -230,7 +231,6 @@
client.collections.list_all()
# END WCDQuickStartInstantiation


# =====================================================================================
# Batch examples
# =====================================================================================
Expand Down Expand Up @@ -417,7 +417,6 @@
# =====================================================================================



# START CreateCollectionFromJSON
import weaviate

Expand Down Expand Up @@ -1016,3 +1015,269 @@ def work_with_collection(collection: Collection):

client.close()

# =====================================================================================
# Async instantiation
# =====================================================================================

import asyncio

# AsyncWCDInstantiation
import weaviate
import os

async_client = weaviate.use_async_with_weaviate_cloud(
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
)
# END AsyncWCDInstantiation

async def check_connection():
try:
await async_client.connect()
assert await async_client.is_ready()
finally:
await async_client.close()

loop = asyncio.new_event_loop()
try:
loop.run_until_complete(check_connection())
finally:
loop.close()


# AsyncLocalInstantiationBasic
import weaviate

async_client = weaviate.use_async_with_local()
# END AsyncLocalInstantiationBasic

async def check_connection():
try:
await async_client.connect()
assert await async_client.is_ready()
finally:
await async_client.close()

# asyncio.run(check_connection())
loop = asyncio.new_event_loop()
try:
loop.run_until_complete(check_connection())
finally:
loop.close()


# AsyncCustomInstantiationBasic
import weaviate
import os

async_client = weaviate.use_async_with_custom(
http_host="localhost",
http_port="8080",
http_secure=False,
grpc_host="localhost",
grpc_port="50051",
grpc_secure=False,
)
# END AsyncCustomInstantiationBasic

async def check_connection():
try:
await async_client.connect()
assert await async_client.is_ready()
finally:
await async_client.close()
# asyncio.run(check_connection())
loop = asyncio.new_event_loop()
try:
loop.run_until_complete(check_connection())
finally:
loop.close()

# AsyncDirectInstantiationFull
import weaviate
from weaviate.connect import ConnectionParams
from weaviate.classes.init import AdditionalConfig, Timeout
import os

client = weaviate.WeaviateAsyncClient(
connection_params=ConnectionParams.from_params(
http_host="localhost",
http_port="8099",
http_secure=False,
grpc_host="localhost",
grpc_port="50052",
grpc_secure=False,
),
auth_client_secret=weaviate.auth.AuthApiKey("secr3tk3y"),
additional_headers={
"X-OpenAI-Api-Key": os.getenv("OPENAI_APIKEY")
},
additional_config=AdditionalConfig(
timeout=Timeout(init=30, query=60, insert=120), # Values in seconds
),
skip_init_checks=False
)
# END AsyncDirectInstantiationFull

# AsyncDirectInstantiationAndConnect
import weaviate
from weaviate.connect import ConnectionParams
from weaviate import WeaviateAsyncClient
import os


async def instantiate_and_connect() -> WeaviateAsyncClient:
client = weaviate.WeaviateAsyncClient(
connection_params=ConnectionParams.from_params(
http_host="localhost",
http_port="8099",
http_secure=False,
grpc_host="localhost",
grpc_port="50052",
grpc_secure=False,
),
# Additional settings not shown
)
await client.connect()
return client

# END AsyncDirectInstantiationAndConnect

# # =====================================================================================
# # Async CRUD
# # =====================================================================================

import weaviate

client = weaviate.connect_to_local()
client.collections.delete("Movie")

client.close()

objects = [
{
"title": f"Test Movie {i+1}",
"overview": f"Overview of Test Movie {i+1}"
}
for i in range(5)
]


# START AsyncInsertionExample
import weaviate
from weaviate.classes.config import Configure, Property, DataType
from weaviate.collections.classes.batch import BatchObjectReturn
import asyncio
import os


cohere_api_key = os.getenv("COHERE_API_KEY") # Best practice: store your API keys in environment variables

async_client = weaviate.use_async_with_local(
headers={
"X-Cohere-Api-Key": cohere_api_key # Replace with your Cohere API key
}
)


async def async_insert() -> BatchObjectReturn:
# This example uses an async context manager
# The client will automatically connect and disconnect as it enters and exits the context manager
async with async_client:
collection = await async_client.collections.create(
name="Movie",
vectorizer_config=[
Configure.NamedVectors.text2vec_cohere(
"overview_vector",
source_properties=["overview"]
)
],
generative_config=Configure.Generative.cohere(),
properties=[
Property(name="title", data_type=DataType.TEXT),
Property(name="overview", data_type=DataType.TEXT),
],
)

# Build objects to insert

response = await collection.data.insert_many(objects)
return response


loop = asyncio.new_event_loop()
try:
response = loop.run_until_complete(async_insert())
finally:
loop.close()

# END AsyncInsertionExample

# START AsyncSearchExample
import weaviate
from weaviate.classes.config import Configure, Property, DataType
from weaviate.collections.classes.internal import GenerativeSearchReturnType
import asyncio
import os


cohere_api_key = os.getenv("COHERE_API_KEY") # Best practice: store your API keys in environment variables

async_client = weaviate.use_async_with_local(
headers={
"X-Cohere-Api-Key": cohere_api_key # Replace with your Cohere API key
}
)


async def async_query() -> GenerativeSearchReturnType:
async with async_client:
# Note `collections.get()` is not an async method
collection = async_client.collections.get(name="Movie")

response = await collection.generate.hybrid(
"romantic comedy set in Europe",
target_vector="overview_vector",
grouped_task="Write an ad, selling a bundle of these movies together",
limit=3,
)
return response


loop = asyncio.new_event_loop()
try:
response = loop.run_until_complete(async_query())
finally:
loop.close()


print(response.generated)
for o in response.objects:
print(o.properties["title"])
# END AsyncSearchExample


# =====================================================================================
# Async Context Manager
# =====================================================================================

# START AsyncContextManager
import weaviate

async def context_manager_example() -> bool:
async with weaviate.use_async_with_local() as async_client:
# The async context manager automatically connects and disconnects
# Use the async client - for example, check if it's ready
readiness = await async_client.is_ready()
return readiness


loop = asyncio.new_event_loop()
try:
readiness = loop.run_until_complete(context_manager_example())
finally:
loop.close()
# END AsyncContextManager


assert readiness == True
Loading

0 comments on commit 5096380

Please sign in to comment.