diff --git a/CHANGELOG.md b/CHANGELOG.md index 16fa33b43..f88fb240f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,34 +1,45 @@ # Changelog +## 4.26 + +- [#296] (https://github.com/cohere-ai/cohere-python/pull/301) + - Chat: add support for prompt_truncation param + ## 4.25 - [#303] (https://github.com/cohere-ai/cohere-python/pull/303) - Allow uploading of evaluation data ## 4.24 + - [#296] (https://github.com/cohere-ai/cohere-python/pull/296) - Allow passing of delimiter for csv - + ## 4.23 + - [#294] (https://github.com/cohere-ai/cohere-python/pull/294) - Allow passing of ParseInfo for datasets ## 4.22 + - [#292] (https://github.com/cohere-ai/cohere-python/pull/292) - Add search query only parameter - - Add documents to generate citations - - Add connectors to generate citations + - Add documents to generate citations + - Add connectors to generate citations - Add citation quality ## 4.21 + - [#287] (https://github.com/cohere-ai/cohere-python/pull/287) - Remove deprecated chat "query" parameter including inside chat_history parameter - Support event-type for chat streaming ## 4.20.2 + - [#284] (https://github.com/cohere-ai/cohere-python/pull/284) - Rename dataset urls to download_urls ## 4.20.1 + - [#279] (https://github.com/cohere-ai/cohere-python/pull/279) - Fix dataset listing key error @@ -64,7 +75,7 @@ - [#262](https://github.com/cohere-ai/cohere-python/pull/262) - Deprecate embed custom models -## 4.15 +## 4.15 - [#256](https://github.com/cohere-ai/cohere-python/pull/256) - Add rerank finetuning endpoint diff --git a/cohere/client.py b/cohere/client.py index 47dfcd2d5..db5261a56 100644 --- a/cohere/client.py +++ b/cohere/client.py @@ -244,6 +244,7 @@ def chat( search_queries_only: Optional[bool] = None, documents: Optional[List[Dict[str, Any]]] = None, citation_quality: Optional[str] = None, + prompt_truncation: Optional[str] = None, connectors: Optional[List[Dict[str, Any]]] = None, ) -> Union[Chat, StreamingChat]: """Returns a Chat object with the query reply. @@ -288,6 +289,7 @@ def chat( ], connectors (List[Dict[str, str]]): (Optional) When specified, the model's reply will be enriched with information found by quering each of the connectors (RAG). Example: connectors=[{"id": "web-search"}] citation_quality (str): (Optional) Dictates the approach taken to generating citations by allowing the user to specify whether they want "accurate" results or "fast" results. Defaults to "accurate". + prompt_truncation (str): (Optional) Dictates how the prompt will be constructed. With `prompt_truncation` set to "AUTO", some elements from `chat_history` and `documents` will be dropped in attempt to construct a prompt that fits within the model's context length limit. With `prompt_truncation` set to "OFF", no elements will be dropped. If the sum of the inputs exceeds the model's context length limit, a `TooManyTokens` error will be returned. Returns: a Chat object if stream=False, or a StreamingChat object if stream=True @@ -376,6 +378,9 @@ def chat( } if citation_quality is not None: json_body["citation_quality"] = citation_quality + if prompt_truncation is not None: + json_body["prompt_truncation"] = prompt_truncation + response = self._request(cohere.CHAT_URL, json=json_body, stream=stream) if stream: diff --git a/cohere/client_async.py b/cohere/client_async.py index ff983d55c..f95e944a7 100644 --- a/cohere/client_async.py +++ b/cohere/client_async.py @@ -226,6 +226,7 @@ async def chat( search_queries_only: Optional[bool] = None, documents: Optional[List[Dict[str, Any]]] = None, citation_quality: Optional[str] = None, + prompt_truncation: Optional[str] = None, connectors: Optional[List[Dict[str, Any]]] = None, ) -> Union[AsyncChat, StreamingChat]: if message is None: @@ -253,6 +254,8 @@ async def chat( } if citation_quality is not None: json_body["citation_quality"] = citation_quality + if prompt_truncation is not None: + json_body["prompt_truncation"] = prompt_truncation response = await self._request(cohere.CHAT_URL, json=json_body, stream=stream) diff --git a/pyproject.toml b/pyproject.toml index 7d9b456eb..8b1695d12 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "cohere" -version = "4.25" +version = "4.26" description = "" authors = ["Cohere"] readme = "README.md"