Skip to content
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

Add the Cohere client name to cohere requests #362

Merged
merged 5 commits into from
Mar 29, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ def run(self, documents: List[Document]):
api_url=self.api_base_url,
max_retries=self.max_retries,
timeout=self.timeout,
client_name="haystack",
)
all_embeddings, metadata = asyncio.run(
get_async_response(cohere_client, texts_to_embed, self.model, self.input_type, self.truncate)
Expand All @@ -182,6 +183,7 @@ def run(self, documents: List[Document]):
api_url=self.api_base_url,
max_retries=self.max_retries,
timeout=self.timeout,
client_name="haystack",
)
all_embeddings, metadata = get_response(
cohere_client,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ def run(self, text: str):
api_url=self.api_base_url,
max_retries=self.max_retries,
timeout=self.timeout,
client_name="haystack",
)
embedding, metadata = asyncio.run(
get_async_response(cohere_client, [text], self.model, self.input_type, self.truncate)
Expand All @@ -144,6 +145,7 @@ def run(self, text: str):
api_url=self.api_base_url,
max_retries=self.max_retries,
timeout=self.timeout,
client_name="haystack",
)
embedding, metadata = get_response(cohere_client, [text], self.model, self.input_type, self.truncate)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ def __init__(
self.api_base_url = api_base_url
self.generation_kwargs = generation_kwargs
self.model_parameters = kwargs
self.client = cohere.Client(api_key=self.api_key.resolve_value(), api_url=self.api_base_url)
self.client = cohere.Client(
api_key=self.api_key.resolve_value(), api_url=self.api_base_url, client_name="haystack"
)

def _get_telemetry_data(self) -> Dict[str, Any]:
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def __init__(
self.streaming_callback = streaming_callback
self.api_base_url = api_base_url
self.model_parameters = kwargs
self.client = Client(api_key=self.api_key.resolve_value(), api_url=self.api_base_url)
self.client = Client(api_key=self.api_key.resolve_value(), api_url=self.api_base_url, client_name="haystack")

def to_dict(self) -> Dict[str, Any]:
"""
Expand Down