Skip to content

armgit / dspy

Public Imported from GitHub
0

DSPy: The framework for programming—not prompting—language models

Python

chore(dspy): deprecate dsp AzureCognitiveSearch retrieval class

HARISHKUMAR11120014309e585c355
diff --git a/docs/api/retrieval_model_clients/AzureCognitiveSearch.md b/docs/api/retrieval_model_clients/AzureCognitiveSearch.md
index b8c353f31..bb210e830 100644
--- a/docs/api/retrieval_model_clients/AzureCognitiveSearch.md
+++ b/docs/api/retrieval_model_clients/AzureCognitiveSearch.md
@@ -6,7 +6,7 @@ sidebar_position: 3
### Constructor
-The constructor initializes an instance of the `AzureCognitiveSearch` class and sets up parameters for sending queries and retreiving results with the Azure Cognitive Search server.
+The constructor initializes an instance of the `AzureCognitiveSearch` class and sets up parameters for sending queries and retreiving results with the Azure Cognitive Search server.
```python
class AzureCognitiveSearch:
@@ -21,6 +21,7 @@ class AzureCognitiveSearch:
```
**Parameters:**
+
- `search_service_name` (_str_): Name of Azure Cognitive Search server.
- `search_api_key` (_str_): API Authentication token for accessing Azure Cognitive Search server.
- `search_index_name` (_str_): Name of search index in the Azure Cognitive Search server.
@@ -31,4 +32,8 @@ class AzureCognitiveSearch:
Refer to [ColBERTv2](/api/retrieval_model_clients/ColBERTv2) documentation. Keep in mind there is no `simplify` flag for AzureCognitiveSearch.
-AzureCognitiveSearch supports sending queries and processing the received results, mapping content and scores to a correct format for the Azure Cognitive Search server.
\ No newline at end of file
+AzureCognitiveSearch supports sending queries and processing the received results, mapping content and scores to a correct format for the Azure Cognitive Search server.
+
+### Deprecation Notice
+
+This module is scheduled for removal in future releases. Please use the AzureAISearchRM class from dspy.retrieve.azureaisearch_rm instead.For more information, refer to the updated documentation(docs/docs/deep-dive/retrieval_models_clients/Azure.mdx).
diff --git a/dsp/modules/azurecognitivesearch.py b/dsp/modules/azurecognitivesearch.py
index fedc59b01..5f6b76f15 100644
--- a/dsp/modules/azurecognitivesearch.py
+++ b/dsp/modules/azurecognitivesearch.py
@@ -12,6 +12,10 @@ except ImportError:
"Please use the command: pip install azure-search-documents",
)
+# Deprecated: This module is scheduled for removal in future releases.
+# Please use the AzureAISearchRM class from dspy.retrieve.azureaisearch_rm instead.
+# For more information, refer to the updated documentation.
+
class AzureCognitiveSearch:
"""Wrapper for the Azure Cognitive Search Retrieval."""
@@ -37,9 +41,12 @@ class AzureCognitiveSearch:
credential=self.credential)
def __call__(self, query: str, k: int = 10) -> Union[list[str], list[dotdict]]:
-
+ print("""# Deprecated: This module is scheduled for removal in future releases.
+ Please use the AzureAISearchRM class from dspy.retrieve.azureaisearch_rm instead.
+ For more information, refer to the updated documentation.""")
+
topk: list[dict[str, Any]] = azure_search_request(self.field_text, self.field_score, self.client, query, k)
- topk = [{**d, "long_text": d["text"]} for d in topk]
+ topk = [{**d, "long_text": d["text"]} for d in topk]
return [dotdict(psg) for psg in topk]
@@ -65,6 +72,6 @@ def process_azure_result(results:SearchItemPaged, content_key:str, content_score
elif(key == content_score):
tmp["score"] = value
else:
- tmp[key] = value
+ tmp[key] = value
res.append(tmp)
- return res
+ return res