Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion examples/simple_weaviate.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import sys

from weaviate.classes.config import ReferenceProperty
from weaviate.client import AdditionalConfig, ConnectionParams
from weaviate.config import AdditionalConfig
from weaviate.connect.base import ConnectionParams
from weaviate.collections.classes.config import Configure
from weaviate.config import Timeout

Expand Down
208 changes: 118 additions & 90 deletions lib/poetry-lock/poetry.lock

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions lib/poetry-lock/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ repository = "https://github.com/aryn-ai/sycamore.git"
[tool.poetry.dependencies]
python = ">=3.9.2,<3.13"
# required older version
protobuf = "4.25.3" # rps
fsspec = "2024.2.0" # sycamore (via datasets)
# Make sure tests are run in the same order.
# the following will fail which prevents upgrading pytest to 8.1.1
Expand All @@ -18,7 +17,7 @@ pytest = "7.4.0"
guidance = "0.1.14" # They removed AzureOpenAIChat in https://github.com/guidance-ai/guidance/commit/a75896a851edf8b3cf15534af4fed8d15f277af1
ray = ">=2.41.0" # Latest version supported on linux/aarch64 https://github.com/ray-project/ray/issues/46104
pandas = "2.1.1" # Hardcoded into sycamore pyproject.toml. Unclear why.
weaviate-client = "4.6.4" # Failes typechecking with 4.7.0
weaviate-client = "4.14.1" # Failes typechecking with 4.7.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove comment?


# Required to continue supporting python 3.9; it may be possible to make these a bit more
# current, but latest version no longer supports 3.9
Expand Down
254 changes: 141 additions & 113 deletions lib/sycamore/poetry.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions lib/sycamore/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ elasticsearch = { version = "8.14.0", optional = true}
duckdb = { version = "^1.1.1", optional = true }
neo4j = { version = "^5.21.0", optional = true }
opensearch-py = { version = "^2.3.1", optional = true }
pinecone-client = { version = "^4.1.0", extras = ["grpc"], optional = true }
pinecone = { version = "^6.0.2", extras = ["grpc"], optional = true }
pinecone-text = { version = "^0.9.0", optional = true }
weaviate-client = { version = ">=4.6.1,<4.7", optional = true } # typechecking fails with 4.7
weaviate-client = { version = ">=4.14.1", optional = true } # typechecking fails with 4.7
qdrant-client = { version = "^1.11.2", optional = true }

# Local inference dependencies
Expand All @@ -92,7 +92,7 @@ nltk = { version = "^3.9.0", optional = true }

# LLM Dependencies
anthropic = { version = "^0.42.0", optional = true }
google-genai = {version = "^1.0", optional = true}
google-genai = {version = "^1.14.0", optional = true}
tiktoken = "^0.8.0"

[tool.poetry.group.test.dependencies]
Expand Down Expand Up @@ -129,7 +129,7 @@ duckdb = ["duckdb"]
elasticsearch = ["elasticsearch"]
neo4j = ["neo4j"]
opensearch = ["opensearch-py"]
pinecone = ["pinecone-client", "pinecone-text"]
pinecone = ["pinecone", "pinecone-text"]
weaviate = ["weaviate-client"]
qdrant = ["qdrant-client"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def read_records(self, query_params: BaseDBReader.QueryParams) -> "PineconeReade
for pids in index.list(namespace=query_params.namespace):
ids.extend(pids)
results = PineconeReaderQueryResponse(
list(dict(index.fetch(ids=ids, namespace=query_params.namespace)["vectors"]).values())
list(dict(index.fetch(ids=ids, namespace=query_params.namespace).vectors).values())
)
return results

Expand Down
12 changes: 5 additions & 7 deletions lib/sycamore/sycamore/connectors/weaviate/weaviate_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@

if typing.TYPE_CHECKING:
from weaviate import WeaviateClient
from weaviate.client import (
AdditionalConfig,
AuthCredentials,
ConnectionParams,
EmbeddedOptions,
)
from weaviate.auth import AuthCredentials
from weaviate.connect.base import ConnectionParams
from weaviate.config import AdditionalConfig
from weaviate.embedded import EmbeddedOptions


@dataclass
Expand Down Expand Up @@ -66,7 +64,7 @@ def read_records(self, query_params: BaseDBReader.QueryParams) -> "WeaviateReade
else:
collection = list(
self._client.collections.get(query_params.collection_name).iterator(include_vector=True)
)
) # type: ignore
results = WeaviateReaderQueryResponse(collection=collection)
return results

Expand Down
12 changes: 5 additions & 7 deletions lib/sycamore/sycamore/connectors/weaviate/weaviate_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,14 @@

if typing.TYPE_CHECKING:
from weaviate import WeaviateClient
from weaviate.client import (
AdditionalConfig,
AuthCredentials,
ConnectionParams,
EmbeddedOptions,
)
from weaviate.auth import AuthCredentials
from weaviate.collections.classes.config import (
_CollectionConfigCreate,
CollectionConfig,
)
from weaviate.connect.base import ConnectionParams
from weaviate.config import AdditionalConfig
from weaviate.embedded import EmbeddedOptions


# This is a convenience so that you can use the alias CollectionConfigCreate
Expand Down Expand Up @@ -127,7 +125,7 @@ def write_many_records(self, records: list[BaseDBWriter.Record], target_params:
batch.add_object(properties=r.properties, uuid=r.uuid)

def create_target_idempotent(self, target_params: BaseDBWriter.TargetParams):
from weaviate.client import UnexpectedStatusCodeError
from weaviate.exceptions import UnexpectedStatusCodeError
from weaviate.collections.classes.config import CollectionConfig

assert isinstance(target_params, WeaviateWriterTargetParams)
Expand Down
1 change: 1 addition & 0 deletions lib/sycamore/sycamore/llms/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class GeminiModels(Enum):
"""Represents available Gemini models. More info: https://googleapis.github.io/python-genai/"""

# Note that the models available on a given Gemini account may vary.
GEMINI_2_5_FLASH_PREVIEW = GeminiModel(name="gemini-2.5-flash-preview-04-17", is_chat=True)
GEMINI_2_FLASH = GeminiModel(name="gemini-2.0-flash", is_chat=True)
GEMINI_2_FLASH_LITE = GeminiModel(name="gemini-2.0-flash-lite", is_chat=True)
GEMINI_2_FLASH_THINKING = GeminiModel(name="gemini-2.0-flash-thinking-exp", is_chat=True)
Expand Down
3 changes: 3 additions & 0 deletions lib/sycamore/sycamore/llms/gemini.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,12 @@ def get_generate_kwargs(self, prompt: RenderedPrompt, llm_kwargs: Optional[dict]
buffered = io.BytesIO()
image.save(buffered, format="PNG")
image_bytes = buffered.getvalue()
assert content.parts is not None # mypy
content.parts.append(types.Part.from_bytes(data=image_bytes, mime_type="image/png"))
content_list.append(content)
kwargs["config"] = None
if thinking_budget := config.pop("thinking_budget", None):
config["thinking_config"] = types.ThinkingConfig(thinking_budget=thinking_budget)
if config:
kwargs["config"] = types.GenerateContentConfig(**config)
kwargs["content"] = content_list
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def wait_for_write_completion(client: PineconeGRPC, index_name: str, namespace:
index = client.Index(index_name)
while time.time() < deadline:
try:
desc = dict(index.fetch(ids=[doc_id], namespace=namespace)["vectors"]).items()
desc = dict(index.fetch(ids=[doc_id], namespace=namespace).vectors).items()
if len(desc) > 0:
return
except PineconeException:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import weaviate
from weaviate.classes.config import Property, ReferenceProperty
from weaviate.client import ConnectionParams
from weaviate.connect.base import ConnectionParams
from weaviate.collections.classes.config import Configure, DataType

import sycamore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import weaviate
from weaviate.classes.config import Property, ReferenceProperty
from weaviate.classes.query import Filter
from weaviate.client import ConnectionParams
from weaviate.connect.base import ConnectionParams
from weaviate.collections.classes.config import Configure, DataType

import sycamore
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
PineconeReaderQueryResponse,
)

from pinecone.data import FetchResponse, Vector


@pytest.fixture
def client_params():
Expand Down Expand Up @@ -40,9 +42,11 @@ def test_pinecone_reader_client_read_records(query_params, mock_pinecone_grpc):
mock_index = mock.Mock()
mock_pinecone_grpc.return_value.Index.return_value = mock_index
mock_index.list.return_value = [["id1", "id2"]]
mock_index.fetch.return_value = {
"vectors": {"id1": {"id": "id1", "values": [0.1, 0.2]}, "id2": {"id": "id2", "values": [0.3, 0.4]}}
}
mock_index.fetch.return_value = FetchResponse(
namespace="test_namespace",
vectors={"id1": Vector(id="id1", values=[0.1, 0.2]), "id2": Vector(id="id2", values=[0.3, 0.4])},
usage=None,
)

client = PineconeReaderClient(PineconeReaderClientParams(api_key="test_api_key"))
response = client.read_records(query_params)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from sycamore.tests.config import TEST_DIR
import weaviate
from weaviate.classes.config import Property, ReferenceProperty
from weaviate.client import ConnectionParams
from weaviate.connect.base import ConnectionParams
from weaviate.collections.classes.config import Configure, DataType
from weaviate.exceptions import WeaviateInvalidInputError

Expand Down
Loading
Loading