Skip to content

Commit 749fa59

Browse files
Python: Move connectors (#12282)
1 parent aad3d50 commit 749fa59

File tree

78 files changed

+497
-297
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+497
-297
lines changed

python/samples/concepts/caching/semantic_caching.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
from semantic_kernel import Kernel
1111
from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion, OpenAITextEmbedding
12-
from semantic_kernel.connectors.memory.in_memory import InMemoryStore
13-
from semantic_kernel.data.vectors import VectorStore, VectorStoreCollection, VectorStoreField, vectorstoremodel
12+
from semantic_kernel.connectors.in_memory import InMemoryStore
13+
from semantic_kernel.data.vector import VectorStore, VectorStoreCollection, VectorStoreField, vectorstoremodel
1414
from semantic_kernel.filters import FilterTypes, FunctionInvocationContext, PromptRenderContext
1515
from semantic_kernel.functions import FunctionResult
1616

python/samples/concepts/chat_history/store_chat_history_in_cosmosdb.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
from samples.concepts.setup.chat_completion_services import Services, get_chat_completion_service_and_request_settings
88
from semantic_kernel import Kernel
99
from semantic_kernel.connectors.ai import FunctionChoiceBehavior
10-
from semantic_kernel.connectors.memory.azure_cosmos_db import CosmosNoSqlStore
10+
from semantic_kernel.connectors.azure_cosmos_db import CosmosNoSqlStore
1111
from semantic_kernel.contents import ChatHistory, ChatMessageContent
1212
from semantic_kernel.core_plugins.math_plugin import MathPlugin
1313
from semantic_kernel.core_plugins.time_plugin import TimePlugin
14-
from semantic_kernel.data.vectors import VectorStore, VectorStoreCollection, VectorStoreField, vectorstoremodel
14+
from semantic_kernel.data.vector import VectorStore, VectorStoreCollection, VectorStoreField, vectorstoremodel
1515

1616
"""
1717
This sample demonstrates how to build a conversational chatbot

python/samples/concepts/memory/azure_ai_search_hotel_samples/1_interact_with_the_collection.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
load_records,
99
)
1010
from semantic_kernel.connectors.ai.open_ai import OpenAITextEmbedding
11-
from semantic_kernel.connectors.memory import AzureAISearchCollection
11+
from semantic_kernel.connectors.azure_ai_search import AzureAISearchCollection
1212

1313
"""
1414
With the data model and records defined in step_0_data_model.py, this script will create an Azure AI Search collection,
@@ -32,7 +32,7 @@ async def main(query: str):
3232
await collection.create_collection(index=custom_index)
3333
await collection.upsert(records)
3434
# get the first five records to check the upsert worked.
35-
results = await collection.get(order_by={"field": "HotelName", "ascending": True}, top=5)
35+
results = await collection.get(order_by="HotelName", top=5)
3636
print("Get first five records: ")
3737
if results:
3838
for result in results:
@@ -56,7 +56,9 @@ async def main(query: str):
5656
print("Search results using hybrid: ")
5757
# Use hybrid search to search using the vector.
5858
results = await collection.hybrid_search(
59-
query, vector_property_name="DescriptionVector", additional_property_name="Description"
59+
query,
60+
vector_property_name="DescriptionVector",
61+
additional_property_name="Description",
6062
)
6163
async for result in results.results:
6264
print(

python/samples/concepts/memory/azure_ai_search_hotel_samples/2_use_as_a_plugin.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,21 @@
33

44
import asyncio
55
from collections.abc import Awaitable, Callable
6-
from typing import TYPE_CHECKING, Any
6+
from typing import Any
77

88
from samples.concepts.memory.azure_ai_search_hotel_samples.data_model import (
99
HotelSampleClass,
1010
custom_index,
1111
load_records,
1212
)
13-
from semantic_kernel.agents import ChatCompletionAgent
14-
from semantic_kernel.agents.agent import AgentThread
15-
from semantic_kernel.connectors.ai.function_choice_behavior import FunctionChoiceBehavior
13+
from semantic_kernel.agents import AgentThread, ChatCompletionAgent
14+
from semantic_kernel.connectors.ai import FunctionChoiceBehavior
1615
from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion, OpenAITextEmbedding
17-
from semantic_kernel.connectors.memory import AzureAISearchCollection
16+
from semantic_kernel.connectors.azure_ai_search import AzureAISearchCollection
1817
from semantic_kernel.filters import FilterTypes, FunctionInvocationContext
19-
from semantic_kernel.functions import KernelParameterMetadata
20-
from semantic_kernel.functions.kernel_plugin import KernelPlugin
18+
from semantic_kernel.functions import KernelParameterMetadata, KernelPlugin
2119
from semantic_kernel.kernel_types import OptionalOneOrList
2220

23-
if TYPE_CHECKING:
24-
from semantic_kernel.functions import KernelParameterMetadata
25-
26-
2721
"""
2822
This sample builds on the previous one, but can be run independently.
2923
It uses the data model defined in step_0_data_model.py, and with that creates a collection
@@ -185,8 +179,7 @@ async def chat():
185179
# Create the Azure AI Search collection
186180
async with collection:
187181
# Check if the collection exists.
188-
if not await collection.does_collection_exist():
189-
await collection.create_collection(index=custom_index)
182+
await collection.ensure_collection_exists(index=custom_index)
190183
if not await collection.get(top=1):
191184
await collection.upsert(records)
192185
thread: AgentThread | None = None

python/samples/concepts/memory/azure_ai_search_hotel_samples/data_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
)
1616
from pydantic import BaseModel, ConfigDict
1717

18-
from semantic_kernel.data.vectors import VectorStoreField, vectorstoremodel
18+
from semantic_kernel.data.vector import VectorStoreField, vectorstoremodel
1919

2020
"""
2121
The data model used for this sample is based on the hotel data model from the Azure AI Search samples.

python/samples/concepts/memory/complex_memory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
SqlServerCollection,
2727
WeaviateCollection,
2828
)
29-
from semantic_kernel.data.vectors import (
29+
from semantic_kernel.data.vector import (
3030
SearchType,
3131
VectorSearchProtocol,
3232
VectorStoreCollection,

python/samples/concepts/memory/data_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from pandas import DataFrame
88
from pydantic import BaseModel, Field
99

10-
from semantic_kernel.data.vectors import VectorStoreCollectionDefinition, VectorStoreField, vectorstoremodel
10+
from semantic_kernel.data.vector import VectorStoreCollectionDefinition, VectorStoreField, vectorstoremodel
1111

1212
# This concept shows the different ways you can create a vector store data model
1313
# using dataclasses, Pydantic, and Python classes.

python/samples/concepts/memory/memory_with_pandas.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
import pandas as pd
77

88
from semantic_kernel.connectors.ai.open_ai import OpenAITextEmbedding
9-
from semantic_kernel.connectors.memory.azure_ai_search import AzureAISearchCollection
10-
from semantic_kernel.data.vectors import VectorStoreCollectionDefinition, VectorStoreField
9+
from semantic_kernel.connectors.azure_ai_search import AzureAISearchCollection
10+
from semantic_kernel.data.vector import VectorStoreCollectionDefinition, VectorStoreField
1111

1212
definition = VectorStoreCollectionDefinition(
1313
collection_name="pandas_test_index",

python/samples/concepts/memory/simple_memory.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
from samples.concepts.memory.utils import print_record
1010
from samples.concepts.resources.utils import Colors, print_with_color
1111
from semantic_kernel.connectors.ai.open_ai import OpenAITextEmbedding
12-
from semantic_kernel.connectors.memory import InMemoryCollection
13-
from semantic_kernel.data.vectors import VectorStoreField, vectorstoremodel
12+
from semantic_kernel.connectors.in_memory import InMemoryCollection
13+
from semantic_kernel.data.vector import VectorStoreField, vectorstoremodel
1414

1515
# This is the most basic example of a vector store and collection
1616
# For a more complex example, using different collection types, see "complex_memory.py"

python/samples/concepts/memory/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from typing import TypeVar
44

55
from samples.concepts.resources.utils import Colors, print_with_color
6-
from semantic_kernel.data.vectors import VectorSearchResult
6+
from semantic_kernel.data.vector import VectorSearchResult
77

88
_T = TypeVar("_T")
99

python/samples/concepts/on_your_data/azure_chat_gpt_with_data_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
AzureChatPromptExecutionSettings,
1111
ExtraBody,
1212
)
13-
from semantic_kernel.connectors.memory.azure_ai_search import AzureAISearchSettings
13+
from semantic_kernel.connectors.azure_ai_search import AzureAISearchSettings
1414
from semantic_kernel.contents import ChatHistory
1515
from semantic_kernel.functions import KernelArguments
1616
from semantic_kernel.prompt_template import InputVariable, PromptTemplateConfig

python/samples/concepts/rag/rag_with_vector_collection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
OpenAIChatPromptExecutionSettings,
1111
OpenAITextEmbedding,
1212
)
13-
from semantic_kernel.connectors.memory import InMemoryCollection
14-
from semantic_kernel.data.vectors import VectorStoreField, vectorstoremodel
13+
from semantic_kernel.connectors.in_memory import InMemoryCollection
14+
from semantic_kernel.data.vector import VectorStoreField, vectorstoremodel
1515
from semantic_kernel.functions import KernelArguments
1616

1717
"""

python/samples/concepts/rag/self_critique_rag.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
from semantic_kernel import Kernel
99
from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion, OpenAITextEmbedding
10-
from semantic_kernel.connectors.memory import AzureAISearchCollection
10+
from semantic_kernel.connectors.azure_ai_search import AzureAISearchCollection
1111
from semantic_kernel.contents import ChatHistory
12-
from semantic_kernel.data.vectors import VectorStoreField, vectorstoremodel
12+
from semantic_kernel.data.vector import VectorStoreField, vectorstoremodel
1313
from semantic_kernel.functions.kernel_function import KernelFunction
1414

1515
"""

python/samples/concepts/search/brave_text_search_as_plugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from semantic_kernel import Kernel
66
from semantic_kernel.connectors.ai import FunctionChoiceBehavior
77
from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion, OpenAIChatPromptExecutionSettings
8-
from semantic_kernel.connectors.search.brave import BraveSearch
8+
from semantic_kernel.connectors.brave import BraveSearch
99
from semantic_kernel.contents import ChatHistory
1010
from semantic_kernel.filters import FilterTypes, FunctionInvocationContext
1111
from semantic_kernel.functions import KernelArguments, KernelParameterMetadata

python/samples/concepts/search/google_text_search_as_plugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from semantic_kernel import Kernel
77
from semantic_kernel.connectors.ai import FunctionChoiceBehavior
88
from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion, OpenAIChatPromptExecutionSettings
9-
from semantic_kernel.connectors.search import GoogleSearch
9+
from semantic_kernel.connectors.google_search import GoogleSearch
1010
from semantic_kernel.contents import ChatHistory
1111
from semantic_kernel.filters import FilterTypes, FunctionInvocationContext
1212
from semantic_kernel.functions import KernelParameterMetadata

0 commit comments

Comments
 (0)