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

fix: tool calling cohere #3355

Merged
4 changes: 3 additions & 1 deletion autogen/oai/cohere.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"api_type": "cohere",
"model": "command-r-plus",
"api_key": os.environ.get("COHERE_API_KEY")
"client_name": "autogen-cohere", # Optional parameter
}
]}

Expand Down Expand Up @@ -67,6 +68,7 @@ def __init__(self, **kwargs):
"""
# Ensure we have the api_key upon instantiation
self.api_key = kwargs.get("api_key", None)
self.client_name = kwargs.get("client_name") or "autogen-cohere"
marklysze marked this conversation as resolved.
Show resolved Hide resolved
if not self.api_key:
self.api_key = os.getenv("COHERE_API_KEY")

Expand Down Expand Up @@ -157,7 +159,7 @@ def create(self, params: Dict) -> ChatCompletion:
cohere_params["preamble"] = preamble

# We use chat model by default
client = Cohere(api_key=self.api_key, client_name="autogen-cohere")
client = Cohere(api_key=self.api_key, client_name=self.client_name)

# Token counts will be returned
prompt_tokens = 0
Expand Down