Skip to content

Python: Move connectors #12282

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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
4 changes: 2 additions & 2 deletions python/samples/concepts/caching/semantic_caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

from semantic_kernel import Kernel
from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion, OpenAITextEmbedding
from semantic_kernel.connectors.memory.in_memory import InMemoryStore
from semantic_kernel.data.vectors import VectorStore, VectorStoreCollection, VectorStoreField, vectorstoremodel
from semantic_kernel.connectors.in_memory import InMemoryStore
from semantic_kernel.data.vector import VectorStore, VectorStoreCollection, VectorStoreField, vectorstoremodel
from semantic_kernel.filters import FilterTypes, FunctionInvocationContext, PromptRenderContext
from semantic_kernel.functions import FunctionResult

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
from samples.concepts.setup.chat_completion_services import Services, get_chat_completion_service_and_request_settings
from semantic_kernel import Kernel
from semantic_kernel.connectors.ai import FunctionChoiceBehavior
from semantic_kernel.connectors.memory.azure_cosmos_db import CosmosNoSqlStore
from semantic_kernel.connectors.azure_cosmos_db import CosmosNoSqlStore
from semantic_kernel.contents import ChatHistory, ChatMessageContent
from semantic_kernel.core_plugins.math_plugin import MathPlugin
from semantic_kernel.core_plugins.time_plugin import TimePlugin
from semantic_kernel.data.vectors import VectorStore, VectorStoreCollection, VectorStoreField, vectorstoremodel
from semantic_kernel.data.vector import VectorStore, VectorStoreCollection, VectorStoreField, vectorstoremodel

"""
This sample demonstrates how to build a conversational chatbot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
load_records,
)
from semantic_kernel.connectors.ai.open_ai import OpenAITextEmbedding
from semantic_kernel.connectors.memory import AzureAISearchCollection
from semantic_kernel.connectors.azure_ai_search import AzureAISearchCollection

"""
With the data model and records defined in step_0_data_model.py, this script will create an Azure AI Search collection,
Expand All @@ -32,7 +32,7 @@ async def main(query: str):
await collection.create_collection(index=custom_index)
await collection.upsert(records)
# get the first five records to check the upsert worked.
results = await collection.get(order_by={"field": "HotelName", "ascending": True}, top=5)
results = await collection.get(order_by="HotelName", top=5)
print("Get first five records: ")
if results:
for result in results:
Expand All @@ -56,7 +56,9 @@ async def main(query: str):
print("Search results using hybrid: ")
# Use hybrid search to search using the vector.
results = await collection.hybrid_search(
query, vector_property_name="DescriptionVector", additional_property_name="Description"
query,
vector_property_name="DescriptionVector",
additional_property_name="Description",
)
async for result in results.results:
print(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,21 @@

import asyncio
from collections.abc import Awaitable, Callable
from typing import TYPE_CHECKING, Any
from typing import Any

from samples.concepts.memory.azure_ai_search_hotel_samples.data_model import (
HotelSampleClass,
custom_index,
load_records,
)
from semantic_kernel.agents import ChatCompletionAgent
from semantic_kernel.agents.agent import AgentThread
from semantic_kernel.connectors.ai.function_choice_behavior import FunctionChoiceBehavior
from semantic_kernel.agents import AgentThread, ChatCompletionAgent
from semantic_kernel.connectors.ai import FunctionChoiceBehavior
from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion, OpenAITextEmbedding
from semantic_kernel.connectors.memory import AzureAISearchCollection
from semantic_kernel.connectors.azure_ai_search import AzureAISearchCollection
from semantic_kernel.filters import FilterTypes, FunctionInvocationContext
from semantic_kernel.functions import KernelParameterMetadata
from semantic_kernel.functions.kernel_plugin import KernelPlugin
from semantic_kernel.functions import KernelParameterMetadata, KernelPlugin
from semantic_kernel.kernel_types import OptionalOneOrList

if TYPE_CHECKING:
from semantic_kernel.functions import KernelParameterMetadata


"""
This sample builds on the previous one, but can be run independently.
It uses the data model defined in step_0_data_model.py, and with that creates a collection
Expand Down Expand Up @@ -185,8 +179,7 @@ async def chat():
# Create the Azure AI Search collection
async with collection:
# Check if the collection exists.
if not await collection.does_collection_exist():
await collection.create_collection(index=custom_index)
await collection.ensure_collection_exists(index=custom_index)
if not await collection.get(top=1):
await collection.upsert(records)
thread: AgentThread | None = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
)
from pydantic import BaseModel, ConfigDict

from semantic_kernel.data.vectors import VectorStoreField, vectorstoremodel
from semantic_kernel.data.vector import VectorStoreField, vectorstoremodel

"""
The data model used for this sample is based on the hotel data model from the Azure AI Search samples.
Expand Down
2 changes: 1 addition & 1 deletion python/samples/concepts/memory/complex_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
SqlServerCollection,
WeaviateCollection,
)
from semantic_kernel.data.vectors import (
from semantic_kernel.data.vector import (
SearchType,
VectorSearchProtocol,
VectorStoreCollection,
Expand Down
2 changes: 1 addition & 1 deletion python/samples/concepts/memory/data_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from pandas import DataFrame
from pydantic import BaseModel, Field

from semantic_kernel.data.vectors import VectorStoreCollectionDefinition, VectorStoreField, vectorstoremodel
from semantic_kernel.data.vector import VectorStoreCollectionDefinition, VectorStoreField, vectorstoremodel

# This concept shows the different ways you can create a vector store data model
# using dataclasses, Pydantic, and Python classes.
Expand Down
4 changes: 2 additions & 2 deletions python/samples/concepts/memory/memory_with_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import pandas as pd

from semantic_kernel.connectors.ai.open_ai import OpenAITextEmbedding
from semantic_kernel.connectors.memory.azure_ai_search import AzureAISearchCollection
from semantic_kernel.data.vectors import VectorStoreCollectionDefinition, VectorStoreField
from semantic_kernel.connectors.azure_ai_search import AzureAISearchCollection
from semantic_kernel.data.vector import VectorStoreCollectionDefinition, VectorStoreField

definition = VectorStoreCollectionDefinition(
collection_name="pandas_test_index",
Expand Down
4 changes: 2 additions & 2 deletions python/samples/concepts/memory/simple_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from samples.concepts.memory.utils import print_record
from samples.concepts.resources.utils import Colors, print_with_color
from semantic_kernel.connectors.ai.open_ai import OpenAITextEmbedding
from semantic_kernel.connectors.memory import InMemoryCollection
from semantic_kernel.data.vectors import VectorStoreField, vectorstoremodel
from semantic_kernel.connectors.in_memory import InMemoryCollection
from semantic_kernel.data.vector import VectorStoreField, vectorstoremodel

# This is the most basic example of a vector store and collection
# For a more complex example, using different collection types, see "complex_memory.py"
Expand Down
2 changes: 1 addition & 1 deletion python/samples/concepts/memory/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import TypeVar

from samples.concepts.resources.utils import Colors, print_with_color
from semantic_kernel.data.vectors import VectorSearchResult
from semantic_kernel.data.vector import VectorSearchResult

_T = TypeVar("_T")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
AzureChatPromptExecutionSettings,
ExtraBody,
)
from semantic_kernel.connectors.memory.azure_ai_search import AzureAISearchSettings
from semantic_kernel.connectors.azure_ai_search import AzureAISearchSettings
from semantic_kernel.contents import ChatHistory
from semantic_kernel.functions import KernelArguments
from semantic_kernel.prompt_template import InputVariable, PromptTemplateConfig
Expand Down
4 changes: 2 additions & 2 deletions python/samples/concepts/rag/rag_with_vector_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
OpenAIChatPromptExecutionSettings,
OpenAITextEmbedding,
)
from semantic_kernel.connectors.memory import InMemoryCollection
from semantic_kernel.data.vectors import VectorStoreField, vectorstoremodel
from semantic_kernel.connectors.in_memory import InMemoryCollection
from semantic_kernel.data.vector import VectorStoreField, vectorstoremodel
from semantic_kernel.functions import KernelArguments

"""
Expand Down
4 changes: 2 additions & 2 deletions python/samples/concepts/rag/self_critique_rag.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

from semantic_kernel import Kernel
from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion, OpenAITextEmbedding
from semantic_kernel.connectors.memory import AzureAISearchCollection
from semantic_kernel.connectors.azure_ai_search import AzureAISearchCollection
from semantic_kernel.contents import ChatHistory
from semantic_kernel.data.vectors import VectorStoreField, vectorstoremodel
from semantic_kernel.data.vector import VectorStoreField, vectorstoremodel
from semantic_kernel.functions.kernel_function import KernelFunction

"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from semantic_kernel import Kernel
from semantic_kernel.connectors.ai import FunctionChoiceBehavior
from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion, OpenAIChatPromptExecutionSettings
from semantic_kernel.connectors.search.brave import BraveSearch
from semantic_kernel.connectors.brave import BraveSearch
from semantic_kernel.contents import ChatHistory
from semantic_kernel.filters import FilterTypes, FunctionInvocationContext
from semantic_kernel.functions import KernelArguments, KernelParameterMetadata
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from semantic_kernel import Kernel
from semantic_kernel.connectors.ai import FunctionChoiceBehavior
from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion, OpenAIChatPromptExecutionSettings
from semantic_kernel.connectors.search import GoogleSearch
from semantic_kernel.connectors.google_search import GoogleSearch
from semantic_kernel.contents import ChatHistory
from semantic_kernel.filters import FilterTypes, FunctionInvocationContext
from semantic_kernel.functions import KernelParameterMetadata
Expand Down
Loading