Skip to content

Commit 8c2e5a1

Browse files
authored
Remove unecessary tools (#233)
1 parent 1c1e6c2 commit 8c2e5a1

13 files changed

Lines changed: 2 additions & 574 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Also there is some cross-domain functionality for features above:
3636
- [**Batch processing**](https://aistudio.yandex.ru/docs/ai-studio/concepts/generation/batch-processing)
3737
- Run long‑running batch tasks with automatic polling.
3838
- **Tools**
39-
- Built‑in tools such as Generative Search Tool, [Function Tool](https://aistudio.yandex.ru/docs/ai-studio/concepts/generation/function-call) and Search Index Tool that can be used in Completions and Chat, providing a unified way to extend functionality across the SDK.
39+
- [Function Tool](https://aistudio.yandex.ru/docs/ai-studio/concepts/generation/function-call) for extending models with custom callable functions in Completions and Chat.
4040
- [**Tuning**](https://aistudio.yandex.ru/docs/ai-studio/concepts/tuning/)
4141
- Fine‑tune models with configurable optimizers, schedulers and other hyper‑parameters.
4242
- [**Datasets**](https://aistudio.yandex.ru/docs/ai-studio/concepts/resources/dataset)

docs/types/tools.rst

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,8 @@
11
Tools
22
=====
33

4-
Search index tool
5-
-----------------
6-
7-
.. autoclass:: yandex_ai_studio_sdk._tools.search_index.tool.SearchIndexTool
8-
:undoc-members:
9-
10-
.. autoclass:: yandex_ai_studio_sdk._tools.search_index.rephraser.function.RephraserFunction
11-
:undoc-members:
12-
13-
.. autoclass:: yandex_ai_studio_sdk._tools.search_index.rephraser.model.Rephraser
14-
:undoc-members:
15-
16-
.. autoclass:: yandex_ai_studio_sdk._tools.search_index.call_strategy.CallStrategy
17-
:undoc-members:
18-
19-
204
Function tool
215
-------------
226

237
.. autoclass:: yandex_ai_studio_sdk._tools.tool.FunctionTool
248
:undoc-members:
25-
26-
Generative search tool
27-
----------------------
28-
29-
.. autoclass:: yandex_ai_studio_sdk._tools.generative_search.GenerativeSearchTool

src/yandex_ai_studio_sdk/_search_api/generative/function.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ def __call__(
3030
"""
3131
Creates generative search object which provides methods for invoking generative search.
3232
33-
Not to be confused with ``sdk.tools.generative_search``.
34-
Tools domain is for creating tools for using in LLMs/Assistants and search_api domain
35-
is for using Search API directly.
36-
3733
To learn more about parameters and their formats and possible values,
3834
refer to
3935
`generative search documentation <https://aistudio.yandex.ru/docs/search-api/concepts/generative-response#body>`_

src/yandex_ai_studio_sdk/_search_api/generative/generative.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from yandex.cloud.searchapi.v2.gen_search_service_pb2_grpc import GenSearchServiceStub
99

1010
from yandex_ai_studio_sdk._logging import get_logger
11-
from yandex_ai_studio_sdk._tools.generative_search import GenerativeSearchTool
1211
from yandex_ai_studio_sdk._types.misc import UNDEFINED, UndefinedOr
1312
from yandex_ai_studio_sdk._types.model import ModelSyncMixin
1413
from yandex_ai_studio_sdk._types.string import SmartStringSequence
@@ -152,28 +151,6 @@ async def _run(self, request: MessageInputType, *, timeout: float = 60) -> Gener
152151

153152
raise RuntimeError("call returned less then one result")
154153

155-
def as_tool(self, description: str) -> GenerativeSearchTool:
156-
"""
157-
Converts generative search instance to :py:class:`~.GenerativeSearchTool` object
158-
which is eligible to use as tools in LLMs/Assistants.
159-
160-
:param description: description of tool instance which also instructs model when to call it.
161-
"""
162-
c = self.config
163-
if c.fix_misspell is not None:
164-
raise ValueError("Option fix_misspell doest not supported in GenSearchTool")
165-
166-
return GenerativeSearchTool(
167-
description=description,
168-
enable_nrfm_docs=c.enable_nrfm_docs,
169-
search_filters=c.search_filters,
170-
fix_misspell=None,
171-
host=c.host,
172-
site=c.site,
173-
url=c.url,
174-
)
175-
176-
177154
@doc_from(BaseGenerativeSearch)
178155
class AsyncGenerativeSearch(BaseGenerativeSearch):
179156
@doc_from(BaseGenerativeSearch._run)

src/yandex_ai_studio_sdk/_tools/domain.py

Lines changed: 0 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,10 @@
44
from functools import cached_property
55
from typing import Generic
66

7-
from yandex_ai_studio_sdk._search_api.generative.config import SmartFilterSequence
8-
from yandex_ai_studio_sdk._search_indexes.search_index import BaseSearchIndex
97
from yandex_ai_studio_sdk._types.domain import BaseDomain
10-
from yandex_ai_studio_sdk._types.misc import UNDEFINED, UndefinedOr, get_defined_value, is_defined
11-
from yandex_ai_studio_sdk._types.string import SmartStringSequence
12-
from yandex_ai_studio_sdk._utils.coerce import ResourceType, coerce_resource_ids
138
from yandex_ai_studio_sdk._utils.doc import doc_from
149

1510
from .function import AsyncFunctionTools, FunctionTools, FunctionToolsTypeT
16-
from .generative_search import GenerativeSearchTool
17-
from .search_index.call_strategy import CallStrategy, CallStrategyInputType
18-
from .search_index.rephraser.function import RephraserFunction, RephraserInputType
19-
from .search_index.tool import SearchIndexTool
2011

2112

2213
class BaseTools(BaseDomain, Generic[FunctionToolsTypeT]):
@@ -34,8 +25,6 @@ class BaseTools(BaseDomain, Generic[FunctionToolsTypeT]):
3425
3526
Tools are particularly useful in:
3627
37-
- **AI Assistants**: Extending conversational agents with external capabilities like web search,
38-
database queries, or API calls
3928
- **Completions**: Enabling language models to invoke functions during text generation for
4029
dynamic content creation and problem-solving
4130
@@ -54,121 +43,6 @@ def function(self) -> FunctionToolsTypeT:
5443
sdk=self._sdk
5544
)
5645

57-
@cached_property
58-
def rephraser(self) -> RephraserFunction:
59-
"""
60-
Get the rephraser for creating query transformation models.
61-
62-
The rephraser provides access to specialized language models designed to intelligently
63-
rewrite and enhance user search queries by incorporating conversational context. This is
64-
particularly useful in multi-turn conversations where the latest user message may lack context
65-
from previous exchanges.
66-
67-
The rephraser works by:
68-
- Analyzing the conversation history and current user query
69-
- Reformulating the query to be more specific and contextually complete
70-
- Improving search relevance by expanding abbreviated or ambiguous terms
71-
- Maintaining semantic intent while adding necessary context
72-
73-
The rephraser returns a factory that can create Rephraser model instances with different
74-
configurations, supporting various model types including the default 'rephraser' model or
75-
custom rephrasing models.
76-
"""
77-
return RephraserFunction(
78-
name='tools.rehraser',
79-
sdk=self._sdk,
80-
parent_resource=self
81-
)
82-
83-
def search_index(
84-
self,
85-
indexes: ResourceType[BaseSearchIndex],
86-
*,
87-
max_num_results: UndefinedOr[int] = UNDEFINED,
88-
rephraser: UndefinedOr[RephraserInputType] = UNDEFINED,
89-
call_strategy: UndefinedOr[CallStrategyInputType] = UNDEFINED,
90-
) -> SearchIndexTool:
91-
"""
92-
Creates SearchIndexTool (not to be confused with :py:class:`~.SearchIndex`/:py:class:`~.AsyncSearchIndex`).
93-
94-
:param indexes: parameter takes :py:class:`~.BaseSearchIndex`, string with search index id,
95-
or a list of this values in any combination.
96-
:param max_num_results: the maximum number of results to return from the search.
97-
Fewer results may be returned if necessary to fit within the prompt's token limit.
98-
This ensures that the combined prompt and search results do not exceed the token constraints.
99-
:param rephraser: setting for rephrasing user queries; refer to :py:class:`~.Rephraser` documentation
100-
for details.
101-
"""
102-
103-
index_ids = coerce_resource_ids(indexes, BaseSearchIndex)
104-
max_num_results_ = get_defined_value(max_num_results, None)
105-
106-
rephraser_ = None
107-
if is_defined(rephraser):
108-
# this is coercing any RephraserInputType to Rephraser
109-
rephraser_ = self.rephraser(rephraser) # type: ignore[arg-type]
110-
111-
call_strategy_ = None
112-
if is_defined(call_strategy):
113-
call_strategy_ = CallStrategy._coerce(call_strategy)
114-
115-
return SearchIndexTool(
116-
search_index_ids=tuple(index_ids),
117-
max_num_results=max_num_results_,
118-
rephraser=rephraser_,
119-
call_strategy=call_strategy_,
120-
)
121-
122-
def generative_search(
123-
self,
124-
*,
125-
description: str,
126-
site: UndefinedOr[SmartStringSequence] = UNDEFINED,
127-
host: UndefinedOr[SmartStringSequence] = UNDEFINED,
128-
url: UndefinedOr[SmartStringSequence] = UNDEFINED,
129-
enable_nrfm_docs: UndefinedOr[bool] = UNDEFINED,
130-
search_filters: UndefinedOr[SmartFilterSequence] = UNDEFINED,
131-
) -> GenerativeSearchTool:
132-
"""Creates GenerativeSearch tool which provide access to
133-
generative search by `Yandex Search API <https://aistudio.yandex.ru/docs/search-api/concepts/index>`_ for LLMs.
134-
135-
Not to be confused with ``sdk.search_api.generative``.
136-
Tools domain is for creating tools for using in LLMs/Assistants and search_api domain
137-
is for using Yandex Search API directly.
138-
139-
To learn more about parameters, their formats, and possible values,
140-
refer to
141-
`generative search documentation <https://aistudio.yandex.ru/docs/search-api/concepts/generative-response#body>`_
142-
143-
NB: All of the ``site``, ``host``, ``url`` parameters are mutually exclusive.
144-
145-
:param site: parameter for limiting search to specific location or list of sites.
146-
:param host: parameter for limiting search to specific location or list of hosts.
147-
:param url: parameter for limiting search to specific location or list of URLs.
148-
:param enable_nrfm_docs: tells to backend to include or not to include pages,
149-
which are not available via direct clicks from given sites/hosts/urls
150-
to search result.
151-
:param search_filters: allows to limit search results with additional filters.
152-
153-
>>> date_filter = {'date': '<20250101'}
154-
>>> format_filter = {'format': 'doc'}
155-
>>> lang_filter = {'lang': 'ru'}
156-
>>> tool = sdk.tools.generative_search(
157-
... search_filters=[date_filter, format_filter, lang_filter],
158-
... description="description when model should call a tool"
159-
... )
160-
161-
"""
162-
163-
search_api = self._sdk.search_api.generative(
164-
site=site,
165-
host=host,
166-
url=url,
167-
enable_nrfm_docs=enable_nrfm_docs,
168-
search_filters=search_filters
169-
)
170-
return search_api.as_tool(description=description)
171-
17246

17347
@doc_from(BaseTools)
17448
class AsyncTools(BaseTools[AsyncFunctionTools]):

src/yandex_ai_studio_sdk/_tools/generative_search.py

Lines changed: 0 additions & 89 deletions
This file was deleted.

src/yandex_ai_studio_sdk/_tools/search_index/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)