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

chore!: Rename model_name to model in the Cohere integration #222

Merged
merged 9 commits into from
Jan 17, 2024
Prev Previous commit
Next Next commit
rename model_name to model in cohere generator
  • Loading branch information
ZanSara committed Jan 16, 2024
commit 008d1aaf71fdfe469a8b8c0d3d32bbcb498e802a
10 changes: 5 additions & 5 deletions integrations/cohere/src/cohere_haystack/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class CohereGenerator:
def __init__(
self,
api_key: Optional[str] = None,
model_name: str = "command",
model: str = "command",
streaming_callback: Optional[Callable] = None,
api_base_url: Optional[str] = None,
**kwargs,
Expand All @@ -41,7 +41,7 @@ def __init__(
Instantiates a `CohereGenerator` component.

:param api_key: The API key for the Cohere API. If not set, it will be read from the COHERE_API_KEY env var.
:param model_name: The name of the model to use. Available models are: [command, command-light, command-nightly,
:param model: The name of the model to use. Available models are: [command, command-light, command-nightly,
command-nightly-light]. Defaults to "command".
:param streaming_callback: A callback function to be called with the streaming response. Defaults to None.
:param api_base_url: The base URL of the Cohere API. Defaults to "https://api.cohere.ai".
Expand Down Expand Up @@ -86,7 +86,7 @@ def __init__(
api_base_url = COHERE_API_URL

self.api_key = api_key
self.model_name = model_name
self.model = model
self.streaming_callback = streaming_callback
self.api_base_url = api_base_url
self.model_parameters = kwargs
Expand All @@ -107,7 +107,7 @@ def to_dict(self) -> Dict[str, Any]:

return default_to_dict(
self,
model_name=self.model_name,
model=self.model,
streaming_callback=callback_name,
api_base_url=self.api_base_url,
**self.model_parameters,
Expand Down Expand Up @@ -142,7 +142,7 @@ def run(self, prompt: str):
:param prompt: The prompt to be sent to the generative model.
"""
response = self.client.generate(
model=self.model_name, prompt=prompt, stream=self.streaming_callback is not None, **self.model_parameters
model=self.model, prompt=prompt, stream=self.streaming_callback is not None, **self.model_parameters
)
if self.streaming_callback:
metadata_dict: Dict[str, Any] = {}
Expand Down