From 57a60d2eb272a3905d8119207869ecd153a568e9 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 26 Sep 2024 01:25:27 +0000 Subject: [PATCH] feat: Updated OpenAPI spec --- .../Generated/Cohere.CohereApi.Chatv2.g.cs | 14 ++++++++ .../Generated/Cohere.ICohereApi.Chatv2.g.cs | 4 +++ .../Generated/Cohere.Models.Document.g.cs | 2 +- src/libs/Cohere/openapi.yaml | 33 ++++++++++++++++++- 4 files changed, 51 insertions(+), 2 deletions(-) diff --git a/src/libs/Cohere/Generated/Cohere.CohereApi.Chatv2.g.cs b/src/libs/Cohere/Generated/Cohere.CohereApi.Chatv2.g.cs index 80cb4ab..251d95e 100644 --- a/src/libs/Cohere/Generated/Cohere.CohereApi.Chatv2.g.cs +++ b/src/libs/Cohere/Generated/Cohere.CohereApi.Chatv2.g.cs @@ -7,10 +7,12 @@ public partial class CohereApi { partial void PrepareChatv2Arguments( global::System.Net.Http.HttpClient httpClient, + ref string? xClientName, global::Cohere.Chatv2Request request); partial void PrepareChatv2Request( global::System.Net.Http.HttpClient httpClient, global::System.Net.Http.HttpRequestMessage httpRequestMessage, + string? xClientName, global::Cohere.Chatv2Request request); partial void ProcessChatv2Response( global::System.Net.Http.HttpClient httpClient, @@ -25,11 +27,13 @@ partial void ProcessChatv2ResponseContent( /// Chat with the model
/// Generates a message from the model in response to a provided conversation. To learn how to use the Chat API with Streaming and RAG follow our Text Generation guides. /// + /// /// /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task> Chatv2Async( global::Cohere.Chatv2Request request, + string? xClientName = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -38,8 +42,14 @@ partial void ProcessChatv2ResponseContent( client: _httpClient); PrepareChatv2Arguments( httpClient: _httpClient, + xClientName: ref xClientName, request: request); + if (xClientName != default) + { + _httpClient.DefaultRequestHeaders.TryAddWithoutValidation("X-Client-Name", xClientName); + } + var __pathBuilder = new PathBuilder( path: "/v2/chat", baseUri: _httpClient.BaseAddress); @@ -60,6 +70,7 @@ partial void ProcessChatv2ResponseContent( PrepareChatv2Request( httpClient: _httpClient, httpRequestMessage: httpRequest, + xClientName: xClientName, request: request); using var response = await _httpClient.SendAsync( @@ -103,6 +114,7 @@ partial void ProcessChatv2ResponseContent( /// Chat with the model
/// Generates a message from the model in response to a provided conversation. To learn how to use the Chat API with Streaming and RAG follow our Text Generation guides. /// + /// /// /// The name of a compatible [Cohere model](https://docs.cohere.com/docs/models) (such as command-r or command-r-plus) or the ID of a [fine-tuned](https://docs.cohere.com/docs/chat-fine-tuning) model. /// @@ -174,6 +186,7 @@ partial void ProcessChatv2ResponseContent( public async global::System.Threading.Tasks.Task> Chatv2Async( string model, global::System.Collections.Generic.IList messages, + string? xClientName = default, global::System.Collections.Generic.IList? tools = default, global::System.Collections.Generic.IList>? documents = default, global::Cohere.CitationOptions? citationOptions = default, @@ -209,6 +222,7 @@ partial void ProcessChatv2ResponseContent( }; return await Chatv2Async( + xClientName: xClientName, request: request, cancellationToken: cancellationToken).ConfigureAwait(false); } diff --git a/src/libs/Cohere/Generated/Cohere.ICohereApi.Chatv2.g.cs b/src/libs/Cohere/Generated/Cohere.ICohereApi.Chatv2.g.cs index a771b00..b77eae4 100644 --- a/src/libs/Cohere/Generated/Cohere.ICohereApi.Chatv2.g.cs +++ b/src/libs/Cohere/Generated/Cohere.ICohereApi.Chatv2.g.cs @@ -8,17 +8,20 @@ public partial interface ICohereApi /// Chat with the model
/// Generates a message from the model in response to a provided conversation. To learn how to use the Chat API with Streaming and RAG follow our Text Generation guides. /// + /// /// /// The token to cancel the operation with /// global::System.Threading.Tasks.Task> Chatv2Async( global::Cohere.Chatv2Request request, + string? xClientName = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Chat with the model
/// Generates a message from the model in response to a provided conversation. To learn how to use the Chat API with Streaming and RAG follow our Text Generation guides. ///
+ /// /// /// The name of a compatible [Cohere model](https://docs.cohere.com/docs/models) (such as command-r or command-r-plus) or the ID of a [fine-tuned](https://docs.cohere.com/docs/chat-fine-tuning) model. /// @@ -90,6 +93,7 @@ public partial interface ICohereApi global::System.Threading.Tasks.Task> Chatv2Async( string model, global::System.Collections.Generic.IList messages, + string? xClientName = default, global::System.Collections.Generic.IList? tools = default, global::System.Collections.Generic.IList>? documents = default, global::Cohere.CitationOptions? citationOptions = default, diff --git a/src/libs/Cohere/Generated/Cohere.Models.Document.g.cs b/src/libs/Cohere/Generated/Cohere.Models.Document.g.cs index 56a0b56..03824a4 100644 --- a/src/libs/Cohere/Generated/Cohere.Models.Document.g.cs +++ b/src/libs/Cohere/Generated/Cohere.Models.Document.g.cs @@ -18,7 +18,7 @@ public sealed partial class Document public required global::Cohere.DocumentData Data { get; set; } /// - /// Unique identifier for this document which will be referenced in citations. If not provided an ID will be automatically generated + /// Unique identifier for this document which will be referenced in citations. If not provided an ID will be automatically generated. /// [global::System.Text.Json.Serialization.JsonPropertyName("id")] public string? Id { get; set; } diff --git a/src/libs/Cohere/openapi.yaml b/src/libs/Cohere/openapi.yaml index f42a900..b5b0e8e 100644 --- a/src/libs/Cohere/openapi.yaml +++ b/src/libs/Cohere/openapi.yaml @@ -739,6 +739,8 @@ paths: summary: Chat with the model description: "Generates a message from the model in response to a provided conversation. To learn how to use the Chat API with Streaming and RAG follow our Text Generation guides.\n" operationId: chatv2 + parameters: + - $ref: '#/components/parameters/RequestSource' requestBody: content: application/json: @@ -894,6 +896,12 @@ paths: - sdk: python name: Async code: "import cohere\nimport asyncio\n\nco = cohere.AsyncClientV2(\"<>\")\n\n\nasync def main():\n response = await co.chat(\n model=\"command-r-plus\",\n messages=[\n cohere.v2.ChatMessage2_User(\n content=\"hello world!\"\n )\n ]\n )\n\n print(response)\n\nasyncio.run(main())\n" + - sdk: java + name: Default + code: "/* (C)2024 */\npackage chatv2post;\n\nimport com.cohere.api.Cohere;\nimport com.cohere.api.resources.v2.requests.V2ChatRequest;\nimport com.cohere.api.types.*;\nimport java.util.List;\n\npublic class Default {\n public static void main(String[] args) {\n Cohere cohere = Cohere.builder().token(\"<>\").clientName(\"snippet\").build();\n\n ChatResponse response =\n cohere.v2()\n .chat(\n V2ChatRequest.builder()\n .model(\"command-r-plus\")\n .messages(\n List.of(\n ChatMessageV2.user(\n UserMessage.builder()\n .content(\n UserMessageContent\n .of(\n \"Who discovered\"\n + \" gravity?\"))\n .build()),\n ChatMessageV2.assistant(\n AssistantMessage.builder()\n .content(\n AssistantMessageContent\n .of(\n \"The man\"\n + \" who is\"\n + \" widely\"\n + \" credited\"\n + \" with\"\n + \" discovering\"\n + \" gravity\"\n + \" is Sir\"\n + \" Isaac\"\n + \" Newton\"))\n .build())))\n .build());\n\n System.out.println(response);\n }\n}\n" + - sdk: curl + name: Default + code: "curl --request POST \\\n --url https://api.cohere.com/v1/chat \\\n --header 'accept: application/json' \\\n --header 'content-type: application/json' \\\n --header \"Authorization: bearer $CO_API_KEY\" \\\n --data '{\n \"model\": \"command-r-plus\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"message\": \"Hello world!\"\n }\n ],\n }'" request: model: command-r messages: @@ -923,6 +931,12 @@ paths: - sdk: python name: Documents code: "import cohere\n\nco = cohere.ClientV2(\"<>\")\n\nresponse = co.chat(\n model=\"command-r-plus\",\n documents=[{'id': '1', 'data': {'text': 'Cohere is the best!', 'title': 'The best'}}],\n messages=[\n {\n \"role\": \"user\",\n \"content\": \"Who's the best?\"\n }\n ]\n)\n\nprint(response)\n" + - sdk: java + name: Documents + code: "/* (C)2024 */\npackage chatv2post;\n\nimport com.cohere.api.Cohere;\nimport com.cohere.api.resources.v2.requests.V2ChatRequest;\nimport com.cohere.api.resources.v2.types.V2ChatRequestDocumentsItem;\nimport com.cohere.api.types.*;\nimport java.util.List;\n\npublic class Documents {\n public static void main(String[] args) {\n Cohere cohere = Cohere.builder().token(\"<>\").clientName(\"snippet\").build();\n\n ChatResponse response =\n cohere.v2()\n .chat(\n V2ChatRequest.builder()\n .model(\"command-r-plus\")\n .messages(\n List.of(\n ChatMessageV2.user(\n UserMessage.builder()\n .content(\n UserMessageContent\n .of(\n \"Who is\"\n + \" the most\"\n + \" popular?\"))\n .build())))\n .documents(\n List.of(\n V2ChatRequestDocumentsItem.of(\n \"↓ Skip to Main Content\\n\\n\"\n + \"Music industry – One step\"\n + \" closer to being\"\n + \" accurate\\n\\n\"\n + \"CSPC: Backstreet Boys\"\n + \" Popularity Analysis\\n\\n\"\n + \"Hernán Lopez Posted on\"\n + \" February 9, 2017 Posted in\"\n + \" CSPC 72 Comments Tagged\"\n + \" with Backstreet Boys, Boy\"\n + \" band\\n\\n\"\n + \"At one point, Backstreet\"\n + \" Boys defined success:\"\n + \" massive albums sales across\"\n + \" the globe, great singles\"\n + \" sales, plenty of chart\"\n + \" topping releases, hugely\"\n + \" hyped tours and tremendous\"\n + \" media coverage.\\n\\n\"\n + \"It is true that they\"\n + \" benefited from\"\n + \" extraordinarily good market\"\n + \" conditions in all markets.\"\n + \" After all, the all-time\"\n + \" record year for the music\"\n + \" business, as far as\"\n + \" revenues in billion dollars\"\n + \" are concerned, was actually\"\n + \" 1999. That is, back when\"\n + \" this five men group was at\"\n + \" its peak.\"),\n V2ChatRequestDocumentsItem.of(\n \"↓ Skip to Main Content\\n\\n\"\n + \"Music industry – One step\"\n + \" closer to being\"\n + \" accurate\\n\\n\"\n + \"CSPC: NSYNC Popularity\"\n + \" Analysis\\n\\n\"\n + \"MJD Posted on February 9,\"\n + \" 2018 Posted in CSPC 27\"\n + \" Comments Tagged with Boy\"\n + \" band, N'Sync\\n\\n\"\n + \"At the turn of the\"\n + \" millennium three teen acts\"\n + \" were huge in the US, the\"\n + \" Backstreet Boys, Britney\"\n + \" Spears and NSYNC. The\"\n + \" latter is the only one we\"\n + \" haven’t study so far. It\"\n + \" took 15 years and Adele to\"\n + \" break their record of 2,4\"\n + \" million units sold of No\"\n + \" Strings Attached in its\"\n + \" first week alone.\\n\\n\"\n + \"It wasn’t a fluke, as the\"\n + \" second fastest selling\"\n + \" album of the Soundscan era\"\n + \" prior 2015, was also theirs\"\n + \" since Celebrity debuted\"\n + \" with 1,88 million units\"\n + \" sold.\"),\n V2ChatRequestDocumentsItem.of(\n \" 1997, 1998, 2000 and 2001 also\"\n + \" rank amongst some of the\"\n + \" very best years.\\n\\n\"\n + \"Yet the way many music\"\n + \" consumers – especially\"\n + \" teenagers and young women’s\"\n + \" – embraced their output\"\n + \" deserves its own chapter.\"\n + \" If Jonas Brothers and more\"\n + \" recently One Direction\"\n + \" reached a great level of\"\n + \" popularity during the past\"\n + \" decade, the type of success\"\n + \" achieved by Backstreet Boys\"\n + \" is in a completely\"\n + \" different level as they\"\n + \" really dominated the\"\n + \" business for a few years\"\n + \" all over the world,\"\n + \" including in some countries\"\n + \" that were traditionally\"\n + \" hard to penetrate for\"\n + \" Western artists.\\n\\n\"\n + \"We will try to analyze the\"\n + \" extent of that hegemony\"\n + \" with this new article with\"\n + \" final results which will\"\n + \" more than surprise many\"\n + \" readers.\"),\n V2ChatRequestDocumentsItem.of(\n \" Was the teen group led by Justin\"\n + \" Timberlake really that big?\"\n + \" Was it only in the US where\"\n + \" they found success? Or were\"\n + \" they a global\"\n + \" phenomenon?\\n\\n\"\n + \"As usual, I’ll be using the\"\n + \" Commensurate Sales to\"\n + \" Popularity Concept in order\"\n + \" to relevantly gauge their\"\n + \" results. This concept will\"\n + \" not only bring you sales\"\n + \" information for all NSYNC‘s\"\n + \" albums, physical and\"\n + \" download singles, as well\"\n + \" as audio and video\"\n + \" streaming, but it will also\"\n + \" determine their true\"\n + \" popularity. If you are not\"\n + \" yet familiar with the CSPC\"\n + \" method, the next page\"\n + \" explains it with a short\"\n + \" video. I fully recommend\"\n + \" watching the video before\"\n + \" getting into the sales\"\n + \" figures.\")))\n .build());\n System.out.println(response);\n }\n}\n" + - sdk: curl + name: Documents + code: "curl --request POST \\\n --url https://api.cohere.com/v1/chat \\\n --header 'accept: application/json' \\\n --header 'content-type: application/json' \\\n --header \"Authorization: bearer $CO_API_KEY\" \\\n --data '{\n \"model\": \"command-r-plus\",\n \"documents\": [\n {\n \"id\": \"1\",\n \"data\": \"Cohere is the best!\"\n }\n ],\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": \"Who's the best?\"\n }\n ]\n }\n ]\n }'" request: model: command-r documents: @@ -1056,6 +1070,13 @@ paths: - sdk: python name: Streaming code: "import cohere\n\nco = cohere.ClientV2(\"<>\")\n\nresponse = co.chat_stream(\n model=\"command-r-plus\",\n messages=[\n {\n \"role\": \"user\",\n \"content\": \"hello world!\"\n }\n ]\n)\n\nfor event in response:\n if event.type == \"content-delta\":\n print(event.delta.message.content.text, end='')\n" + - sdk: java + name: Streaming + code: "/* (C)2024 */\npackage chatv2post;\n\nimport com.cohere.api.Cohere;\nimport com.cohere.api.resources.v2.requests.V2ChatStreamRequest;\nimport com.cohere.api.types.*;\nimport java.util.List;\n\npublic class Stream {\n public static void main(String[] args) {\n Cohere cohere = Cohere.builder().token(\"<>\").clientName(\"snippet\").build();\n\n Iterable response =\n cohere.v2()\n .chatStream(\n V2ChatStreamRequest.builder()\n .model(\"command-r-plus\")\n .messages(\n List.of(\n ChatMessageV2.user(\n UserMessage.builder()\n .content(\n UserMessageContent\n .of(\n \"Who discovered\"\n + \" gravity?\"))\n .build()),\n ChatMessageV2.assistant(\n AssistantMessage.builder()\n .content(\n AssistantMessageContent\n .of(\n \"The man\"\n + \" who is\"\n + \" widely\"\n + \" credited\"\n + \" with\"\n + \" discovering\"\n + \" gravity\"\n + \" is Sir\"\n + \" Isaac\"\n + \" Newton\"))\n .build())))\n .build());\n\n for (StreamedChatResponseV2 chatResponse : response) {\n if (chatResponse.isContentDelta()) {\n System.out.println(\n chatResponse\n .getContentDelta()\n .flatMap(ChatContentDeltaEvent::getDelta)\n .flatMap(ChatContentDeltaEventDelta::getMessage)\n .flatMap(ChatContentDeltaEventDeltaMessage::getContent)\n .flatMap(ChatContentDeltaEventDeltaMessageContent::getText)\n .orElse(\"\"));\n }\n }\n\n System.out.println(response);\n }\n}\n" + - sdk: curl + name: Streaming + code: + $ref: ./snippets/curl/chat-v2-post/streaming.sh request: model: command-r messages: @@ -1175,6 +1196,12 @@ paths: - sdk: python name: Tools code: "import cohere\n\nco = cohere.Client(\"<>\")\n\nresponse = co.chat(\n model=\"command-r-plus\",\n tools=[\n cohere.ToolV2(type='function', function={\n \"name\": 'query_daily_sales_report',\n \"description\": 'Connects to a database to retrieve overall sales volumes and sales information for a given day.',\n \"parameters\": {\n \"day\": {\n \"description\": 'Retrieves sales data for this day, formatted as YYYY-MM-DD.',\n \"type\": 'str',\n \"required\": True,\n },\n }\n }),\n cohere.ToolV2(type='function', function={\n \"name\": 'query_product_catalog',\n \"description\": 'Connects to a a product catalog with information about all the products being sold, including categories, prices, and stock levels.',\n \"parameters\": {\n \"category\": {\n \"description\": 'Retrieves product information data for all products in this category.',\n \"type\": 'str',\n \"required\": True,\n },\n }\n })\n ],\n messages=[\n {\n \"role\": \"user\",\n \"content\": \"Can you provide a sales summary for 29th September 2023, and also give me some details about the products in the 'Electronics' category, for example their prices and stock levels?\"\n }\n ]\n)\n\nprint(response)\n" + - sdk: java + name: Tools + code: "/* (C)2024 */\npackage chatv2post;\n\nimport com.cohere.api.Cohere;\nimport com.cohere.api.resources.v2.requests.V2ChatRequest;\nimport com.cohere.api.types.*;\nimport java.util.List;\nimport java.util.Map;\n\npublic class Tools {\n public static void main(String[] args) {\n Cohere cohere = Cohere.builder().token(\"<>\").clientName(\"snippet\").build();\n\n ChatResponse response =\n cohere.v2()\n .chat(\n V2ChatRequest.builder()\n .model(\"command-r-plus\")\n .tools(\n List.of(\n ToolV2.builder()\n .function(\n ToolV2Function.builder()\n .name(\n \"query_daily_sales_report\")\n .description(\n \"Connects\"\n + \" to a\"\n + \" database\"\n + \" to retrieve\"\n + \" overall\"\n + \" sales\"\n + \" volumes\"\n + \" and sales\"\n + \" information\"\n + \" for a\"\n + \" given\"\n + \" day.\")\n .parameters(\n Map.of(\n \"day\",\n ToolParameterDefinitionsValue\n .builder()\n .type(\n \"str\")\n .description(\n \"Retrieves\"\n + \" sales\"\n + \" data\"\n + \" for this\"\n + \" day,\"\n + \" formatted\"\n + \" as YYYY-MM-DD.\")\n .required(\n true)\n .build()))\n .build())\n .build(),\n ToolV2.builder()\n .function(\n ToolV2Function.builder()\n .name(\n \"query_product_catalog\")\n .description(\"Connects\"\n + \" to a\"\n + \" a product\"\n + \" catalog\"\n + \" with information\"\n + \" about all\"\n + \" the products being\"\n + \" sold,\"\n + \" including\"\n + \" categories,\"\n + \" prices, and stock\"\n + \" levels.\")\n .parameters(\n Map.of(\n \"category\",\n ToolParameterDefinitionsValue\n .builder()\n .type(\n \"str\")\n .description(\n \"Retrieves\"\n + \" product\"\n + \" information\"\n + \" data\"\n + \" for all\"\n + \" products\"\n + \" in this\"\n + \" category.\")\n .required(\n true)\n .build()))\n .build())\n .build())\n )\n .build());\n\n System.out.println(response);\n }\n}\n" + - sdk: curl + name: Tools + code: "curl --request POST \\\n --url https://api.cohere.com/v1/chat \\\n --header 'accept: application/json' \\\n --header 'content-type: application/json' \\\n --header \"Authorization: bearer $CO_API_KEY\" \\\n --data '{\n \"model\": \"command-r-plus\",\n \"tools\": [\n {\n \"type\": \"function\",\n \"function\": {\n \"name\": \"query_daily_sales_report\",\n \"description\": \"Connects to a database to retrieve overall sales volumes and sales information for a given day.\",\n \"parameters\": {\n \"day\": {\n \"description\": \"Retrieves sales data for this day, formatted as YYYY-MM-DD.\",\n \"type\": \"str\",\n \"required\": true\n }\n }\n }\n },\n {\n \"type\": \"function\",\n \"function\": {\n \"name\": \"query_product_catalog\",\n \"description\": \"Connects to a a product catalog with information about all the products being sold, including categories, prices, and stock levels.\",\n \"parameters\": {\n \"category\": {\n \"description\": \"Retrieves product information data for all products in this category.\",\n \"type\": \"str\",\n \"required\": true\n }\n }\n }\n }\n ],\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Can you provide a sales summary for 29th September 2023, and also give me some details about the products in the 'Electronics' category, for example their prices and stock levels?\"\n }\n ]\n }'\n" request: model: command-r messages: @@ -9795,6 +9822,7 @@ components: - $ref: '#/components/schemas/TextContent' description: A Content block which contains information about the content type and the content itself. UserMessage: + title: User Message required: - role - content @@ -9866,6 +9894,7 @@ components: $ref: '#/components/schemas/Source' description: Citation information containing sources and the text cited. AssistantMessage: + title: Assistant Message required: - role type: object @@ -9893,6 +9922,7 @@ components: $ref: '#/components/schemas/Citation' description: A message from the assistant role can contain text and tool call information. SystemMessage: + title: System Message required: - role - content @@ -9923,7 +9953,7 @@ components: x-fern-type: 'map' id: type: string - description: Unique identifier for this document which will be referenced in citations. If not provided an ID will be automatically generated + description: Unique identifier for this document which will be referenced in citations. If not provided an ID will be automatically generated. description: "Relevant information that could be used by the model to generate a more accurate reply.\nThe content of each document are generally short (should be under 300 words). Metadata should be used to provide additional information, both the key name and the value will be\npassed to the model.\n" DocumentContent: required: @@ -9944,6 +9974,7 @@ components: - $ref: '#/components/schemas/DocumentContent' description: A content block which contains information about the content of a tool result ToolMessageV2: + title: Tool Message required: - role - tool_call_id