Skip to content

Commit

Permalink
Remove DiscussService and TextService (#512)
Browse files Browse the repository at this point in the history
* Remove DiscussService and TextService

* Remove references to TextService in answer.py, remove refs in client.py

* Remove reference from test case for client

* Modify text_types.py for embeddings

* Delete certain markdown files, update other mds

* Delete generate emb md

* Fix tests

* Revert "Delete generate emb md"

This reverts commit d4177f7.

* Revert "Delete certain markdown files, update other mds"

This reverts commit dca0b1f.

* Reformat

* Added other clients to test_client parameters

* Update google/generativeai/client.py

---------

Co-authored-by: Mark Daoust <[email protected]>
  • Loading branch information
shilpakancharla and MarkDaoust authored Aug 22, 2024
1 parent 526fe03 commit 7342a62
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 2,257 deletions.
10 changes: 0 additions & 10 deletions google/generativeai/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@

from google.generativeai.client import configure

from google.generativeai.discuss import chat
from google.generativeai.discuss import chat_async
from google.generativeai.discuss import count_message_tokens

from google.generativeai.embedding import embed_content
from google.generativeai.embedding import embed_content_async

Expand All @@ -77,19 +73,13 @@
from google.generativeai.operations import list_operations
from google.generativeai.operations import get_operation

from google.generativeai.text import generate_text
from google.generativeai.text import generate_embeddings
from google.generativeai.text import count_text_tokens

from google.generativeai.types import GenerationConfig

__version__ = version.__version__

del discuss
del embedding
del files
del generative_models
del text
del models
del client
del operations
Expand Down
4 changes: 2 additions & 2 deletions google/generativeai/answer.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def generate_answer(
answer_style: Style in which the grounded answer should be returned.
safety_settings: Safety settings for generated output. Defaults to None.
temperature: Controls the randomness of the output.
client: If you're not relying on a default client, you pass a `glm.TextServiceClient` instead.
client: If you're not relying on a default client, you pass a `glm.GenerativeServiceClient` instead.
request_options: Options for the request.
Returns:
Expand Down Expand Up @@ -337,7 +337,7 @@ async def generate_answer_async(
answer_style: Style in which the grounded answer should be returned.
safety_settings: Safety settings for generated output. Defaults to None.
temperature: Controls the randomness of the output.
client: If you're not relying on a default client, you pass a `glm.TextServiceClient` instead.
client: If you're not relying on a default client, you pass a `glm.GenerativeServiceClient` instead.
Returns:
A `types.Answer` containing the model's text answer response.
Expand Down
18 changes: 1 addition & 17 deletions google/generativeai/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,6 @@ async def create_file(self, *args, **kwargs):
class _ClientManager:
client_config: dict[str, Any] = dataclasses.field(default_factory=dict)
default_metadata: Sequence[tuple[str, str]] = ()

discuss_client: glm.DiscussServiceClient | None = None
discuss_async_client: glm.DiscussServiceAsyncClient | None = None
clients: dict[str, Any] = dataclasses.field(default_factory=dict)

def configure(
Expand All @@ -119,7 +116,7 @@ def configure(
api_key: str | None = None,
credentials: ga_credentials.Credentials | dict | None = None,
# The user can pass a string to choose `rest` or `grpc` or 'grpc_asyncio'.
# See `_transport_registry` in `DiscussServiceClientMeta`.
# See _transport_registry in the google.ai.generativelanguage package.
# Since the transport classes align with the client classes it wouldn't make
# sense to accept a `Transport` object here even though the client classes can.
# We could accept a dict since all the `Transport` classes take the same args,
Expand Down Expand Up @@ -281,7 +278,6 @@ def configure(
api_key: str | None = None,
credentials: ga_credentials.Credentials | dict | None = None,
# The user can pass a string to choose `rest` or `grpc` or 'grpc_asyncio'.
# See `_transport_registry` in `DiscussServiceClientMeta`.
# Since the transport classes align with the client classes it wouldn't make
# sense to accept a `Transport` object here even though the client classes can.
# We could accept a dict since all the `Transport` classes take the same args,
Expand Down Expand Up @@ -326,14 +322,6 @@ def get_default_cache_client() -> glm.CacheServiceClient:
return _client_manager.get_default_client("cache")


def get_default_discuss_client() -> glm.DiscussServiceClient:
return _client_manager.get_default_client("discuss")


def get_default_discuss_async_client() -> glm.DiscussServiceAsyncClient:
return _client_manager.get_default_client("discuss_async")


def get_default_file_client() -> glm.FilesServiceClient:
return _client_manager.get_default_client("file")

Expand All @@ -350,10 +338,6 @@ def get_default_generative_async_client() -> glm.GenerativeServiceAsyncClient:
return _client_manager.get_default_client("generative_async")


def get_default_text_client() -> glm.TextServiceClient:
return _client_manager.get_default_client("text")


def get_default_operations_client() -> operations_v1.OperationsClient:
return _client_manager.get_default_client("operations")

Expand Down
Loading

0 comments on commit 7342a62

Please sign in to comment.