From d6a753703d811657ca70f17667a33b6eea654fa9 Mon Sep 17 00:00:00 2001 From: platform-endpoints Date: Mon, 19 Aug 2024 13:17:00 +0000 Subject: [PATCH] Add spec changes Co-authored-by: billytrend-cohere <144115527+billytrend-cohere@users.noreply.github.com> --- cohere-openapi.yaml | 7286 ++++++++++++++++++++----------------------- 1 file changed, 3386 insertions(+), 3900 deletions(-) diff --git a/cohere-openapi.yaml b/cohere-openapi.yaml index e27c73590..b62afef4d 100644 --- a/cohere-openapi.yaml +++ b/cohere-openapi.yaml @@ -144,947 +144,927 @@ paths: tool-calls-generation: "#/components/schemas/ChatToolCallsGenerationEvent" stream-end: "#/components/schemas/ChatStreamEndEvent" tool-calls-chunk: "#/components/schemas/ChatToolCallsChunkEvent" - x-readme: - samples-languages: - - python - - java - - curl - - node - - go - code-samples: - - language: go - name: Default - install: go get github.com/cohere-ai/cohere-go/v2 - code: > - package main - - - import ( - "context" - "log" - - cohere "github.com/cohere-ai/cohere-go/v2" - client "github.com/cohere-ai/cohere-go/v2/client" - ) - - - func main() { - co := client.NewClient(client.WithToken("<>")) - - resp, err := co.Chat( - context.TODO(), - &cohere.ChatRequest{ - ChatHistory: []*cohere.Message{ - { - Role: "USER", - User: &cohere.ChatMessage{ - Message: "Who discovered gravity?", - }, - }, - { - Role: "CHATBOT", - Chatbot: &cohere.ChatMessage{ - Message: "The man who is widely credited with discovering gravity is Sir Isaac Newton", - }, - }}, - Message: "What year was he born?", - Connectors: []*cohere.ChatConnector{ - {Id: "web-search"}, - }, - }, - ) - - if err != nil { - log.Fatal(err) - } - - log.Printf("%+v", resp) - } - - language: go - name: Documents - install: go get github.com/cohere-ai/cohere-go/v2 - code: > - package main - - - import ( - "context" - "errors" - "io" - "log" - - cohere "github.com/cohere-ai/cohere-go/v2" - client "github.com/cohere-ai/cohere-go/v2/client" - ) - - - func main() { - co := client.NewClient(client.WithToken("<>")) - - resp, err := co.ChatStream( - context.TODO(), - &cohere.ChatStreamRequest{ - ChatHistory: []*cohere.Message{ - { - Role: "USER", - User: &cohere.ChatMessage{ - Message: "Who discovered gravity?", - }, - }, - { - Role: "CHATBOT", - Chatbot: &cohere.ChatMessage{ - Message: "The man who is widely credited with discovering gravity is Sir Isaac Newton", - }, - }}, - Message: "What year was he born?", - Connectors: []*cohere.ChatConnector{ - {Id: "web-search"}, - }, - }, - ) - - if err != nil { - log.Fatal(err) - } - - // Make sure to close the stream when you're done reading. - // This is easily handled with defer. - defer resp.Close() - - for { - message, err := resp.Recv() - - if errors.Is(err, io.EOF) { - // An io.EOF error means the server is done sending messages - // and should be treated as a success. - break - } - - if message.TextGeneration != nil { - log.Printf("%+v", resp) - } - } - - } - - language: go - name: Streaming - install: go get github.com/cohere-ai/cohere-go/v2 - code: > - package main - - - import ( - "context" - "errors" - "io" - "log" - - cohere "github.com/cohere-ai/cohere-go/v2" - client "github.com/cohere-ai/cohere-go/v2/client" - ) - - - func main() { - co := client.NewClient(client.WithToken("<>")) - - resp, err := co.ChatStream( - context.TODO(), - &cohere.ChatStreamRequest{ - ChatHistory: []*cohere.Message{ - { - Role: "USER", - User: &cohere.ChatMessage{ - Message: "Who discovered gravity?", - }, - }, - { - Role: "CHATBOT", - Chatbot: &cohere.ChatMessage{ - Message: "The man who is widely credited with discovering gravity is Sir Isaac Newton", - }, - }}, - Message: "What year was he born?", - Connectors: []*cohere.ChatConnector{ - {Id: "web-search"}, - }, - }, - ) - - if err != nil { - log.Fatal(err) - } - - // Make sure to close the stream when you're done reading. - // This is easily handled with defer. - defer resp.Close() - - for { - message, err := resp.Recv() - - if errors.Is(err, io.EOF) { - // An io.EOF error means the server is done sending messages - // and should be treated as a success. - break - } - - if message.TextGeneration != nil { - log.Printf("%+v", resp) - } - } - - } - - language: go - name: Tools - install: go get github.com/cohere-ai/cohere-go/v2 - code: > - package main - + x-fern-examples: + - code-samples: + - sdk: go + name: Default + code: > + package main + + + import ( + "context" + "log" + + cohere "github.com/cohere-ai/cohere-go/v2" + client "github.com/cohere-ai/cohere-go/v2/client" + ) + + + func main() { + co := client.NewClient(client.WithToken("<>")) + + resp, err := co.Chat( + context.TODO(), + &cohere.ChatRequest{ + ChatHistory: []*cohere.Message{ + { + Role: "USER", + User: &cohere.ChatMessage{ + Message: "Who discovered gravity?", + }, + }, + { + Role: "CHATBOT", + Chatbot: &cohere.ChatMessage{ + Message: "The man who is widely credited with discovering gravity is Sir Isaac Newton", + }, + }}, + Message: "What year was he born?", + Connectors: []*cohere.ChatConnector{ + {Id: "web-search"}, + }, + }, + ) + + if err != nil { + log.Fatal(err) + } + + log.Printf("%+v", resp) + } + - sdk: typescript + name: Default + code: > + const { CohereClient } = require('cohere-ai'); - import ( - "context" - "log" - cohere "github.com/cohere-ai/cohere-go/v2" - client "github.com/cohere-ai/cohere-go/v2/client" - ) + const cohere = new CohereClient({ + token: '<>', + }); - func main() { - co := client.NewClient(client.WithToken("<>")) + (async () => { + const response = await cohere.chat({ + chatHistory: [ + { role: 'USER', message: 'Who discovered gravity?' }, + { + role: 'CHATBOT', + message: 'The man who is widely credited with discovering gravity is Sir Isaac Newton', + }, + ], + message: 'What year was he born?', + // perform web search before answering the question. You can also use your own custom connector. + connectors: [{ id: 'web-search' }], + }); - resp, err := co.Chat( - context.TODO(), - &cohere.ChatRequest{ - Message: "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?", - Tools: []*cohere.Tool{ - { - Name: "query_daily_sales_report", - Description: "Connects to a database to retrieve overall sales volumes and sales information for a given day.", - ParameterDefinitions: map[string]*cohere.ToolParameterDefinitionsValue{ - "day": { - Description: cohere.String("Retrieves sales data for this day, formatted as YYYY-MM-DD."), - Type: "str", - Required: cohere.Bool(true), - }, - }, - }, - { - Name: "query_product_catalog", - Description: "Connects to a a product catalog with information about all the products being sold, including categories, prices, and stock levels.", - ParameterDefinitions: map[string]*cohere.ToolParameterDefinitionsValue{ - "category": { - Description: cohere.String("Retrieves product information data for all products in this category."), - Type: "str", - Required: cohere.Bool(true), - }, - }, - }, - }, - }, - ) + console.log(response); + })(); + - sdk: java + name: Default + code: > + /* (C)2024 */ - if err != nil { - log.Fatal(err) - } + package chatpost; - log.Printf("%+v", resp) - } - - language: node - name: Default - install: npm i cohere-ai - code: > - const { CohereClient } = require('cohere-ai'); + import com.cohere.api.Cohere; - const cohere = new CohereClient({ - token: '<>', - }); + import com.cohere.api.requests.ChatRequest; + import com.cohere.api.types.ChatMessage; - (async () => { - const response = await cohere.chat({ - chatHistory: [ - { role: 'USER', message: 'Who discovered gravity?' }, - { - role: 'CHATBOT', - message: 'The man who is widely credited with discovering gravity is Sir Isaac Newton', - }, - ], - message: 'What year was he born?', - // perform web search before answering the question. You can also use your own custom connector. - connectors: [{ id: 'web-search' }], - }); + import com.cohere.api.types.ChatMessageRole; - console.log(response); - })(); - - language: node - name: Documents - install: npm i cohere-ai - code: > - const { CohereClient } = require('cohere-ai'); + import com.cohere.api.types.NonStreamedChatResponse; + import java.util.List; - const cohere = new CohereClient({ - token: '<>', - }); + public class Default { + public static void main(String[] args) { + Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); - (async () => { - const response = await cohere.chat({ - message: 'Who is more popular: Nsync or Backstreet Boys?', - documents: [ - { - title: 'CSPC: Backstreet Boys Popularity Analysis - ChartMasters', - snippet: - '↓ Skip to Main Content\n\nMusic industry – One step closer to being accurate\n\nCSPC: Backstreet Boys Popularity Analysis\n\nHernán Lopez Posted on February 9, 2017 Posted in CSPC 72 Comments Tagged with Backstreet Boys, Boy band\n\nAt one point, Backstreet Boys defined success: massive albums sales across the globe, great singles sales, plenty of chart topping releases, hugely hyped tours and tremendous media coverage.\n\nIt is true that they benefited from extraordinarily good market conditions in all markets. After all, the all-time record year for the music business, as far as revenues in billion dollars are concerned, was actually 1999. That is, back when this five men group was at its peak.', - }, - { - title: 'CSPC: NSYNC Popularity Analysis - ChartMasters', - snippet: - "↓ Skip to Main Content\n\nMusic industry – One step closer to being accurate\n\nCSPC: NSYNC Popularity Analysis\n\nMJD Posted on February 9, 2018 Posted in CSPC 27 Comments Tagged with Boy band, N'Sync\n\nAt the turn of the millennium three teen acts were huge in the US, the Backstreet Boys, Britney Spears and NSYNC. The latter is the only one we haven’t study so far. It took 15 years and Adele to break their record of 2,4 million units sold of No Strings Attached in its first week alone.\n\nIt wasn’t a fluke, as the second fastest selling album of the Soundscan era prior 2015, was also theirs since Celebrity debuted with 1,88 million units sold.", - }, - { - title: 'CSPC: Backstreet Boys Popularity Analysis - ChartMasters', - snippet: - ' 1997, 1998, 2000 and 2001 also rank amongst some of the very best years.\n\nYet the way many music consumers – especially teenagers and young women’s – embraced their output deserves its own chapter. If Jonas Brothers and more recently One Direction reached a great level of popularity during the past decade, the type of success achieved by Backstreet Boys is in a completely different level as they really dominated the business for a few years all over the world, including in some countries that were traditionally hard to penetrate for Western artists.\n\nWe will try to analyze the extent of that hegemony with this new article with final results which will more than surprise many readers.', - }, - { - title: 'CSPC: NSYNC Popularity Analysis - ChartMasters', - snippet: - ' Was the teen group led by Justin Timberlake really that big? Was it only in the US where they found success? Or were they a global phenomenon?\n\nAs usual, I’ll be using the Commensurate Sales to Popularity Concept in order to relevantly gauge their results. This concept will not only bring you sales information for all NSYNC‘s albums, physical and download singles, as well as audio and video streaming, but it will also determine their true popularity. If you are not yet familiar with the CSPC method, the next page explains it with a short video. I fully recommend watching the video before getting into the sales figures.', - }, - ], - }); + NonStreamedChatResponse response = + cohere.chat( + ChatRequest.builder() + .message("What year was he born?") + .chatHistory( + List.of( + ChatMessage.builder() + .role(ChatMessageRole.USER) + .message("Who discovered gravity?") + .build(), + ChatMessage.builder() + .role(ChatMessageRole.CHATBOT) + .message( + "The man who is widely credited" + + " with discovering gravity is" + + " Sir Isaac Newton") + .build())) + .build()); - console.log(response); - })(); - - language: node - name: Streaming - install: npm i cohere-ai - code: > - const { CohereClient } = require('cohere-ai'); - - - const cohere = new CohereClient({ - token: '<>', - }); - - - (async () => { - const chatStream = await cohere.chatStream({ - chatHistory: [ - { role: 'USER', message: 'Who discovered gravity?' }, - { - role: 'CHATBOT', - message: 'The man who is widely credited with discovering gravity is Sir Isaac Newton', - }, - ], - message: 'What year was he born?', - // perform web search before answering the question. You can also use your own custom connector. - connectors: [{ id: 'web-search' }], - }); - - for await (const message of chatStream) { - if (message.eventType === 'text-generation') { - process.stdout.write(message); - } + System.out.println(response); + } } - })(); - - language: node - name: Tools - install: npm i cohere-ai - code: > - const { CohereClient } = require('cohere-ai'); + - sdk: python + name: Sync + code: > + import cohere - const cohere = new CohereClient({ - token: '<>', - }); + co = cohere.Client("<>") - (async () => { - const response = await cohere.chat({ - message: - "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?", - tools: [ - { - name: 'query_daily_sales_report', - description: - 'Connects to a database to retrieve overall sales volumes and sales information for a given day.', - parameterDefinitions: { - day: { - description: 'Retrieves sales data for this day, formatted as YYYY-MM-DD.', - type: 'str', - required: true, - }, - }, - }, - { - name: 'query_product_catalog', - description: - 'Connects to a a product catalog with information about all the products being sold, including categories, prices, and stock levels.', - parameterDefinitions: { - category: { - description: 'Retrieves product information data for all products in this category.', - type: 'str', - required: true, + response = co.chat( + chat_history=[ + {"role": "USER", "message": "Who discovered gravity?"}, + { + "role": "CHATBOT", + "message": "The man who is widely credited with discovering gravity is Sir Isaac Newton", }, - }, - }, - ], - }); - - console.log(response); - })(); - - language: python - name: Sync - install: python -m pip install cohere --upgrade - code: > - import cohere - - - co = cohere.Client("<>") - - - response = co.chat( - chat_history=[ + ], + message="What year was he born?", + # perform web search before answering the question. You can also use your own custom connector. + connectors=[{"id": "web-search"}], + ) + + + print(response) + - sdk: python + name: Async + code: > + import cohere + + import asyncio + + + co = cohere.AsyncClient("<>") + + + + async def main(): + return await co.chat( + chat_history=[ + {"role": "USER", "message": "Who discovered gravity?"}, + { + "role": "CHATBOT", + "message": "The man who is widely credited with discovering gravity is Sir Isaac Newton", + }, + ], + message="What year was he born?", + # perform web search before answering the question. You can also use your own custom connector. + connectors=[{"id": "web-search"}], + ) + + asyncio.run(main()) + - sdk: curl + name: cURL + code: >- + curl --request POST \ + --url https://api.cohere.com/v1/chat \ + --header 'accept: application/json' \ + --header 'content-type: application/json' \ + --header "Authorization: bearer $CO_API_KEY" \ + --data '{ + "chat_history": [ {"role": "USER", "message": "Who discovered gravity?"}, - { - "role": "CHATBOT", - "message": "The man who is widely credited with discovering gravity is Sir Isaac Newton", - }, - ], - message="What year was he born?", - # perform web search before answering the question. You can also use your own custom connector. - connectors=[{"id": "web-search"}], - ) - - - print(response) - - language: python - name: Async - install: python -m pip install cohere --upgrade - code: > - import cohere - - import asyncio - + {"role": "CHATBOT", "message": "The man who is widely credited with discovering gravity is Sir Isaac Newton"} + ], + "message": "What year was he born?", + "connectors": [{"id": "web-search"}] + }' + - code-samples: + - sdk: go + name: Documents + code: > + package main + + + import ( + "context" + "errors" + "io" + "log" + + cohere "github.com/cohere-ai/cohere-go/v2" + client "github.com/cohere-ai/cohere-go/v2/client" + ) + + + func main() { + co := client.NewClient(client.WithToken("<>")) + + resp, err := co.ChatStream( + context.TODO(), + &cohere.ChatStreamRequest{ + ChatHistory: []*cohere.Message{ + { + Role: "USER", + User: &cohere.ChatMessage{ + Message: "Who discovered gravity?", + }, + }, + { + Role: "CHATBOT", + Chatbot: &cohere.ChatMessage{ + Message: "The man who is widely credited with discovering gravity is Sir Isaac Newton", + }, + }}, + Message: "What year was he born?", + Connectors: []*cohere.ChatConnector{ + {Id: "web-search"}, + }, + }, + ) + + if err != nil { + log.Fatal(err) + } + + // Make sure to close the stream when you're done reading. + // This is easily handled with defer. + defer resp.Close() + + for { + message, err := resp.Recv() + + if errors.Is(err, io.EOF) { + // An io.EOF error means the server is done sending messages + // and should be treated as a success. + break + } + + if message.TextGeneration != nil { + log.Printf("%+v", resp) + } + } - co = cohere.AsyncClient("<>") - - - - async def main(): - return await co.chat( - chat_history=[ - {"role": "USER", "message": "Who discovered gravity?"}, - { - "role": "CHATBOT", - "message": "The man who is widely credited with discovering gravity is Sir Isaac Newton", - }, - ], - message="What year was he born?", - # perform web search before answering the question. You can also use your own custom connector. - connectors=[{"id": "web-search"}], - ) - - asyncio.run(main()) - - language: python - name: Documents - install: python -m pip install cohere --upgrade - code: > - import cohere + } + - sdk: typescript + name: Documents + code: > + const { CohereClient } = require('cohere-ai'); - co = cohere.Client("<>") + const cohere = new CohereClient({ + token: '<>', + }); - response = co.chat( - model="command", - message="Who is more popular: Nsync or Backstreet Boys?", - documents=[ + (async () => { + const response = await cohere.chat({ + message: 'Who is more popular: Nsync or Backstreet Boys?', + documents: [ { - "title": "CSPC: Backstreet Boys Popularity Analysis - ChartMasters", - "snippet": "↓ Skip to Main Content\n\nMusic industry – One step closer to being accurate\n\nCSPC: Backstreet Boys Popularity Analysis\n\nHernán Lopez Posted on February 9, 2017 Posted in CSPC 72 Comments Tagged with Backstreet Boys, Boy band\n\nAt one point, Backstreet Boys defined success: massive albums sales across the globe, great singles sales, plenty of chart topping releases, hugely hyped tours and tremendous media coverage.\n\nIt is true that they benefited from extraordinarily good market conditions in all markets. After all, the all-time record year for the music business, as far as revenues in billion dollars are concerned, was actually 1999. That is, back when this five men group was at its peak." + title: 'CSPC: Backstreet Boys Popularity Analysis - ChartMasters', + snippet: + '↓ Skip to Main Content\n\nMusic industry – One step closer to being accurate\n\nCSPC: Backstreet Boys Popularity Analysis\n\nHernán Lopez Posted on February 9, 2017 Posted in CSPC 72 Comments Tagged with Backstreet Boys, Boy band\n\nAt one point, Backstreet Boys defined success: massive albums sales across the globe, great singles sales, plenty of chart topping releases, hugely hyped tours and tremendous media coverage.\n\nIt is true that they benefited from extraordinarily good market conditions in all markets. After all, the all-time record year for the music business, as far as revenues in billion dollars are concerned, was actually 1999. That is, back when this five men group was at its peak.', }, { - "title": "CSPC: NSYNC Popularity Analysis - ChartMasters", - "snippet": "↓ Skip to Main Content\n\nMusic industry – One step closer to being accurate\n\nCSPC: NSYNC Popularity Analysis\n\nMJD Posted on February 9, 2018 Posted in CSPC 27 Comments Tagged with Boy band, N'Sync\n\nAt the turn of the millennium three teen acts were huge in the US, the Backstreet Boys, Britney Spears and NSYNC. The latter is the only one we haven’t study so far. It took 15 years and Adele to break their record of 2,4 million units sold of No Strings Attached in its first week alone.\n\nIt wasn’t a fluke, as the second fastest selling album of the Soundscan era prior 2015, was also theirs since Celebrity debuted with 1,88 million units sold." + title: 'CSPC: NSYNC Popularity Analysis - ChartMasters', + snippet: + "↓ Skip to Main Content\n\nMusic industry – One step closer to being accurate\n\nCSPC: NSYNC Popularity Analysis\n\nMJD Posted on February 9, 2018 Posted in CSPC 27 Comments Tagged with Boy band, N'Sync\n\nAt the turn of the millennium three teen acts were huge in the US, the Backstreet Boys, Britney Spears and NSYNC. The latter is the only one we haven’t study so far. It took 15 years and Adele to break their record of 2,4 million units sold of No Strings Attached in its first week alone.\n\nIt wasn’t a fluke, as the second fastest selling album of the Soundscan era prior 2015, was also theirs since Celebrity debuted with 1,88 million units sold.", }, { - "title": "CSPC: Backstreet Boys Popularity Analysis - ChartMasters", - "snippet": " 1997, 1998, 2000 and 2001 also rank amongst some of the very best years.\n\nYet the way many music consumers – especially teenagers and young women’s – embraced their output deserves its own chapter. If Jonas Brothers and more recently One Direction reached a great level of popularity during the past decade, the type of success achieved by Backstreet Boys is in a completely different level as they really dominated the business for a few years all over the world, including in some countries that were traditionally hard to penetrate for Western artists.\n\nWe will try to analyze the extent of that hegemony with this new article with final results which will more than surprise many readers." + title: 'CSPC: Backstreet Boys Popularity Analysis - ChartMasters', + snippet: + ' 1997, 1998, 2000 and 2001 also rank amongst some of the very best years.\n\nYet the way many music consumers – especially teenagers and young women’s – embraced their output deserves its own chapter. If Jonas Brothers and more recently One Direction reached a great level of popularity during the past decade, the type of success achieved by Backstreet Boys is in a completely different level as they really dominated the business for a few years all over the world, including in some countries that were traditionally hard to penetrate for Western artists.\n\nWe will try to analyze the extent of that hegemony with this new article with final results which will more than surprise many readers.', }, { - "title": "CSPC: NSYNC Popularity Analysis - ChartMasters", - "snippet": " Was the teen group led by Justin Timberlake really that big? Was it only in the US where they found success? Or were they a global phenomenon?\n\nAs usual, I’ll be using the Commensurate Sales to Popularity Concept in order to relevantly gauge their results. This concept will not only bring you sales information for all NSYNC‘s albums, physical and download singles, as well as audio and video streaming, but it will also determine their true popularity. If you are not yet familiar with the CSPC method, the next page explains it with a short video. I fully recommend watching the video before getting into the sales figures." - } - ]) - - print(response) - - language: python - name: Streaming - install: python -m pip install cohere --upgrade - code: > - import cohere - - - co = cohere.Client("<>") - - - response = co.chat_stream( - chat_history=[ - {"role": "USER", "message": "Who discovered gravity?"}, - { - "role": "CHATBOT", - "message": "The man who is widely credited with discovering gravity is Sir Isaac Newton", + title: 'CSPC: NSYNC Popularity Analysis - ChartMasters', + snippet: + ' Was the teen group led by Justin Timberlake really that big? Was it only in the US where they found success? Or were they a global phenomenon?\n\nAs usual, I’ll be using the Commensurate Sales to Popularity Concept in order to relevantly gauge their results. This concept will not only bring you sales information for all NSYNC‘s albums, physical and download singles, as well as audio and video streaming, but it will also determine their true popularity. If you are not yet familiar with the CSPC method, the next page explains it with a short video. I fully recommend watching the video before getting into the sales figures.', }, - ], - message="What year was he born?", - # perform web search before answering the question. You can also use your own custom connector. - connectors=[{"id": "web-search"}], - ) - - - for event in response: - if event.event_type == "text-generation": - print(event.text, end='') - - language: python - name: Tools - install: python -m pip install cohere --upgrade - code: > - import cohere - - - co = cohere.Client("<>") - - - # tool descriptions that the model has access to - - tools = [ - { - "name": "query_daily_sales_report", - "description": "Connects to a database to retrieve overall sales volumes and sales information for a given day.", - "parameter_definitions": { - "day": { - "description": "Retrieves sales data for this day, formatted as YYYY-MM-DD.", - "type": "str", - "required": True - } - } - }, - { - "name": "query_product_catalog", - "description": "Connects to a a product catalog with information about all the products being sold, including categories, prices, and stock levels.", - "parameter_definitions": { - "category": { - "description": "Retrieves product information data for all products in this category.", - "type": "str", - "required": True - } - } - } - ] - - - - # user request - - message = "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?" - - - response = co.chat( - message=message, - tools=tools, - ) - - - print(response) - - language: java - name: Default - install: implementation 'com.cohere:cohere-java:1.x.x' - code: > - /* (C)2024 */ - - package chatpost; - - - import com.cohere.api.Cohere; + ], + }); + + console.log(response); + })(); + - sdk: java + name: Documents + code: > + /* (C)2024 */ + + package chatpost; + + + import com.cohere.api.Cohere; + + import com.cohere.api.requests.ChatRequest; + + import com.cohere.api.types.NonStreamedChatResponse; + + import java.util.List; + + import java.util.Map; + + + public class Documents { + public static void main(String[] args) { + Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); + + NonStreamedChatResponse response = + cohere.chat( + ChatRequest.builder() + .message("What year was he born?") + .documents( + List.of( + Map.of( + "title", + "CSPC: Backstreet Boys Popularity" + + " Analysis - ChartMasters", + "snippet", + "↓ Skip to Main Content\n\n" + + "Music industry – One step" + + " closer to being" + + " accurate\n\n" + + "CSPC: Backstreet Boys" + + " Popularity Analysis\n\n" + + "Hernán Lopez Posted on" + + " February 9, 2017 Posted in" + + " CSPC 72 Comments Tagged" + + " with Backstreet Boys, Boy" + + " band\n\n" + + "At one point, Backstreet" + + " Boys defined success:" + + " massive albums sales across" + + " the globe, great singles" + + " sales, plenty of chart" + + " topping releases, hugely" + + " hyped tours and tremendous" + + " media coverage.\n\n" + + "It is true that they" + + " benefited from" + + " extraordinarily good market" + + " conditions in all markets." + + " After all, the all-time" + + " record year for the music" + + " business, as far as" + + " revenues in billion dollars" + + " are concerned, was actually" + + " 1999. That is, back when" + + " this five men group was at" + + " its peak."), + Map.of( + "title", + "CSPC: NSYNC Popularity Analysis -" + + " ChartMasters", + "snippet", + "↓ Skip to Main Content\n\n" + + "Music industry – One step" + + " closer to being" + + " accurate\n\n" + + "CSPC: NSYNC Popularity" + + " Analysis\n\n" + + "MJD Posted on February 9," + + " 2018 Posted in CSPC 27" + + " Comments Tagged with Boy" + + " band, N'Sync\n\n" + + "At the turn of the" + + " millennium three teen acts" + + " were huge in the US, the" + + " Backstreet Boys, Britney" + + " Spears and NSYNC. The" + + " latter is the only one we" + + " haven’t study so far. It" + + " took 15 years and Adele to" + + " break their record of 2,4" + + " million units sold of No" + + " Strings Attached in its" + + " first week alone.\n\n" + + "It wasn’t a fluke, as the" + + " second fastest selling" + + " album of the Soundscan era" + + " prior 2015, was also theirs" + + " since Celebrity debuted" + + " with 1,88 million units" + + " sold."), + Map.of( + "title", + "CSPC: Backstreet Boys Popularity" + + " Analysis - ChartMasters", + "snippet", + " 1997, 1998, 2000 and 2001 also" + + " rank amongst some of the" + + " very best years.\n\n" + + "Yet the way many music" + + " consumers – especially" + + " teenagers and young women’s" + + " – embraced their output" + + " deserves its own chapter." + + " If Jonas Brothers and more" + + " recently One Direction" + + " reached a great level of" + + " popularity during the past" + + " decade, the type of success" + + " achieved by Backstreet Boys" + + " is in a completely" + + " different level as they" + + " really dominated the" + + " business for a few years" + + " all over the world," + + " including in some countries" + + " that were traditionally" + + " hard to penetrate for" + + " Western artists.\n\n" + + "We will try to analyze the" + + " extent of that hegemony" + + " with this new article with" + + " final results which will" + + " more than surprise many" + + " readers."), + Map.of( + "title", + "CSPC: NSYNC Popularity Analysis -" + + " ChartMasters", + "snippet", + " Was the teen group led by Justin" + + " Timberlake really that big? Was it" + + " only in the US where they found" + + " success? Or were they a global" + + " phenomenon?\n\n" + + "As usual, I’ll be using the" + + " Commensurate Sales to Popularity" + + " Concept in order to relevantly" + + " gauge their results. This concept" + + " will not only bring you sales" + + " information for all NSYNC‘s albums," + + " physical and download singles, as" + + " well as audio and video streaming," + + " but it will also determine their" + + " true popularity. If you are not yet" + + " familiar with the CSPC method, the" + + " next page explains it with a short" + + " video. I fully recommend watching" + + " the video before getting into the" + + " sales figures."))) + .build()); + + System.out.println(response); + } + } + - sdk: python + name: Documents + code: > + import cohere - import com.cohere.api.requests.ChatRequest; - import com.cohere.api.types.ChatMessage; + co = cohere.Client("<>") - import com.cohere.api.types.ChatMessageRole; - import com.cohere.api.types.NonStreamedChatResponse; + response = co.chat( + model="command", + message="Who is more popular: Nsync or Backstreet Boys?", + documents=[ + { + "title": "CSPC: Backstreet Boys Popularity Analysis - ChartMasters", + "snippet": "↓ Skip to Main Content\n\nMusic industry – One step closer to being accurate\n\nCSPC: Backstreet Boys Popularity Analysis\n\nHernán Lopez Posted on February 9, 2017 Posted in CSPC 72 Comments Tagged with Backstreet Boys, Boy band\n\nAt one point, Backstreet Boys defined success: massive albums sales across the globe, great singles sales, plenty of chart topping releases, hugely hyped tours and tremendous media coverage.\n\nIt is true that they benefited from extraordinarily good market conditions in all markets. After all, the all-time record year for the music business, as far as revenues in billion dollars are concerned, was actually 1999. That is, back when this five men group was at its peak." + }, + { + "title": "CSPC: NSYNC Popularity Analysis - ChartMasters", + "snippet": "↓ Skip to Main Content\n\nMusic industry – One step closer to being accurate\n\nCSPC: NSYNC Popularity Analysis\n\nMJD Posted on February 9, 2018 Posted in CSPC 27 Comments Tagged with Boy band, N'Sync\n\nAt the turn of the millennium three teen acts were huge in the US, the Backstreet Boys, Britney Spears and NSYNC. The latter is the only one we haven’t study so far. It took 15 years and Adele to break their record of 2,4 million units sold of No Strings Attached in its first week alone.\n\nIt wasn’t a fluke, as the second fastest selling album of the Soundscan era prior 2015, was also theirs since Celebrity debuted with 1,88 million units sold." + }, + { + "title": "CSPC: Backstreet Boys Popularity Analysis - ChartMasters", + "snippet": " 1997, 1998, 2000 and 2001 also rank amongst some of the very best years.\n\nYet the way many music consumers – especially teenagers and young women’s – embraced their output deserves its own chapter. If Jonas Brothers and more recently One Direction reached a great level of popularity during the past decade, the type of success achieved by Backstreet Boys is in a completely different level as they really dominated the business for a few years all over the world, including in some countries that were traditionally hard to penetrate for Western artists.\n\nWe will try to analyze the extent of that hegemony with this new article with final results which will more than surprise many readers." + }, + { + "title": "CSPC: NSYNC Popularity Analysis - ChartMasters", + "snippet": " Was the teen group led by Justin Timberlake really that big? Was it only in the US where they found success? Or were they a global phenomenon?\n\nAs usual, I’ll be using the Commensurate Sales to Popularity Concept in order to relevantly gauge their results. This concept will not only bring you sales information for all NSYNC‘s albums, physical and download singles, as well as audio and video streaming, but it will also determine their true popularity. If you are not yet familiar with the CSPC method, the next page explains it with a short video. I fully recommend watching the video before getting into the sales figures." + } + ]) + + print(response) + - code-samples: + - sdk: go + name: Streaming + code: > + package main + + + import ( + "context" + "errors" + "io" + "log" + + cohere "github.com/cohere-ai/cohere-go/v2" + client "github.com/cohere-ai/cohere-go/v2/client" + ) + + + func main() { + co := client.NewClient(client.WithToken("<>")) + + resp, err := co.ChatStream( + context.TODO(), + &cohere.ChatStreamRequest{ + ChatHistory: []*cohere.Message{ + { + Role: "USER", + User: &cohere.ChatMessage{ + Message: "Who discovered gravity?", + }, + }, + { + Role: "CHATBOT", + Chatbot: &cohere.ChatMessage{ + Message: "The man who is widely credited with discovering gravity is Sir Isaac Newton", + }, + }}, + Message: "What year was he born?", + Connectors: []*cohere.ChatConnector{ + {Id: "web-search"}, + }, + }, + ) + + if err != nil { + log.Fatal(err) + } + + // Make sure to close the stream when you're done reading. + // This is easily handled with defer. + defer resp.Close() + + for { + message, err := resp.Recv() + + if errors.Is(err, io.EOF) { + // An io.EOF error means the server is done sending messages + // and should be treated as a success. + break + } + + if message.TextGeneration != nil { + log.Printf("%+v", resp) + } + } - import java.util.List; + } + - sdk: typescript + name: Streaming + code: > + const { CohereClient } = require('cohere-ai'); - public class Default { - public static void main(String[] args) { - Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); + const cohere = new CohereClient({ + token: '<>', + }); - NonStreamedChatResponse response = - cohere.chat( - ChatRequest.builder() - .message("What year was he born?") - .chatHistory( - List.of( - ChatMessage.builder() - .role(ChatMessageRole.USER) - .message("Who discovered gravity?") - .build(), - ChatMessage.builder() - .role(ChatMessageRole.CHATBOT) - .message( - "The man who is widely credited" - + " with discovering gravity is" - + " Sir Isaac Newton") - .build())) - .build()); - System.out.println(response); + (async () => { + const chatStream = await cohere.chatStream({ + chatHistory: [ + { role: 'USER', message: 'Who discovered gravity?' }, + { + role: 'CHATBOT', + message: 'The man who is widely credited with discovering gravity is Sir Isaac Newton', + }, + ], + message: 'What year was he born?', + // perform web search before answering the question. You can also use your own custom connector. + connectors: [{ id: 'web-search' }], + }); + + for await (const message of chatStream) { + if (message.eventType === 'text-generation') { + process.stdout.write(message); + } } - } - - language: java - name: Documents - install: implementation 'com.cohere:cohere-java:1.x.x' - code: > - /* (C)2024 */ + })(); + - sdk: java + name: Streaming + code: > + /* (C)2024 */ - package chatpost; + package chatpost; - import com.cohere.api.Cohere; + import com.cohere.api.Cohere; - import com.cohere.api.requests.ChatRequest; + import com.cohere.api.requests.ChatStreamRequest; - import com.cohere.api.types.NonStreamedChatResponse; + import com.cohere.api.types.ChatMessage; - import java.util.List; + import com.cohere.api.types.ChatMessageRole; - import java.util.Map; + import com.cohere.api.types.ChatTextGenerationEvent; + import com.cohere.api.types.StreamedChatResponse; - public class Documents { - public static void main(String[] args) { - Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); + import java.util.List; - NonStreamedChatResponse response = - cohere.chat( - ChatRequest.builder() - .message("What year was he born?") - .documents( - List.of( - Map.of( - "title", - "CSPC: Backstreet Boys Popularity" - + " Analysis - ChartMasters", - "snippet", - "↓ Skip to Main Content\n\n" - + "Music industry – One step" - + " closer to being" - + " accurate\n\n" - + "CSPC: Backstreet Boys" - + " Popularity Analysis\n\n" - + "Hernán Lopez Posted on" - + " February 9, 2017 Posted in" - + " CSPC 72 Comments Tagged" - + " with Backstreet Boys, Boy" - + " band\n\n" - + "At one point, Backstreet" - + " Boys defined success:" - + " massive albums sales across" - + " the globe, great singles" - + " sales, plenty of chart" - + " topping releases, hugely" - + " hyped tours and tremendous" - + " media coverage.\n\n" - + "It is true that they" - + " benefited from" - + " extraordinarily good market" - + " conditions in all markets." - + " After all, the all-time" - + " record year for the music" - + " business, as far as" - + " revenues in billion dollars" - + " are concerned, was actually" - + " 1999. That is, back when" - + " this five men group was at" - + " its peak."), - Map.of( - "title", - "CSPC: NSYNC Popularity Analysis -" - + " ChartMasters", - "snippet", - "↓ Skip to Main Content\n\n" - + "Music industry – One step" - + " closer to being" - + " accurate\n\n" - + "CSPC: NSYNC Popularity" - + " Analysis\n\n" - + "MJD Posted on February 9," - + " 2018 Posted in CSPC 27" - + " Comments Tagged with Boy" - + " band, N'Sync\n\n" - + "At the turn of the" - + " millennium three teen acts" - + " were huge in the US, the" - + " Backstreet Boys, Britney" - + " Spears and NSYNC. The" - + " latter is the only one we" - + " haven’t study so far. It" - + " took 15 years and Adele to" - + " break their record of 2,4" - + " million units sold of No" - + " Strings Attached in its" - + " first week alone.\n\n" - + "It wasn’t a fluke, as the" - + " second fastest selling" - + " album of the Soundscan era" - + " prior 2015, was also theirs" - + " since Celebrity debuted" - + " with 1,88 million units" - + " sold."), - Map.of( - "title", - "CSPC: Backstreet Boys Popularity" - + " Analysis - ChartMasters", - "snippet", - " 1997, 1998, 2000 and 2001 also" - + " rank amongst some of the" - + " very best years.\n\n" - + "Yet the way many music" - + " consumers – especially" - + " teenagers and young women’s" - + " – embraced their output" - + " deserves its own chapter." - + " If Jonas Brothers and more" - + " recently One Direction" - + " reached a great level of" - + " popularity during the past" - + " decade, the type of success" - + " achieved by Backstreet Boys" - + " is in a completely" - + " different level as they" - + " really dominated the" - + " business for a few years" - + " all over the world," - + " including in some countries" - + " that were traditionally" - + " hard to penetrate for" - + " Western artists.\n\n" - + "We will try to analyze the" - + " extent of that hegemony" - + " with this new article with" - + " final results which will" - + " more than surprise many" - + " readers."), - Map.of( - "title", - "CSPC: NSYNC Popularity Analysis -" - + " ChartMasters", - "snippet", - " Was the teen group led by Justin" - + " Timberlake really that big? Was it" - + " only in the US where they found" - + " success? Or were they a global" - + " phenomenon?\n\n" - + "As usual, I’ll be using the" - + " Commensurate Sales to Popularity" - + " Concept in order to relevantly" - + " gauge their results. This concept" - + " will not only bring you sales" - + " information for all NSYNC‘s albums," - + " physical and download singles, as" - + " well as audio and video streaming," - + " but it will also determine their" - + " true popularity. If you are not yet" - + " familiar with the CSPC method, the" - + " next page explains it with a short" - + " video. I fully recommend watching" - + " the video before getting into the" - + " sales figures."))) - .build()); - - System.out.println(response); - } - } - - language: java - name: Streaming - install: implementation 'com.cohere:cohere-java:1.x.x' - code: > - /* (C)2024 */ - package chatpost; + public class Stream { + public static void main(String[] args) { + Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); + Iterable response = + cohere.chatStream( + ChatStreamRequest.builder() + .message("What year was he born?") + .chatHistory( + List.of( + ChatMessage.builder() + .role(ChatMessageRole.USER) + .message("Who discovered gravity?") + .build(), + ChatMessage.builder() + .role(ChatMessageRole.CHATBOT) + .message( + "The man who is widely credited" + + " with discovering gravity is" + + " Sir Isaac Newton") + .build())) + .build()); - import com.cohere.api.Cohere; + for (StreamedChatResponse chatResponse : response) { + if (chatResponse.isTextGeneration()) { + System.out.println( + chatResponse + .getTextGeneration() + .map(ChatTextGenerationEvent::getText) + .orElse("")); + } + } - import com.cohere.api.requests.ChatStreamRequest; - - import com.cohere.api.types.ChatMessage; + System.out.println(response); + } + } + - sdk: python + name: Streaming + code: > + import cohere - import com.cohere.api.types.ChatMessageRole; - import com.cohere.api.types.ChatTextGenerationEvent; + co = cohere.Client("<>") - import com.cohere.api.types.StreamedChatResponse; - import java.util.List; + response = co.chat_stream( + chat_history=[ + {"role": "USER", "message": "Who discovered gravity?"}, + { + "role": "CHATBOT", + "message": "The man who is widely credited with discovering gravity is Sir Isaac Newton", + }, + ], + message="What year was he born?", + # perform web search before answering the question. You can also use your own custom connector. + connectors=[{"id": "web-search"}], + ) + + + for event in response: + if event.event_type == "text-generation": + print(event.text, end='') + - code-samples: + - sdk: go + name: Tools + code: > + package main + + + import ( + "context" + "log" + + cohere "github.com/cohere-ai/cohere-go/v2" + client "github.com/cohere-ai/cohere-go/v2/client" + ) + + + func main() { + co := client.NewClient(client.WithToken("<>")) + + resp, err := co.Chat( + context.TODO(), + &cohere.ChatRequest{ + Message: "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?", + Tools: []*cohere.Tool{ + { + Name: "query_daily_sales_report", + Description: "Connects to a database to retrieve overall sales volumes and sales information for a given day.", + ParameterDefinitions: map[string]*cohere.ToolParameterDefinitionsValue{ + "day": { + Description: cohere.String("Retrieves sales data for this day, formatted as YYYY-MM-DD."), + Type: "str", + Required: cohere.Bool(true), + }, + }, + }, + { + Name: "query_product_catalog", + Description: "Connects to a a product catalog with information about all the products being sold, including categories, prices, and stock levels.", + ParameterDefinitions: map[string]*cohere.ToolParameterDefinitionsValue{ + "category": { + Description: cohere.String("Retrieves product information data for all products in this category."), + Type: "str", + Required: cohere.Bool(true), + }, + }, + }, + }, + }, + ) + + if err != nil { + log.Fatal(err) + } + + log.Printf("%+v", resp) + } + - sdk: typescript + name: Tools + code: > + const { CohereClient } = require('cohere-ai'); - public class Stream { - public static void main(String[] args) { - Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); + const cohere = new CohereClient({ + token: '<>', + }); - Iterable response = - cohere.chatStream( - ChatStreamRequest.builder() - .message("What year was he born?") - .chatHistory( - List.of( - ChatMessage.builder() - .role(ChatMessageRole.USER) - .message("Who discovered gravity?") - .build(), - ChatMessage.builder() - .role(ChatMessageRole.CHATBOT) - .message( - "The man who is widely credited" - + " with discovering gravity is" - + " Sir Isaac Newton") - .build())) - .build()); - - for (StreamedChatResponse chatResponse : response) { - if (chatResponse.isTextGeneration()) { - System.out.println( - chatResponse - .getTextGeneration() - .map(ChatTextGenerationEvent::getText) - .orElse("")); - } - } - System.out.println(response); - } - } - - language: java - name: Tools - install: implementation 'com.cohere:cohere-java:1.x.x' - code: > - /* (C)2024 */ + (async () => { + const response = await cohere.chat({ + message: + "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?", + tools: [ + { + name: 'query_daily_sales_report', + description: + 'Connects to a database to retrieve overall sales volumes and sales information for a given day.', + parameterDefinitions: { + day: { + description: 'Retrieves sales data for this day, formatted as YYYY-MM-DD.', + type: 'str', + required: true, + }, + }, + }, + { + name: 'query_product_catalog', + description: + 'Connects to a a product catalog with information about all the products being sold, including categories, prices, and stock levels.', + parameterDefinitions: { + category: { + description: 'Retrieves product information data for all products in this category.', + type: 'str', + required: true, + }, + }, + }, + ], + }); + + console.log(response); + })(); + - sdk: java + name: Tools + code: > + /* (C)2024 */ + + package chatpost; + + + import com.cohere.api.Cohere; + + import com.cohere.api.requests.ChatRequest; + + import com.cohere.api.types.NonStreamedChatResponse; + + import com.cohere.api.types.Tool; + + import com.cohere.api.types.ToolParameterDefinitionsValue; + + import java.util.List; + + import java.util.Map; + + + public class Tools { + public static void main(String[] args) { + Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); + + NonStreamedChatResponse response = + cohere.chat( + ChatRequest.builder() + .message( + "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?") + .tools( + List.of( + Tool.builder() + .name("query_daily_sales_report") + .description( + "Connects to a database to retrieve" + + " overall sales volumes and" + + " sales information for a" + + " given day.") + .parameterDefinitions( + Map.of( + "day", + ToolParameterDefinitionsValue + .builder() + .type("str") + .description( + "Retrieves" + + " sales" + + " data" + + " for this" + + " day," + + " formatted" + + " as YYYY-MM-DD.") + .required(true) + .build())) + .build(), + Tool.builder() + .name("query_product_catalog") + .description( + "Connects to a a product catalog" + + " with information about all" + + " the products being sold," + + " including categories," + + " prices, and stock levels.") + .parameterDefinitions( + Map.of( + "category", + ToolParameterDefinitionsValue + .builder() + .type("str") + .description( + "Retrieves" + + " product" + + " information" + + " data" + + " for all" + + " products" + + " in this" + + " category.") + .required(true) + .build())) + .build())) + .build()); + + System.out.println(response); + } + } + - sdk: python + name: Tools + code: > + import cohere - package chatpost; + co = cohere.Client("<>") - import com.cohere.api.Cohere; - import com.cohere.api.requests.ChatRequest; + # tool descriptions that the model has access to - import com.cohere.api.types.NonStreamedChatResponse; + tools = [ + { + "name": "query_daily_sales_report", + "description": "Connects to a database to retrieve overall sales volumes and sales information for a given day.", + "parameter_definitions": { + "day": { + "description": "Retrieves sales data for this day, formatted as YYYY-MM-DD.", + "type": "str", + "required": True + } + } + }, + { + "name": "query_product_catalog", + "description": "Connects to a a product catalog with information about all the products being sold, including categories, prices, and stock levels.", + "parameter_definitions": { + "category": { + "description": "Retrieves product information data for all products in this category.", + "type": "str", + "required": True + } + } + } + ] - import com.cohere.api.types.Tool; - import com.cohere.api.types.ToolParameterDefinitionsValue; - import java.util.List; + # user request - import java.util.Map; + message = "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?" - public class Tools { - public static void main(String[] args) { - Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); + response = co.chat( + message=message, + tools=tools, + ) - NonStreamedChatResponse response = - cohere.chat( - ChatRequest.builder() - .message( - "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?") - .tools( - List.of( - Tool.builder() - .name("query_daily_sales_report") - .description( - "Connects to a database to retrieve" - + " overall sales volumes and" - + " sales information for a" - + " given day.") - .parameterDefinitions( - Map.of( - "day", - ToolParameterDefinitionsValue - .builder() - .type("str") - .description( - "Retrieves" - + " sales" - + " data" - + " for this" - + " day," - + " formatted" - + " as YYYY-MM-DD.") - .required(true) - .build())) - .build(), - Tool.builder() - .name("query_product_catalog") - .description( - "Connects to a a product catalog" - + " with information about all" - + " the products being sold," - + " including categories," - + " prices, and stock levels.") - .parameterDefinitions( - Map.of( - "category", - ToolParameterDefinitionsValue - .builder() - .type("str") - .description( - "Retrieves" - + " product" - + " information" - + " data" - + " for all" - + " products" - + " in this" - + " category.") - .required(true) - .build())) - .build())) - .build()); - System.out.println(response); - } - } - - language: curl - name: cURL - code: >- - curl --request POST \ - --url https://api.cohere.com/v1/chat \ - --header 'accept: application/json' \ - --header 'content-type: application/json' \ - --header "Authorization: bearer $CO_API_KEY" \ - --data '{ - "chat_history": [ - {"role": "USER", "message": "Who discovered gravity?"}, - {"role": "CHATBOT", "message": "The man who is widely credited with discovering gravity is Sir Isaac Newton"} - ], - "message": "What year was he born?", - "connectors": [{"id": "web-search"}] - }' + print(response) description: | Generates a text response to a user message. To learn how to use the Chat API with Streaming and RAG follow our [Text Generation guides](https://docs.cohere.com/docs/chat-api). @@ -1230,12 +1210,10 @@ paths: A list of relevant documents that the model can cite to generate a more accurate reply. Each document is a string-string dictionary. Example: - ``` - [ + `[ { "title": "Tall penguins", "text": "Emperor penguins are the tallest." }, { "title": "Penguin habitats", "text": "Emperor penguins only live in Antarctica." }, - ] - ``` + ]` Keys and values from each document will be serialized to a string and passed to the model. The resulting generation will include citations that reference some of these documents. @@ -1521,65 +1499,81 @@ paths: type: array items: $ref: "#/components/schemas/Tool-2" - tool_choice: - type: string - enum: - - AUTO - - NONE - - ANY + description: | + A list of available tools (functions) that the model may suggest invoking before producing a text response. + + When `tools` is passed (without `tool_results`), the `text` content in the response will be empty and the `tool_calls` field in the response will be populated with a list of tool calls that need to be made. If no calls need to be made, the `tool_calls` array will be empty. citation_mode: type: string enum: - FAST - ACCURATE - truncation_mode: - type: string - enum: - OFF - - AUTO - - AUTO_PRESERVE_ORDER + description: | + Defaults to `"accurate"`. + Dictates the approach taken to generating citations as part of the RAG flow by allowing the user to specify whether they want `"accurate"` results, `"fast"` results or no results. response_format: - type: object - properties: - type: - type: string - enum: - - json_object - description: When set to JSON, the output will be parse-able valid JSON (or run - out of context). - schema: - description: | - A JSON schema object that the output will adhere to. Refer to https://json-schema.org/ for reference about schemas. - type: object + $ref: "#/components/schemas/ResponseFormat" max_tokens: type: integer - description: The maximum number of tokens to generate. + description: | + The maximum number of tokens the model will generate as part of the response. Note: Setting a low value may result in incomplete generations. stop_sequences: type: array items: type: string - description: A list of strings that the model will stop generating at. - max_input_tokens: - type: integer - description: The maximum number of tokens to feed into the model. + description: | + A list of up to 5 strings that the model will use to stop generation. If the model generates a string that matches any of the strings in the list, it will stop generating tokens and return the generated text up to that point not including the stop sequence. temperature: type: number - description: The temperature of the model. format: float + minimum: 0 + maximum: 1 + description: | + Defaults to `0.3`. + + A non-negative float that tunes the degree of randomness in generation. Lower temperatures mean less random generations, and higher temperatures mean more random generations. + + Randomness can be further maximized by increasing the value of the `p` parameter. seed: type: integer + minimum: 0 + maximum: 18446744073709552000 + description: | + If specified, the backend will make a best effort to sample tokens + deterministically, such that repeated requests with the same + seed and parameters should return the same result. However, + determinism cannot be totally guaranteed. frequency_penalty: type: number - description: The frequency penalty of the model. format: float + description: | + Defaults to `0.0`, min value of `0.0`, max value of `1.0`. + Used to reduce repetitiveness of generated tokens. The higher the value, the stronger a penalty is applied to previously present tokens, proportional to how many times they have already appeared in the prompt or prior generation. presence_penalty: type: number - description: The presence penalty of the model. format: float + description: | + Defaults to `0.0`, min value of `0.0`, max value of `1.0`. + Used to reduce repetitiveness of generated tokens. Similar to `frequency_penalty`, except that this penalty is applied equally to all tokens that have already appeared, regardless of their exact frequencies. k: - type: integer + type: number + format: float + default: 0 + minimum: 0 + maximum: 500 + description: | + Ensures only the top `k` most likely tokens are considered for generation at each step. + Defaults to `0`, min value of `0`, max value of `500`. p: - type: integer + type: number + format: float + default: 0.75 + minimum: 0.01 + maximum: 0.99 + description: | + Ensures that only the most likely tokens, with total probability mass of `p`, are considered for generation at each step. If both `k` and `p` are enabled, `p` acts after `k`. + Defaults to `0.75`. min value of `0.01`, max value of `0.99`. responses: "200": description: OK @@ -1613,278 +1607,269 @@ paths: $ref: "#/components/responses/ServiceUnavailable" "504": $ref: "#/components/responses/GatewayTimeout" - x-readme: - samples-languages: - - python - - node - code-samples: - - language: node - name: Default - install: npm i cohere-ai - code: | - const { CohereClientV2 } = require('cohere-ai'); - - const cohere = new CohereClientV2({ - token: '<>', - }); - - (async () => { - const response = await cohere.chat({ - model: 'command-r-plus', - messages: [ - { - role: 'user', - content: 'hello world!', - }, - ], + x-fern-examples: + - code-samples: + - sdk: typescript + name: Default + code: | + const { CohereClientV2 } = require('cohere-ai'); + + const cohere = new CohereClientV2({ + token: '<>', }); - console.log(response); - })(); - - language: node - name: Documents - install: npm i cohere-ai - code: > - const { CohereClientV2 } = require('cohere-ai'); - - - const cohere = new CohereClientV2({ - token: '<>', - }); - - - (async () => { - const response = await cohere.chat({ - model: 'command-r-plus', - messages: [ - { - role: 'user', - content: [ - { type: 'document', id: '1', document: { text: 'Cohere is the best!' } }, - { type: 'text', text: "Who's the best?" }, - ], - }, - ], - }); + (async () => { + const response = await cohere.chat({ + model: 'command-r-plus', + messages: [ + { + role: 'user', + content: 'hello world!', + }, + ], + }); + + console.log(response); + })(); + - sdk: python + name: Sync + code: | + import cohere + + co = cohere.ClientV2("<>") + + response = co.chat( + model="command-r-plus", + messages=[ + cohere.v2.ChatMessage2_User( + content="hello world!" + ) + ] + ) - console.log(response); - })(); - - language: node - name: Streaming - install: npm i cohere-ai - code: | - const { CohereClientV2 } = require('cohere-ai'); + print(response) + - sdk: python + name: Async + code: | + import cohere + import asyncio - const cohere = new CohereClientV2({ - token: '<>', - }); + co = cohere.AsyncClientV2("<>") - (async () => { - const stream = await cohere.chatStream({ - model: 'command-r-plus', - messages: [ - { - role: 'user', - content: 'hello world!', - }, - ], - }); - for await (const chatEvent of stream) { - if (chatEvent.type === 'content-delta') { - console.log(chatEvent.delta?.message); - } - } - })(); - - language: node - name: Tools - install: npm i cohere-ai - code: > - const { CohereClientV2 } = require('cohere-ai'); + async def main(): + response = await co.chat( + model="command-r-plus", + messages=[ + cohere.v2.ChatMessage2_User( + content="hello world!" + ) + ] + ) + print(response) - const cohere = new CohereClientV2({ - token: '<>', - }); + asyncio.run(main()) + - code-samples: + - sdk: typescript + name: Documents + code: > + const { CohereClientV2 } = require('cohere-ai'); - (async () => { - const response = await cohere.chat({ - model: 'command-r-plus', - tools: [ - { - type: 'function', - function: { - name: 'query_daily_sales_report', - description: - 'Connects to a database to retrieve overall sales volumes and sales information for a given day.', - parameters: { - day: { - description: 'Retrieves sales data for this day, formatted as YYYY-MM-DD.', - type: 'str', - required: true, - }, - }, - }, - }, - { - type: 'function', - function: { - name: 'query_product_catalog', - description: - 'Connects to a a product catalog with information about all the products being sold, including categories, prices, and stock levels.', - parameters: { - category: { - description: 'Retrieves product information data for all products in this category.', - type: 'str', - required: true, - }, - }, - }, - }, - ], - messages: [ - { - role: 'user', - 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?", - }, - ], + const cohere = new CohereClientV2({ + token: '<>', }); - console.log(response); - })(); - - language: python - name: Sync - install: python -m pip install cohere --upgrade - code: | - import cohere - - co = cohere.ClientV2("<>") - - response = co.chat( - model="command-r-plus", - messages=[ - cohere.v2.ChatMessage2_User( - content="hello world!" - ) - ] - ) - - print(response) - - language: python - name: Async - install: python -m pip install cohere --upgrade - code: | - import cohere - import asyncio - - co = cohere.AsyncClientV2("<>") - - - async def main(): - response = await co.chat( - model="command-r-plus", - messages=[ - cohere.v2.ChatMessage2_User( - content="hello world!" - ) - ] - ) - - print(response) - asyncio.run(main()) - - language: python - name: Documents - install: python -m pip install cohere --upgrade - code: | - import cohere + (async () => { + const response = await cohere.chat({ + model: 'command-r-plus', + messages: [ + { + role: 'user', + content: [ + { type: 'document', id: '1', document: { text: 'Cohere is the best!' } }, + { type: 'text', text: "Who's the best?" }, + ], + }, + ], + }); + + console.log(response); + })(); + - sdk: python + name: Documents + code: | + import cohere + + co = cohere.ClientV2("<>") + + response = co.chat( + model="command-r-plus", + messages=[ + cohere.v2.ChatMessage2_User( + content=[ + cohere.v2.DocumentContent( + id=1, + document={'title': 'The best', + 'text': 'Cohere is the best!'} + ), + cohere.v2.TextContent(text="Who's the best?"), + ] + ) + ] + ) - co = cohere.ClientV2("<>") - - response = co.chat( - model="command-r-plus", - messages=[ - cohere.v2.ChatMessage2_User( - content=[ - cohere.v2.DocumentContent( - id=1, - document={'title': 'The best', - 'text': 'Cohere is the best!'} - ), - cohere.v2.TextContent(text="Who's the best?"), - ] - ) - ] - ) + print(response) + - code-samples: + - sdk: typescript + name: Streaming + code: | + const { CohereClientV2 } = require('cohere-ai'); - print(response) - - language: python - name: Streaming - install: python -m pip install cohere --upgrade - code: | - import cohere + const cohere = new CohereClientV2({ + token: '<>', + }); - co = cohere.ClientV2("<>") + (async () => { + const stream = await cohere.chatStream({ + model: 'command-r-plus', + messages: [ + { + role: 'user', + content: 'hello world!', + }, + ], + }); - response = co.chat_stream( - model="command-r-plus", - messages=[ - cohere.v2.ChatMessage2_User( - content="hello world!" - ) - ] - ) + for await (const chatEvent of stream) { + if (chatEvent.type === 'content-delta') { + console.log(chatEvent.delta?.message); + } + } + })(); + - sdk: python + name: Streaming + code: | + import cohere + + co = cohere.ClientV2("<>") + + response = co.chat_stream( + model="command-r-plus", + messages=[ + cohere.v2.ChatMessage2_User( + content="hello world!" + ) + ] + ) - for event in response: - if event.event_type == "text-generation": - print(event.text, end='') - - language: python - name: Tools - install: python -m pip install cohere --upgrade - code: > - import cohere + for event in response: + if event.event_type == "text-generation": + print(event.text, end='') + - code-samples: + - sdk: typescript + name: Tools + code: > + const { CohereClientV2 } = require('cohere-ai'); - co = cohere.Client("<>") + const cohere = new CohereClientV2({ + token: '<>', + }); - response = co.chat( - model="command-r-plus", - tools=[ - cohere.v2.Tool2(type='function', function={ - "name": 'query_daily_sales_report', - "description": 'Connects to a database to retrieve overall sales volumes and sales information for a given day.', - "parameters": { - "day": { - "description": 'Retrieves sales data for this day, formatted as YYYY-MM-DD.', - "type": 'str', - "required": True, - }, - } - }), - cohere.v2.Tool2(type='function', function={ - "name": 'query_product_catalog', - "description": 'Connects to a a product catalog with information about all the products being sold, including categories, prices, and stock levels.', - "parameters": { - "category": { - "description": 'Retrieves product information data for all products in this category.', - "type": 'str', - "required": True, - }, - } - }) - ], - messages=[ - cohere.v2.ChatMessage2_User( - 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?" - ) - ] - ) + (async () => { + const response = await cohere.chat({ + model: 'command-r-plus', + tools: [ + { + type: 'function', + function: { + name: 'query_daily_sales_report', + description: + 'Connects to a database to retrieve overall sales volumes and sales information for a given day.', + parameters: { + day: { + description: 'Retrieves sales data for this day, formatted as YYYY-MM-DD.', + type: 'str', + required: true, + }, + }, + }, + }, + { + type: 'function', + function: { + name: 'query_product_catalog', + description: + 'Connects to a a product catalog with information about all the products being sold, including categories, prices, and stock levels.', + parameters: { + category: { + description: 'Retrieves product information data for all products in this category.', + type: 'str', + required: true, + }, + }, + }, + }, + ], + messages: [ + { + role: 'user', + 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?", + }, + ], + }); + + console.log(response); + })(); + - sdk: python + name: Tools + code: > + import cohere + + + co = cohere.Client("<>") + + + response = co.chat( + model="command-r-plus", + tools=[ + cohere.v2.Tool2(type='function', function={ + "name": 'query_daily_sales_report', + "description": 'Connects to a database to retrieve overall sales volumes and sales information for a given day.', + "parameters": { + "day": { + "description": 'Retrieves sales data for this day, formatted as YYYY-MM-DD.', + "type": 'str', + "required": True, + }, + } + }), + cohere.v2.Tool2(type='function', function={ + "name": 'query_product_catalog', + "description": 'Connects to a a product catalog with information about all the products being sold, including categories, prices, and stock levels.', + "parameters": { + "category": { + "description": 'Retrieves product information data for all products in this category.', + "type": 'str', + "required": True, + }, + } + }) + ], + messages=[ + cohere.v2.ChatMessage2_User( + 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?" + ) + ] + ) - print(response) + print(response) /v1/generate: post: x-fern-audiences: @@ -1941,140 +1926,129 @@ paths: stream-error: "#/components/schemas/GenerateStreamError" parameters: - $ref: "#/components/parameters/RequestSource" - x-readme: - samples-languages: - - python - - java - - curl - - node - - go - code-samples: - - language: go - name: Cohere Go SDK - install: go get github.com/cohere-ai/cohere-go/v2 - code: | - package main - - import ( - "context" - "errors" - "io" - "log" - - cohere "github.com/cohere-ai/cohere-go/v2" - client "github.com/cohere-ai/cohere-go/v2/client" - ) - - func main() { - co := client.NewClient(client.WithToken("<>")) - - resp, err := co.GenerateStream( - context.TODO(), - &cohere.GenerateStreamRequest{ - Prompt: "Please explain to me how LLMs work", - }, - ) - - if err != nil { - log.Fatal(err) - } - - // Make sure to close the stream when you're done reading. - // This is easily handled with defer. - defer resp.Close() - - for { - message, err := resp.Recv() - - if errors.Is(err, io.EOF) { - // An io.EOF error means the server is done sending messages - // and should be treated as a success. - break - } - - if message.TextGeneration != nil { - log.Printf("%+v", resp) - } - } - } - - language: node - name: Cohere TypeScript SDK - install: npm i cohere-ai - code: | - const { CohereClient } = require('cohere-ai'); - - const cohere = new CohereClient({ - token: '<>', - }); + x-fern-examples: + - code-samples: + - sdk: go + name: Cohere Go SDK + code: | + package main + + import ( + "context" + "errors" + "io" + "log" + + cohere "github.com/cohere-ai/cohere-go/v2" + client "github.com/cohere-ai/cohere-go/v2/client" + ) + + func main() { + co := client.NewClient(client.WithToken("<>")) + + resp, err := co.GenerateStream( + context.TODO(), + &cohere.GenerateStreamRequest{ + Prompt: "Please explain to me how LLMs work", + }, + ) + + if err != nil { + log.Fatal(err) + } + + // Make sure to close the stream when you're done reading. + // This is easily handled with defer. + defer resp.Close() + + for { + message, err := resp.Recv() + + if errors.Is(err, io.EOF) { + // An io.EOF error means the server is done sending messages + // and should be treated as a success. + break + } + + if message.TextGeneration != nil { + log.Printf("%+v", resp) + } + } + } + - sdk: typescript + name: Cohere TypeScript SDK + code: | + const { CohereClient } = require('cohere-ai'); - (async () => { - const generate = await cohere.generate({ - prompt: 'Please explain to me how LLMs work', + const cohere = new CohereClient({ + token: '<>', }); - console.log(generate); - })(); - - language: python - name: Sync - install: python -m pip install cohere --upgrade - code: | - import cohere + (async () => { + const generate = await cohere.generate({ + prompt: 'Please explain to me how LLMs work', + }); - co = cohere.Client("<>") + console.log(generate); + })(); + - sdk: python + name: Sync + code: | + import cohere - response = co.generate( - prompt="Please explain to me how LLMs work", - ) - print(response) - - language: python - name: Async - install: python -m pip install cohere --upgrade - code: | - import cohere - import asyncio + co = cohere.Client("<>") - co = cohere.AsyncClient("<>") + response = co.generate( + prompt="Please explain to me how LLMs work", + ) + print(response) + - sdk: python + name: Async + code: | + import cohere + import asyncio + co = cohere.AsyncClient("<>") - async def main(): - response = await co.generate( - prompt="Please explain to me how LLMs work", - ) - print(response) - asyncio.run(main()) - - language: java - name: Cohere java SDK - install: implementation 'com.cohere:cohere-java:1.0.4' - code: > - import com.cohere.api.Cohere; + async def main(): + response = await co.generate( + prompt="Please explain to me how LLMs work", + ) + print(response) - import com.cohere.api.requests.GenerateRequest; + asyncio.run(main()) + - sdk: java + name: Cohere java SDK + code: > + import com.cohere.api.Cohere; - import com.cohere.api.types.Generation; + import com.cohere.api.requests.GenerateRequest; + import com.cohere.api.types.Generation; - public class GeneratePost { - public static void main(String[] args) { - Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); - Generation response = cohere.generate(GenerateRequest.builder().prompt("Please explain to me how LLMs work").build()); + public class GeneratePost { + public static void main(String[] args) { + Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); - System.out.println(response); - } - } - - language: curl - name: cURL - code: |- - curl --request POST \ - --url https://api.cohere.com/v1/generate \ - --header 'accept: application/json' \ - --header 'content-type: application/json' \ - --header "Authorization: bearer $CO_API_KEY" \ - --data '{ - "prompt": "Please explain to me how LLMs work" - }' + Generation response = cohere.generate(GenerateRequest.builder().prompt("Please explain to me how LLMs work").build()); + + System.out.println(response); + } + } + - sdk: curl + name: cURL + code: |- + curl --request POST \ + --url https://api.cohere.com/v1/generate \ + --header 'accept: application/json' \ + --header 'content-type: application/json' \ + --header "Authorization: bearer $CO_API_KEY" \ + --data '{ + "prompt": "Please explain to me how LLMs work" + }' responses: "200": description: OK @@ -2117,9 +2091,9 @@ paths: "504": $ref: "#/components/responses/GatewayTimeout" description: | - - This API is marked as "Legacy" and is no longer maintained. Follow the [migration guide](/docs/migrating-from-cogenerate-to-cochat) to start using the Chat API. - + > 🚧 Warning + > + > This API is marked as "Legacy" and is no longer maintained. Follow the [migration guide](/docs/migrating-from-cogenerate-to-cochat) to start using the Chat API. Generates realistic text conditioned on a given input. requestBody: @@ -2129,13 +2103,6 @@ paths: type: object x-fern-audiences: - public - x-examples: - Example: - prompt: Please explain to me how LLMs work - max_tokens: 50 - temperature: 1 - k: 0 - p: 0.75 properties: prompt: type: string @@ -2313,10 +2280,6 @@ paths: required: - prompt writeOnly: true - examples: - Example: - value: - prompt: Please explain to me how LLMs work description: "" /v1/embed: post: @@ -2326,138 +2289,127 @@ paths: operationId: embed parameters: - $ref: "#/components/parameters/RequestSource" - x-readme: - samples-languages: - - python - - java - - curl - - node - - go - code-samples: - - language: go - name: Cohere Go SDK - install: go get github.com/cohere-ai/cohere-go/v2 - code: | - package main - - import ( - "context" - "log" - - cohere "github.com/cohere-ai/cohere-go/v2" - client "github.com/cohere-ai/cohere-go/v2/client" - ) - - func main() { - co := client.NewClient(client.WithToken("<>")) - - resp, err := co.Embed( - context.TODO(), - &cohere.EmbedRequest{ - Texts: []string{"hello", "goodbye"}, - Model: cohere.String("embed-english-v3.0"), - InputType: cohere.EmbedInputTypeSearchDocument.Ptr(), - }, - ) - - if err != nil { - log.Fatal(err) - } - - log.Printf("%+v", resp) - } - - language: node - name: Cohere TypeScript SDK - install: npm i cohere-ai - code: | - const { CohereClient } = require('cohere-ai'); - - const cohere = new CohereClient({ - token: '<>', - }); + x-fern-examples: + - code-samples: + - sdk: go + name: Cohere Go SDK + code: | + package main + + import ( + "context" + "log" + + cohere "github.com/cohere-ai/cohere-go/v2" + client "github.com/cohere-ai/cohere-go/v2/client" + ) + + func main() { + co := client.NewClient(client.WithToken("<>")) + + resp, err := co.Embed( + context.TODO(), + &cohere.EmbedRequest{ + Texts: []string{"hello", "goodbye"}, + Model: cohere.String("embed-english-v3.0"), + InputType: cohere.EmbedInputTypeSearchDocument.Ptr(), + }, + ) + + if err != nil { + log.Fatal(err) + } + + log.Printf("%+v", resp) + } + - sdk: typescript + name: Cohere TypeScript SDK + code: | + const { CohereClient } = require('cohere-ai'); - (async () => { - const embed = await cohere.embed({ - texts: ['hello', 'goodbye'], - model: 'embed-english-v3.0', - inputType: 'classification', + const cohere = new CohereClient({ + token: '<>', }); - console.log(embed); - })(); - - language: python - name: Sync - install: python -m pip install cohere --upgrade - code: > - import cohere + (async () => { + const embed = await cohere.embed({ + texts: ['hello', 'goodbye'], + model: 'embed-english-v3.0', + inputType: 'classification', + }); + console.log(embed); + })(); + - sdk: python + name: Sync + code: > + import cohere - co = cohere.Client("<>") + co = cohere.Client("<>") - response = co.embed( - texts=["hello", "goodbye"], model="embed-english-v3.0", input_type="classification" - ) - print(response) - - language: python - name: Async - install: python -m pip install cohere --upgrade - code: > - import cohere + response = co.embed( + texts=["hello", "goodbye"], model="embed-english-v3.0", input_type="classification" + ) - import asyncio + print(response) + - sdk: python + name: Async + code: > + import cohere + import asyncio - co = cohere.AsyncClient("<>") + co = cohere.AsyncClient("<>") - async def main(): - response = await co.embed( - texts=["hello", "goodbye"], model="embed-english-v3.0", input_type="classification" - ) - print(response) - asyncio.run(main()) - - language: java - name: Cohere java SDK - install: implementation 'com.cohere:cohere-java:1.0.4' - code: > - import com.cohere.api.Cohere; + async def main(): + response = await co.embed( + texts=["hello", "goodbye"], model="embed-english-v3.0", input_type="classification" + ) + print(response) - import com.cohere.api.requests.EmbedRequest; + asyncio.run(main()) + - sdk: java + name: Cohere java SDK + code: > + import com.cohere.api.Cohere; - import com.cohere.api.types.EmbedInputType; + import com.cohere.api.requests.EmbedRequest; - import com.cohere.api.types.EmbedResponse; + import com.cohere.api.types.EmbedInputType; + import com.cohere.api.types.EmbedResponse; - import java.util.List; + import java.util.List; - public class EmbedPost { - public static void main(String[] args) { - Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); - EmbedResponse response = cohere.embed(EmbedRequest.builder().texts(List.of("hello", "goodbye")).model("embed-english-v3.0").inputType(EmbedInputType.CLASSIFICATION).build()); + public class EmbedPost { + public static void main(String[] args) { + Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); - System.out.println(response); - } - } - - language: curl - name: cURL - code: |- - curl --request POST \ - --url https://api.cohere.com/v1/embed \ - --header 'accept: application/json' \ - --header 'content-type: application/json' \ - --header "Authorization: bearer $CO_API_KEY" \ - --data '{ - "model": "embed-english-v3.0", - "texts": ["hello", "goodbye"], - "input_type": "classification" - }' + EmbedResponse response = cohere.embed(EmbedRequest.builder().texts(List.of("hello", "goodbye")).model("embed-english-v3.0").inputType(EmbedInputType.CLASSIFICATION).build()); + + System.out.println(response); + } + } + - sdk: curl + name: cURL + code: |- + curl --request POST \ + --url https://api.cohere.com/v1/embed \ + --header 'accept: application/json' \ + --header 'content-type: application/json' \ + --header "Authorization: bearer $CO_API_KEY" \ + --data '{ + "model": "embed-english-v3.0", + "texts": ["hello", "goodbye"], + "input_type": "classification" + }' responses: "200": description: OK @@ -2567,191 +2519,172 @@ paths: * `"float"`: Use this when you want to get back the default float embeddings. Valid for all models. * `"int8"`: Use this when you want to get back signed int8 embeddings. Valid for only v3 models. - * `"uint8"`: Use this when you want to get back unsigned int8 embeddings. Valid for only v3 models. - * `"binary"`: Use this when you want to get back signed binary embeddings. Valid for only v3 models. - * `"ubinary"`: Use this when you want to get back unsigned binary embeddings. Valid for only v3 models. - writeOnly: true - truncate: - type: string - x-fern-audiences: - - public - default: END - enum: - - NONE - - START - - END - description: |- - One of `NONE|START|END` to specify how the API will handle inputs longer than the maximum token length. - - Passing `START` will discard the start of the input. `END` will discard the end of the input. In both cases, input is discarded until the remaining input is exactly the maximum input token length for the model. - - If `NONE` is selected, when the input exceeds the maximum input token length an error will be returned. - writeOnly: true - required: - - texts - examples: - Example: - value: - texts: - - hello - - goodbye - description: "" - /v1/embed-jobs: - post: - x-fern-audiences: - - public - parameters: - - $ref: "#/components/parameters/RequestSource" - summary: Create an Embed Job - operationId: create-embed-job - tags: - - /embed-jobs - x-fern-sdk-group-name: embed-jobs - x-fern-sdk-method-name: create - x-readme: - samples-languages: - - python - - java - - python - - java - - node - - curl - - go - code-samples: - - language: go - name: Cohere Go SDK - install: go get github.com/cohere-ai/cohere-go/v2 - code: | - package main - - import ( - "context" - "log" - - cohere "github.com/cohere-ai/cohere-go/v2" - client "github.com/cohere-ai/cohere-go/v2/client" - ) - - func main() { - co := client.NewClient(client.WithToken("<>")) - - resp, err := co.EmbedJobs.Create( - context.TODO(), - &cohere.CreateEmbedJobRequest{ - DatasetId: "dataset_id", - InputType: cohere.EmbedInputTypeSearchDocument, - }, - ) - - if err != nil { - log.Fatal(err) - } + * `"uint8"`: Use this when you want to get back unsigned int8 embeddings. Valid for only v3 models. + * `"binary"`: Use this when you want to get back signed binary embeddings. Valid for only v3 models. + * `"ubinary"`: Use this when you want to get back unsigned binary embeddings. Valid for only v3 models. + writeOnly: true + truncate: + type: string + x-fern-audiences: + - public + default: END + enum: + - NONE + - START + - END + description: |- + One of `NONE|START|END` to specify how the API will handle inputs longer than the maximum token length. - log.Printf("%+v", resp) - } - - language: python - name: Sync - install: python -m pip install cohere --upgrade - code: > - import cohere + Passing `START` will discard the start of the input. `END` will discard the end of the input. In both cases, input is discarded until the remaining input is exactly the maximum input token length for the model. + If `NONE` is selected, when the input exceeds the maximum input token length an error will be returned. + writeOnly: true + required: + - texts + description: "" + /v1/embed-jobs: + post: + x-fern-audiences: + - public + parameters: + - $ref: "#/components/parameters/RequestSource" + summary: Create an Embed Job + operationId: create-embed-job + tags: + - /embed-jobs + x-fern-sdk-group-name: embed-jobs + x-fern-sdk-method-name: create + x-fern-examples: + - code-samples: + - sdk: go + name: Cohere Go SDK + code: | + package main + + import ( + "context" + "log" + + cohere "github.com/cohere-ai/cohere-go/v2" + client "github.com/cohere-ai/cohere-go/v2/client" + ) + + func main() { + co := client.NewClient(client.WithToken("<>")) + + resp, err := co.EmbedJobs.Create( + context.TODO(), + &cohere.CreateEmbedJobRequest{ + DatasetId: "dataset_id", + InputType: cohere.EmbedInputTypeSearchDocument, + }, + ) + + if err != nil { + log.Fatal(err) + } + + log.Printf("%+v", resp) + } + - sdk: python + name: Sync + code: > + import cohere - co = cohere.Client("<>") + co = cohere.Client("<>") - # start an embed job - job = co.embed_jobs.create( - dataset_id="my-dataset-id", input_type="search_document", model="embed-english-v3.0" - ) + # start an embed job + job = co.embed_jobs.create( + dataset_id="my-dataset-id", input_type="search_document", model="embed-english-v3.0" + ) - # poll the server until the job is complete - response = co.wait(job) + # poll the server until the job is complete + response = co.wait(job) - print(response) - - language: python - name: Async - install: python -m pip install cohere --upgrade - code: > - import cohere - import asyncio + print(response) + - sdk: python + name: Async + code: > + import cohere + import asyncio - co = cohere.AsyncClient("<>") + co = cohere.AsyncClient("<>") - async def main(): - # start an embed job - job = await co.embed_jobs.create( - dataset_id="my-dataset-id", input_type="search_document", model="embed-english-v3.0" - ) - # poll the server until the job is complete - response = await co.wait(job) + async def main(): + # start an embed job + job = await co.embed_jobs.create( + dataset_id="my-dataset-id", input_type="search_document", model="embed-english-v3.0" + ) - print(response) + # poll the server until the job is complete + response = await co.wait(job) - asyncio.run(main()) - - language: java - name: Cohere java SDK - install: implementation 'com.cohere:cohere-java:1.0.4' - code: > - import com.cohere.api.Cohere; + print(response) - import - com.cohere.api.resources.embedjobs.requests.CreateEmbedJobRequest; + asyncio.run(main()) + - sdk: java + name: Cohere java SDK + code: > + import com.cohere.api.Cohere; - import com.cohere.api.types.CreateEmbedJobResponse; + import + com.cohere.api.resources.embedjobs.requests.CreateEmbedJobRequest; - import com.cohere.api.types.EmbedInputType; + import com.cohere.api.types.CreateEmbedJobResponse; + import com.cohere.api.types.EmbedInputType; - public class EmbedJobsPost { - public static void main(String[] args) { - Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); - CreateEmbedJobResponse response = cohere.embedJobs().create(CreateEmbedJobRequest.builder().model("embed-english-v3.0").datasetId("ds.id").inputType(EmbedInputType.SEARCH_DOCUMENT).build()); + public class EmbedJobsPost { + public static void main(String[] args) { + Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); - System.out.println(response); - } - } - - language: node - name: Cohere TypeScript SDK - install: npm i cohere-ai - code: | - const { CohereClient } = require('cohere-ai'); + CreateEmbedJobResponse response = cohere.embedJobs().create(CreateEmbedJobRequest.builder().model("embed-english-v3.0").datasetId("ds.id").inputType(EmbedInputType.SEARCH_DOCUMENT).build()); - const cohere = new CohereClient({ - token: '<>', - }); + System.out.println(response); + } + } + - sdk: typescript + name: Cohere TypeScript SDK + code: | + const { CohereClient } = require('cohere-ai'); - (async () => { - const embedJob = await cohere.embedJobs.create({ - datasetId: 'my-dataset', - inputType: 'search_document', - model: 'embed-english-v3.0', + const cohere = new CohereClient({ + token: '<>', }); - console.log(embedJob); - })(); - - language: curl - name: cURL - code: |- - curl --request POST \ - --url https://api.cohere.com/v1/embed-jobs \ - --header 'accept: application/json' \ - --header 'content-type: application/json' \ - --header "Authorization: bearer $CO_API_KEY" \ - --data '{ - "model": "embed-english-v3.0", - "dataset_id": "my-dataset" - }' + (async () => { + const embedJob = await cohere.embedJobs.create({ + datasetId: 'my-dataset', + inputType: 'search_document', + model: 'embed-english-v3.0', + }); + + console.log(embedJob); + })(); + - sdk: curl + name: cURL + code: |- + curl --request POST \ + --url https://api.cohere.com/v1/embed-jobs \ + --header 'accept: application/json' \ + --header 'content-type: application/json' \ + --header "Authorization: bearer $CO_API_KEY" \ + --data '{ + "model": "embed-english-v3.0", + "dataset_id": "my-dataset" + }' responses: "200": description: OK @@ -2811,109 +2744,96 @@ paths: - /embed-jobs x-fern-sdk-group-name: embed-jobs x-fern-sdk-method-name: list - x-readme: - samples-languages: - - python - - java - - python - - java - - node - - curl - - go - code-samples: - - language: go - name: Cohere Go SDK - install: go get github.com/cohere-ai/cohere-go/v2 - code: | - package main - - import ( - "context" - "log" + x-fern-examples: + - code-samples: + - sdk: go + name: Cohere Go SDK + code: | + package main - client "github.com/cohere-ai/cohere-go/v2/client" - ) + import ( + "context" + "log" - func main() { - co := client.NewClient(client.WithToken("<>")) + client "github.com/cohere-ai/cohere-go/v2/client" + ) - resp, err := co.EmbedJobs.Get(context.TODO(), "embed_job_id") + func main() { + co := client.NewClient(client.WithToken("<>")) - if err != nil { - log.Fatal(err) - } + resp, err := co.EmbedJobs.Get(context.TODO(), "embed_job_id") - log.Printf("%+v", resp) - } - - language: python - name: Sync - install: python -m pip install cohere --upgrade - code: | - import cohere + if err != nil { + log.Fatal(err) + } - co = cohere.Client("<>") + log.Printf("%+v", resp) + } + - sdk: python + name: Sync + code: | + import cohere - # list embed jobs - response = co.embed_jobs.list() + co = cohere.Client("<>") - print(response) - - language: python - name: Async - install: python -m pip install cohere --upgrade - code: | - import cohere - import asyncio + # list embed jobs + response = co.embed_jobs.list() - co = cohere.AsyncClient("<>") + print(response) + - sdk: python + name: Async + code: | + import cohere + import asyncio + co = cohere.AsyncClient("<>") - async def main(): - response = await co.embed_jobs.list() - print(response) + async def main(): + response = await co.embed_jobs.list() - asyncio.run(main()) - - language: java - name: Cohere java SDK - install: implementation 'com.cohere:cohere-java:1.0.4' - code: > - import com.cohere.api.Cohere; + print(response) - import com.cohere.api.types.ListEmbedJobResponse; + asyncio.run(main()) + - sdk: java + name: Cohere java SDK + code: > + import com.cohere.api.Cohere; + import com.cohere.api.types.ListEmbedJobResponse; - public class EmbedJobsGet { - public static void main(String[] args) { - Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); - ListEmbedJobResponse response = cohere.embedJobs().list(); + public class EmbedJobsGet { + public static void main(String[] args) { + Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); - System.out.println(response); - } - } - - language: node - name: Cohere TypeScript SDK - install: npm i cohere-ai - code: | - const { CohereClient } = require('cohere-ai'); + ListEmbedJobResponse response = cohere.embedJobs().list(); - const cohere = new CohereClient({ - token: '<>', - }); + System.out.println(response); + } + } + - sdk: typescript + name: Cohere TypeScript SDK + code: | + const { CohereClient } = require('cohere-ai'); - (async () => { - const embedJobs = await cohere.embedJobs.list(); + const cohere = new CohereClient({ + token: '<>', + }); - console.log(embedJobs); - })(); - - language: curl - name: cURL - code: |- - curl --request GET \ - --url https://api.cohere.com/v1/embed-jobs \ - --header 'accept: application/json' \ - --header "Authorization: bearer $CO_API_KEY" + (async () => { + const embedJobs = await cohere.embedJobs.list(); + + console.log(embedJobs); + })(); + - sdk: curl + name: cURL + code: |- + curl --request GET \ + --url https://api.cohere.com/v1/embed-jobs \ + --header 'accept: application/json' \ + --header "Authorization: bearer $CO_API_KEY" responses: "200": description: OK @@ -2974,109 +2894,96 @@ paths: - /embed-jobs x-fern-sdk-group-name: embed-jobs x-fern-sdk-method-name: get - x-readme: - samples-languages: - - python - - java - - python - - java - - node - - curl - - go - code-samples: - - language: go - name: Cohere Go SDK - install: go get github.com/cohere-ai/cohere-go/v2 - code: | - package main - - import ( - "context" - "log" + x-fern-examples: + - code-samples: + - sdk: go + name: Cohere Go SDK + code: | + package main - client "github.com/cohere-ai/cohere-go/v2/client" - ) + import ( + "context" + "log" - func main() { - co := client.NewClient(client.WithToken("<>")) + client "github.com/cohere-ai/cohere-go/v2/client" + ) - resp, err := co.EmbedJobs.List(context.TODO()) + func main() { + co := client.NewClient(client.WithToken("<>")) - if err != nil { - log.Fatal(err) - } + resp, err := co.EmbedJobs.List(context.TODO()) - log.Printf("%+v", resp) - } - - language: python - name: Sync - install: python -m pip install cohere --upgrade - code: | - import cohere + if err != nil { + log.Fatal(err) + } - co = cohere.Client("<>") + log.Printf("%+v", resp) + } + - sdk: python + name: Sync + code: | + import cohere - # get embed job - response = co.embed_jobs.get("job_id") + co = cohere.Client("<>") - print(response) - - language: python - name: Async - install: python -m pip install cohere --upgrade - code: | - import cohere - import asyncio + # get embed job + response = co.embed_jobs.get("job_id") - co = cohere.AsyncClient("<>") + print(response) + - sdk: python + name: Async + code: | + import cohere + import asyncio + co = cohere.AsyncClient("<>") - async def main(): - response = await co.embed_jobs.get("job_id") - print(response) + async def main(): + response = await co.embed_jobs.get("job_id") - asyncio.run(main()) - - language: java - name: Cohere java SDK - install: implementation 'com.cohere:cohere-java:1.0.4' - code: > - import com.cohere.api.Cohere; + print(response) - import com.cohere.api.types.ListEmbedJobResponse; + asyncio.run(main()) + - sdk: java + name: Cohere java SDK + code: > + import com.cohere.api.Cohere; + import com.cohere.api.types.ListEmbedJobResponse; - public class EmbedJobsGet { - public static void main(String[] args) { - Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); - ListEmbedJobResponse response = cohere.embedJobs().list(); + public class EmbedJobsGet { + public static void main(String[] args) { + Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); - System.out.println(response); - } - } - - language: node - name: Cohere TypeScript SDK - install: npm i cohere-ai - code: | - const { CohereClient } = require('cohere-ai'); + ListEmbedJobResponse response = cohere.embedJobs().list(); - const cohere = new CohereClient({ - token: '<>', - }); + System.out.println(response); + } + } + - sdk: typescript + name: Cohere TypeScript SDK + code: | + const { CohereClient } = require('cohere-ai'); - (async () => { - const embedJob = await cohere.embedJobs.get('job_id'); + const cohere = new CohereClient({ + token: '<>', + }); - console.log(embedJob); - })(); - - language: curl - name: cURL - code: |- - curl --request GET \ - --url https://api.cohere.com/v1/embed-jobs/id \ - --header 'accept: application/json' \ - --header "Authorization: bearer $CO_API_KEY" + (async () => { + const embedJob = await cohere.embedJobs.get('job_id'); + + console.log(embedJob); + })(); + - sdk: curl + name: cURL + code: |- + curl --request GET \ + --url https://api.cohere.com/v1/embed-jobs/id \ + --header 'accept: application/json' \ + --header "Authorization: bearer $CO_API_KEY" responses: "200": description: OK @@ -3127,109 +3034,96 @@ paths: required: true description: The ID of the embed job to cancel. schema: - type: string - x-fern-audiences: - - public - - $ref: "#/components/parameters/RequestSource" - summary: Cancel an Embed Job - operationId: cancel-embed-job - tags: - - /embed-jobs - x-fern-sdk-group-name: embed-jobs - x-fern-sdk-method-name: cancel - x-readme: - samples-languages: - - python - - java - - python - - java - - node - - curl - - go - code-samples: - - language: go - name: Cohere Go SDK - install: go get github.com/cohere-ai/cohere-go/v2 - code: | - package main - - import ( - "context" - "log" + type: string + x-fern-audiences: + - public + - $ref: "#/components/parameters/RequestSource" + summary: Cancel an Embed Job + operationId: cancel-embed-job + tags: + - /embed-jobs + x-fern-sdk-group-name: embed-jobs + x-fern-sdk-method-name: cancel + x-fern-examples: + - code-samples: + - sdk: go + name: Cohere Go SDK + code: | + package main - client "github.com/cohere-ai/cohere-go/v2/client" - ) + import ( + "context" + "log" - func main() { - co := client.NewClient(client.WithToken("<>")) + client "github.com/cohere-ai/cohere-go/v2/client" + ) - err := co.EmbedJobs.Cancel(context.TODO(), "embed_job_id") + func main() { + co := client.NewClient(client.WithToken("<>")) - if err != nil { - log.Fatal(err) - } + err := co.EmbedJobs.Cancel(context.TODO(), "embed_job_id") - } - - language: python - name: Sync - install: python -m pip install cohere --upgrade - code: | - import cohere + if err != nil { + log.Fatal(err) + } - co = cohere.Client("<>") + } + - sdk: python + name: Sync + code: | + import cohere - # cancel an embed job - co.embed_jobs.cancel("job_id") - - language: python - name: Async - install: python -m pip install cohere --upgrade - code: | - import cohere - import asyncio + co = cohere.Client("<>") - co = cohere.AsyncClient("<>") + # cancel an embed job + co.embed_jobs.cancel("job_id") + - sdk: python + name: Async + code: | + import cohere + import asyncio + co = cohere.AsyncClient("<>") - async def main(): - await co.embed_jobs.cancel("job_id") - - language: java - name: Cohere java SDK - install: implementation 'com.cohere:cohere-java:1.0.4' - code: > - import com.cohere.api.Cohere; + async def main(): + await co.embed_jobs.cancel("job_id") + - sdk: java + name: Cohere java SDK + code: > + import com.cohere.api.Cohere; - public class EmbedJobsCancel { - public static void main(String[] args) { - Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); - cohere.embedJobs().cancel("job_id"); - } - } - - language: node - name: Cohere TypeScript SDK - install: npm i cohere-ai - code: | - const { CohereClient } = require('cohere-ai'); + public class EmbedJobsCancel { + public static void main(String[] args) { + Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); - const cohere = new CohereClient({ - token: '<>', - }); + cohere.embedJobs().cancel("job_id"); + } + } + - sdk: typescript + name: Cohere TypeScript SDK + code: | + const { CohereClient } = require('cohere-ai'); - (async () => { - const embedJob = await cohere.embedJobs.cancel('job_id'); + const cohere = new CohereClient({ + token: '<>', + }); - console.log(embedJob); - })(); - - language: curl - name: cURL - code: |- - curl --request POST \ - --url https://api.cohere.com/v1/embed-jobs/id/cancel \ - --header 'accept: application/json' \ - --header 'content-type: application/json' \ - --header "Authorization: bearer $CO_API_KEY" + (async () => { + const embedJob = await cohere.embedJobs.cancel('job_id'); + + console.log(embedJob); + })(); + - sdk: curl + name: cURL + code: |- + curl --request POST \ + --url https://api.cohere.com/v1/embed-jobs/id/cancel \ + --header 'accept: application/json' \ + --header 'content-type: application/json' \ + --header "Authorization: bearer $CO_API_KEY" responses: "200": description: OK @@ -3445,462 +3339,422 @@ paths: required: - query - documents - examples: - Example: - value: - model: rerank-english-v3.0 - query: What is the capital of the United States? - documents: - - Carson City is the capital city of the American state of - Nevada. - - The Commonwealth of the Northern Mariana Islands is a - group of islands in the Pacific Ocean. Its capital is - Saipan. - - Washington, D.C. (also known as simply Washington or D.C., - and officially as the District of Columbia) is the capital - of the United States. It is a federal district. - - Capital punishment (the death penalty) has existed in the - United States since beforethe United States was a country. - As of 2017, capital punishment is legal in 30 of the 50 - states. description: "" description: This endpoint takes in a query and a list of texts and produces an ordered array with each text assigned a relevance score. - x-readme: - samples-languages: - - python - - java - - curl - - node - - go - code-samples: - - language: go - name: Cohere Go SDK - install: go get github.com/cohere-ai/cohere-go/v2 - code: > - package main - - - import ( - "context" - "log" - - cohere "github.com/cohere-ai/cohere-go/v2" - client "github.com/cohere-ai/cohere-go/v2/client" - ) - - - func main() { - co := client.NewClient(client.WithToken("<>")) - - resp, err := co.Rerank( - context.TODO(), - &cohere.RerankRequest{ - Query: "What is the capital of the United States?", - Documents: []*cohere.RerankRequestDocumentsItem{ - {String: "Carson City is the capital city of the American state of Nevada."}, - {String: "The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan."}, - {String: "Capitalization or capitalisation in English grammar is the use of a capital letter at the start of a word. English usage varies from capitalization in other languages."}, - {String: "Washington, D.C. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district."}, - }, - Model: cohere.String("rerank-english-v3.0"), - }, - ) - - if err != nil { - log.Fatal(err) - } - - log.Printf("%+v", resp) - } - - language: node - name: Cohere TypeScript SDK - install: npm i cohere-ai - code: > - const { CohereClient } = require('cohere-ai'); - - - const cohere = new CohereClient({ - token: '<>', - }); + x-fern-examples: + - code-samples: + - sdk: go + name: Cohere Go SDK + code: > + package main + + + import ( + "context" + "log" + + cohere "github.com/cohere-ai/cohere-go/v2" + client "github.com/cohere-ai/cohere-go/v2/client" + ) + + + func main() { + co := client.NewClient(client.WithToken("<>")) + + resp, err := co.Rerank( + context.TODO(), + &cohere.RerankRequest{ + Query: "What is the capital of the United States?", + Documents: []*cohere.RerankRequestDocumentsItem{ + {String: "Carson City is the capital city of the American state of Nevada."}, + {String: "The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan."}, + {String: "Capitalization or capitalisation in English grammar is the use of a capital letter at the start of a word. English usage varies from capitalization in other languages."}, + {String: "Washington, D.C. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district."}, + }, + Model: cohere.String("rerank-english-v3.0"), + }, + ) + + if err != nil { + log.Fatal(err) + } + + log.Printf("%+v", resp) + } + - sdk: typescript + name: Cohere TypeScript SDK + code: > + const { CohereClient } = require('cohere-ai'); - (async () => { - const rerank = await cohere.rerank({ - documents: [ - { text: 'Carson City is the capital city of the American state of Nevada.' }, - { - text: 'The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan.', - }, - { - text: 'Capitalization or capitalisation in English grammar is the use of a capital letter at the start of a word. English usage varies from capitalization in other languages.', - }, - { - text: 'Washington, D.C. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district.', - }, - { - text: 'Capital punishment (the death penalty) has existed in the United States since beforethe United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states.', - }, - ], - query: 'What is the capital of the United States?', - topN: 3, - model: 'rerank-english-v3.0', + const cohere = new CohereClient({ + token: '<>', }); - console.log(rerank); - })(); - - language: python - name: Sync - install: python -m pip install cohere --upgrade - code: > - import cohere - - - co = cohere.Client("<>") - - docs = [ - "Carson City is the capital city of the American state of Nevada.", - "The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan.", - "Capitalization or capitalisation in English grammar is the use of a capital letter at the start of a word. English usage varies from capitalization in other languages.", - "Washington, D.C. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district.", - "Capital punishment (the death penalty) has existed in the United States since beforethe United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states.", - ] - - - response = co.rerank( - model="rerank-english-v3.0", - query="What is the capital of the United States?", - documents=docs, - top_n=3, - ) - - print(response) - - language: python - name: Async - install: python -m pip install cohere --upgrade - code: > - import cohere - - import asyncio - - - co = cohere.AsyncClient("<>") - - - docs = [ - "Carson City is the capital city of the American state of Nevada.", - "The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan.", - "Capitalization or capitalisation in English grammar is the use of a capital letter at the start of a word. English usage varies from capitalization in other languages.", - "Washington, D.C. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district.", - "Capital punishment (the death penalty) has existed in the United States since beforethe United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states.", - ] - - - - async def main(): - response = await co.rerank( - model="rerank-english-v2.0", - query="What is the capital of the United States?", - documents=docs, - top_n=3, - ) - print(response) - - asyncio.run(main()) - - language: java - name: Cohere java SDK - install: implementation 'com.cohere:cohere-java:1.0.4' - code: > - import com.cohere.api.Cohere; - - import com.cohere.api.requests.RerankRequest; - - import com.cohere.api.types.RerankRequestDocumentsItem; - - import com.cohere.api.types.RerankResponse; - - - import java.util.List; - - - - public class RerankPost { - public static void main(String[] args) { - Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); - - RerankResponse response = cohere.rerank(RerankRequest.builder().query("What is the capital of the United States?").documents(List.of( - RerankRequestDocumentsItem.of("Carson City is the capital city of the American state of Nevada."), - RerankRequestDocumentsItem.of("The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan."), - RerankRequestDocumentsItem.of("Capitalization or capitalisation in English grammar is the use of a capital letter at the start of a word. English usage varies from capitalization in other languages."), - RerankRequestDocumentsItem.of("Washington, D.C. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district."), - RerankRequestDocumentsItem.of("Capital punishment (the death penalty) has existed in the United States since beforethe United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states.") - )).model("rerank-english-v3.0").topN(3).build()); - - System.out.println(response); - } - } - - language: curl - name: cURL - code: >- - curl --request POST \ - --url https://api.cohere.com/v1/rerank \ - --header 'accept: application/json' \ - --header 'content-type: application/json' \ - --header "Authorization: bearer $CO_API_KEY" \ - --data '{ - "model": "rerank-english-v3.0", - "query": "What is the capital of the United States?", - "top_n": 3, - "documents": ["Carson City is the capital city of the American state of Nevada.", - "The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan.", - "Washington, D.C. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district.", - "Capitalization or capitalisation in English grammar is the use of a capital letter at the start of a word. English usage varies from capitalization in other languages.", - "Capital punishment (the death penalty) has existed in the United States since beforethe United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states."] - }' - /v1/classify: - post: - parameters: - - $ref: "#/components/parameters/RequestSource" - x-fern-audiences: - - public - summary: Classify - operationId: classify - x-readme: - samples-languages: - - python - - java - - curl - - node - - go - code-samples: - - language: go - name: Cohere Go SDK - install: go get github.com/cohere-ai/cohere-go/v2 - code: | - package main - - import ( - "context" - "log" - - cohere "github.com/cohere-ai/cohere-go/v2" - client "github.com/cohere-ai/cohere-go/v2/client" - ) - - func main() { - co := client.NewClient(client.WithToken("<>")) - - resp, err := co.Classify( - context.TODO(), - &cohere.ClassifyRequest{ - Examples: []*cohere.ClassifyExample{ - { - Text: cohere.String("orange"), - Label: cohere.String("fruit"), - }, - { - Text: cohere.String("pear"), - Label: cohere.String("fruit"), - }, - { - Text: cohere.String("lettuce"), - Label: cohere.String("vegetable"), - }, - { - Text: cohere.String("cauliflower"), - Label: cohere.String("vegetable"), - }, - }, - Inputs: []string{"peach"}, - }, - ) + (async () => { + const rerank = await cohere.rerank({ + documents: [ + { text: 'Carson City is the capital city of the American state of Nevada.' }, + { + text: 'The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan.', + }, + { + text: 'Capitalization or capitalisation in English grammar is the use of a capital letter at the start of a word. English usage varies from capitalization in other languages.', + }, + { + text: 'Washington, D.C. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district.', + }, + { + text: 'Capital punishment (the death penalty) has existed in the United States since beforethe United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states.', + }, + ], + query: 'What is the capital of the United States?', + topN: 3, + model: 'rerank-english-v3.0', + }); - if err != nil { - log.Fatal(err) - } + console.log(rerank); + })(); + - sdk: python + name: Sync + code: > + import cohere - log.Printf("%+v", resp) - } - - language: node - name: Cohere TypeScript SDK - install: npm i cohere-ai - code: > - const { CohereClient } = require('cohere-ai'); + co = cohere.Client("<>") - const cohere = new CohereClient({ - token: '<>', - }); + docs = [ + "Carson City is the capital city of the American state of Nevada.", + "The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan.", + "Capitalization or capitalisation in English grammar is the use of a capital letter at the start of a word. English usage varies from capitalization in other languages.", + "Washington, D.C. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district.", + "Capital punishment (the death penalty) has existed in the United States since beforethe United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states.", + ] - (async () => { - const classify = await cohere.classify({ - examples: [ - { text: "Dermatologists don't like her!", label: 'Spam' }, - { text: "'Hello, open to this?'", label: 'Spam' }, - { text: 'I need help please wire me $1000 right now', label: 'Spam' }, - { text: 'Nice to know you ;)', label: 'Spam' }, - { text: 'Please help me?', label: 'Spam' }, - { text: 'Your parcel will be delivered today', label: 'Not spam' }, - { text: 'Review changes to our Terms and Conditions', label: 'Not spam' }, - { text: 'Weekly sync notes', label: 'Not spam' }, - { text: "'Re: Follow up from today's meeting'", label: 'Not spam' }, - { text: 'Pre-read for tomorrow', label: 'Not spam' }, - ], - inputs: ['Confirm your email address', 'hey i need u to send some $'], - }); - console.log(classify); - })(); - - language: python - name: Sync - install: python -m pip install cohere --upgrade - code: > - import cohere + response = co.rerank( + model="rerank-english-v3.0", + query="What is the capital of the United States?", + documents=docs, + top_n=3, + ) - from cohere import ClassifyExample + print(response) + - sdk: python + name: Async + code: > + import cohere + import asyncio - co = cohere.Client("<>") - examples = [ - ClassifyExample(text="Dermatologists don't like her!", label="Spam"), - ClassifyExample(text="'Hello, open to this?'", label="Spam"), - ClassifyExample( - text="I need help please wire me $1000 right now", label="Spam"), - ClassifyExample(text="Nice to know you ;)", label="Spam"), - ClassifyExample(text="Please help me?", label="Spam"), - ClassifyExample(text="Your parcel will be delivered today", - label="Not spam"), - ClassifyExample( - text="Review changes to our Terms and Conditions", label="Not spam" - ), - ClassifyExample(text="Weekly sync notes", label="Not spam"), - ClassifyExample(text="'Re: Follow up from today's meeting'", - label="Not spam"), - ClassifyExample(text="Pre-read for tomorrow", label="Not spam"), - ] - - inputs = [ - "Confirm your email address", - "hey i need u to send some $", - ] - - response = co.classify( - inputs=inputs, - examples=examples, - ) + co = cohere.AsyncClient("<>") - print(response) - - language: python - name: Async - install: python -m pip install cohere --upgrade - code: > - import cohere - import asyncio + docs = [ + "Carson City is the capital city of the American state of Nevada.", + "The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan.", + "Capitalization or capitalisation in English grammar is the use of a capital letter at the start of a word. English usage varies from capitalization in other languages.", + "Washington, D.C. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district.", + "Capital punishment (the death penalty) has existed in the United States since beforethe United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states.", + ] - from cohere import ClassifyExample - co = cohere.AsyncClient("<>") + async def main(): + response = await co.rerank( + model="rerank-english-v2.0", + query="What is the capital of the United States?", + documents=docs, + top_n=3, + ) + print(response) - examples = [ - ClassifyExample(text="Dermatologists don't like her!", label="Spam"), - ClassifyExample(text="'Hello, open to this?'", label="Spam"), - ClassifyExample( - text="I need help please wire me $1000 right now", label="Spam"), - ClassifyExample(text="Nice to know you ;)", label="Spam"), - ClassifyExample(text="Please help me?", label="Spam"), - ClassifyExample(text="Your parcel will be delivered today", - label="Not spam"), - ClassifyExample( - text="Review changes to our Terms and Conditions", label="Not spam" - ), - ClassifyExample(text="Weekly sync notes", label="Not spam"), - ClassifyExample(text="'Re: Follow up from today's meeting'", - label="Not spam"), - ClassifyExample(text="Pre-read for tomorrow", label="Not spam"), - ] - - inputs = [ - "Confirm your email address", - "hey i need u to send some $", - ] + asyncio.run(main()) + - sdk: java + name: Cohere java SDK + code: > + import com.cohere.api.Cohere; + import com.cohere.api.requests.RerankRequest; + import com.cohere.api.types.RerankRequestDocumentsItem; - async def main(): - response = await co.classify( - inputs=inputs, - examples=examples, - ) - print(response) + import com.cohere.api.types.RerankResponse; - asyncio.run(main()) - - language: java - name: Cohere java SDK - install: implementation 'com.cohere:cohere-java:1.0.4' - code: > - import com.cohere.api.Cohere; - import com.cohere.api.requests.ClassifyRequest; + import java.util.List; - import com.cohere.api.types.ClassifyExample; - import com.cohere.api.types.ClassifyResponse; + public class RerankPost { + public static void main(String[] args) { + Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); - import java.util.List; + RerankResponse response = cohere.rerank(RerankRequest.builder().query("What is the capital of the United States?").documents(List.of( + RerankRequestDocumentsItem.of("Carson City is the capital city of the American state of Nevada."), + RerankRequestDocumentsItem.of("The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan."), + RerankRequestDocumentsItem.of("Capitalization or capitalisation in English grammar is the use of a capital letter at the start of a word. English usage varies from capitalization in other languages."), + RerankRequestDocumentsItem.of("Washington, D.C. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district."), + RerankRequestDocumentsItem.of("Capital punishment (the death penalty) has existed in the United States since beforethe United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states.") + )).model("rerank-english-v3.0").topN(3).build()); + System.out.println(response); + } + } + - sdk: curl + name: cURL + code: >- + curl --request POST \ + --url https://api.cohere.com/v1/rerank \ + --header 'accept: application/json' \ + --header 'content-type: application/json' \ + --header "Authorization: bearer $CO_API_KEY" \ + --data '{ + "model": "rerank-english-v3.0", + "query": "What is the capital of the United States?", + "top_n": 3, + "documents": ["Carson City is the capital city of the American state of Nevada.", + "The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan.", + "Washington, D.C. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district.", + "Capitalization or capitalisation in English grammar is the use of a capital letter at the start of a word. English usage varies from capitalization in other languages.", + "Capital punishment (the death penalty) has existed in the United States since beforethe United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states."] + }' + /v1/classify: + post: + parameters: + - $ref: "#/components/parameters/RequestSource" + x-fern-audiences: + - public + summary: Classify + operationId: classify + x-fern-examples: + - code-samples: + - sdk: go + name: Cohere Go SDK + code: | + package main + + import ( + "context" + "log" + + cohere "github.com/cohere-ai/cohere-go/v2" + client "github.com/cohere-ai/cohere-go/v2/client" + ) + + func main() { + co := client.NewClient(client.WithToken("<>")) + + resp, err := co.Classify( + context.TODO(), + &cohere.ClassifyRequest{ + Examples: []*cohere.ClassifyExample{ + { + Text: cohere.String("orange"), + Label: cohere.String("fruit"), + }, + { + Text: cohere.String("pear"), + Label: cohere.String("fruit"), + }, + { + Text: cohere.String("lettuce"), + Label: cohere.String("vegetable"), + }, + { + Text: cohere.String("cauliflower"), + Label: cohere.String("vegetable"), + }, + }, + Inputs: []string{"peach"}, + }, + ) + + if err != nil { + log.Fatal(err) + } + + log.Printf("%+v", resp) + } + - sdk: typescript + name: Cohere TypeScript SDK + code: > + const { CohereClient } = require('cohere-ai'); - public class ClassifyPost { - public static void main(String[] args) { - Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); + const cohere = new CohereClient({ + token: '<>', + }); - ClassifyResponse response = cohere.classify(ClassifyRequest.builder().addAllInputs( - List.of("Confirm your email address", "hey i need u to send some $") - ).examples(List.of( - ClassifyExample.builder().text("Dermatologists don't like her!").label("Spam").build(), - ClassifyExample.builder().text("'Hello, open to this?'").label("Spam").build(), - ClassifyExample.builder().text("I need help please wire me $1000 right now").label("Spam").build(), - ClassifyExample.builder().text("Nice to know you ;)").label("Spam").build(), - ClassifyExample.builder().text("Please help me?").label("Spam").build(), - ClassifyExample.builder().text("Your parcel will be delivered today").label("Not spam").build(), - ClassifyExample.builder().text("Review changes to our Terms and Conditions").label("Not spam").build(), - ClassifyExample.builder().text("Weekly sync notes").label("Not spam").build(), - ClassifyExample.builder().text("'Re: Follow up from today's meeting'").label("Not spam").build(), - ClassifyExample.builder().text("Pre-read for tomorrow").label("Not spam").build() - )).build()); - System.out.println(response); - } - } - - language: curl - name: cURL - code: >- - curl --request POST \ - --url https://api.cohere.com/v1/classify \ - --header 'accept: application/json' \ - --header 'content-type: application/json' \ - --header "Authorization: bearer $CO_API_KEY" \ - --data '{ - "inputs": ["Confirm your email address", "hey i need u to send some $"], - "examples": [ - {"text": "Dermatologists don'\''t like her!","label": "Spam"}, - {"text": "'\''Hello, open to this?'\''","label": "Spam"}, - {"text": "I need help please wire me $1000 right now","label": "Spam"}, - {"text": "Nice to know you ;)","label": "Spam"}, - {"text": "Please help me?","label": "Spam"}, - {"text": "Your parcel will be delivered today","label": "Not spam"}, - {"text": "Review changes to our Terms and Conditions","label": "Not spam"}, - {"text": "Weekly sync notes","label": "Not spam"}, - {"text": "'\''Re: Follow up from today'\''s meeting'\''","label": "Not spam"}, - {"text": "Pre-read for tomorrow","label": "Not spam"} - ] - }' + (async () => { + const classify = await cohere.classify({ + examples: [ + { text: "Dermatologists don't like her!", label: 'Spam' }, + { text: "'Hello, open to this?'", label: 'Spam' }, + { text: 'I need help please wire me $1000 right now', label: 'Spam' }, + { text: 'Nice to know you ;)', label: 'Spam' }, + { text: 'Please help me?', label: 'Spam' }, + { text: 'Your parcel will be delivered today', label: 'Not spam' }, + { text: 'Review changes to our Terms and Conditions', label: 'Not spam' }, + { text: 'Weekly sync notes', label: 'Not spam' }, + { text: "'Re: Follow up from today's meeting'", label: 'Not spam' }, + { text: 'Pre-read for tomorrow', label: 'Not spam' }, + ], + inputs: ['Confirm your email address', 'hey i need u to send some $'], + }); + + console.log(classify); + })(); + - sdk: python + name: Sync + code: > + import cohere + + from cohere import ClassifyExample + + + co = cohere.Client("<>") + + examples = [ + ClassifyExample(text="Dermatologists don't like her!", label="Spam"), + ClassifyExample(text="'Hello, open to this?'", label="Spam"), + ClassifyExample( + text="I need help please wire me $1000 right now", label="Spam"), + ClassifyExample(text="Nice to know you ;)", label="Spam"), + ClassifyExample(text="Please help me?", label="Spam"), + ClassifyExample(text="Your parcel will be delivered today", + label="Not spam"), + ClassifyExample( + text="Review changes to our Terms and Conditions", label="Not spam" + ), + ClassifyExample(text="Weekly sync notes", label="Not spam"), + ClassifyExample(text="'Re: Follow up from today's meeting'", + label="Not spam"), + ClassifyExample(text="Pre-read for tomorrow", label="Not spam"), + ] + + inputs = [ + "Confirm your email address", + "hey i need u to send some $", + ] + + response = co.classify( + inputs=inputs, + examples=examples, + ) + + print(response) + - sdk: python + name: Async + code: > + import cohere + + import asyncio + + from cohere import ClassifyExample + + + co = cohere.AsyncClient("<>") + + examples = [ + ClassifyExample(text="Dermatologists don't like her!", label="Spam"), + ClassifyExample(text="'Hello, open to this?'", label="Spam"), + ClassifyExample( + text="I need help please wire me $1000 right now", label="Spam"), + ClassifyExample(text="Nice to know you ;)", label="Spam"), + ClassifyExample(text="Please help me?", label="Spam"), + ClassifyExample(text="Your parcel will be delivered today", + label="Not spam"), + ClassifyExample( + text="Review changes to our Terms and Conditions", label="Not spam" + ), + ClassifyExample(text="Weekly sync notes", label="Not spam"), + ClassifyExample(text="'Re: Follow up from today's meeting'", + label="Not spam"), + ClassifyExample(text="Pre-read for tomorrow", label="Not spam"), + ] + + inputs = [ + "Confirm your email address", + "hey i need u to send some $", + ] + + + + async def main(): + response = await co.classify( + inputs=inputs, + examples=examples, + ) + print(response) + + asyncio.run(main()) + - sdk: java + name: Cohere java SDK + code: > + import com.cohere.api.Cohere; + + import com.cohere.api.requests.ClassifyRequest; + + import com.cohere.api.types.ClassifyExample; + + import com.cohere.api.types.ClassifyResponse; + + + import java.util.List; + + + + public class ClassifyPost { + public static void main(String[] args) { + Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); + + ClassifyResponse response = cohere.classify(ClassifyRequest.builder().addAllInputs( + List.of("Confirm your email address", "hey i need u to send some $") + ).examples(List.of( + ClassifyExample.builder().text("Dermatologists don't like her!").label("Spam").build(), + ClassifyExample.builder().text("'Hello, open to this?'").label("Spam").build(), + ClassifyExample.builder().text("I need help please wire me $1000 right now").label("Spam").build(), + ClassifyExample.builder().text("Nice to know you ;)").label("Spam").build(), + ClassifyExample.builder().text("Please help me?").label("Spam").build(), + ClassifyExample.builder().text("Your parcel will be delivered today").label("Not spam").build(), + ClassifyExample.builder().text("Review changes to our Terms and Conditions").label("Not spam").build(), + ClassifyExample.builder().text("Weekly sync notes").label("Not spam").build(), + ClassifyExample.builder().text("'Re: Follow up from today's meeting'").label("Not spam").build(), + ClassifyExample.builder().text("Pre-read for tomorrow").label("Not spam").build() + )).build()); + + System.out.println(response); + } + } + - sdk: curl + name: cURL + code: >- + curl --request POST \ + --url https://api.cohere.com/v1/classify \ + --header 'accept: application/json' \ + --header 'content-type: application/json' \ + --header "Authorization: bearer $CO_API_KEY" \ + --data '{ + "inputs": ["Confirm your email address", "hey i need u to send some $"], + "examples": [ + {"text": "Dermatologists don'\''t like her!","label": "Spam"}, + {"text": "'\''Hello, open to this?'\''","label": "Spam"}, + {"text": "I need help please wire me $1000 right now","label": "Spam"}, + {"text": "Nice to know you ;)","label": "Spam"}, + {"text": "Please help me?","label": "Spam"}, + {"text": "Your parcel will be delivered today","label": "Not spam"}, + {"text": "Review changes to our Terms and Conditions","label": "Not spam"}, + {"text": "Weekly sync notes","label": "Not spam"}, + {"text": "'\''Re: Follow up from today'\''s meeting'\''","label": "Not spam"}, + {"text": "Pre-read for tomorrow","label": "Not spam"} + ] + }' responses: "200": description: OK @@ -3910,38 +3764,6 @@ paths: type: object x-fern-audiences: - public - x-examples: - Example: - id: ca245541-8841-456e-b306-293370789a30 - classifications: - - id: c50ab0d9-95d8-44de-ba90-9647a1718744 - input: Confirm your email address - prediction: Not spam - predictions: - - Not spam - confidence: 0.7581943 - confidences: - - 0.7581943 - labels: - Not spam: - confidence: 0.7581943 - Spam: - confidence: 0.24180566 - classification_type: single-label - - id: 8a841de2-027f-49d4-8c91-e88fa1865b89 - input: hey i need u to send some $ - prediction: Spam - predictions: - - Spam - confidence: 0.9965721 - confidences: - - 0.9965721 - labels: - Not spam: - confidence: 0.0034279241 - Spam: - confidence: 0.9965721 - classification_type: single-label properties: id: type: string @@ -4054,42 +3876,6 @@ paths: required: - id - classifications - examples: - Example: - value: - id: ca245541-8841-456e-b306-293370789a30 - classifications: - - id: c50ab0d9-95d8-44de-ba90-9647a1718744 - input: Confirm your email address - prediction: Not spam - predictions: - - Not spam - confidence: 0.7581943 - confidences: - - 0.7581943 - labels: - Not spam: - confidence: 0.7581943 - Spam: - confidence: 0.24180566 - classification_type: single-label - - id: 8a841de2-027f-49d4-8c91-e88fa1865b89 - input: hey i need u to send some $ - prediction: Spam - predictions: - - Spam - confidence: 0.9965721 - confidences: - - 0.9965721 - labels: - Not spam: - confidence: 0.0034279241 - Spam: - confidence: 0.9965721 - classification_type: single-label - meta: - api_version: - version: "1" headers: X-API-Warning: schema: @@ -4131,61 +3917,26 @@ paths: type: object x-fern-audiences: - public - x-examples: - Example: - inputs: - - Confirm your email address - - hey i need u to send some $ - examples: - - text: Dermatologists don't like her! - label: Spam - - text: Hello, open to this? - label: Spam - - text: I need help please wire me $1000 right now - label: Spam - - text: Nice to know you ;) - label: Spam - - text: Please help me? - label: Spam - - text: Your parcel will be delivered today - label: Not spam - - text: Review changes to our Terms and Conditions - label: Not spam - - text: Weekly sync notes - label: Not spam - - text: "Re: Follow up from today’s meeting" - label: Not spam - - text: Pre-read for tomorrow - label: Not spam properties: inputs: type: array x-fern-audiences: - public maxItems: 96 - description: |- - A list of up to 96 texts to be classified. Each one must be a non-empty string. - There is, however, no consistent, universal limit to the length a particular input can be. We perform classification on the first `x` tokens of each input, and `x` varies depending on which underlying model is powering classification. The maximum token length for each model is listed in the "max tokens" column [here](https://docs.cohere.com/docs/models). - Note: by default the `truncate` parameter is set to `END`, so tokens exceeding the limit will be automatically dropped. This behavior can be disabled by setting `truncate` to `NONE`, which will result in validation errors for longer texts. + description: A list of up to 96 texts to be classified. Each one must be a + non-empty string. + "There is, however, no consistent, universal limit to the length a particular input can be. We perform classification on the first `x` tokens of each input, and `x` varies depending on which underlying model is powering classification. The maximum token length for each model is listed in the \"max tokens\" column [here](https://docs.cohere.com/docs/models).\nNote": + by default the `truncate` parameter is set to `END`, so + tokens exceeding the limit will be automatically dropped. + This behavior can be disabled by setting `truncate` to + `NONE`, which will result in validation errors for longer + texts.' items: type: string x-fern-audiences: - public writeOnly: true writeOnly: true - examples: - type: array - x-fern-audiences: - - public - description: |- - An array of examples to provide context to the model. Each example is a text string and its associated label/class. Each unique label requires at least 2 examples associated with it; the maximum number of examples is 2500, and each example has a maximum length of 512 tokens. The values should be structured as `{text: "...",label: "..."}`. - Note: [Fine-tuned Models](https://docs.cohere.com/docs/classify-fine-tuning) trained on classification examples don't require the `examples` parameter to be passed in explicitly. - maxItems: 2500 - items: - x-fern-audiences: - - public - $ref: "#/components/schemas/ClassifyExample" - writeOnly: true model: type: string x-fern-audiences: @@ -4224,33 +3975,6 @@ paths: writeOnly: true required: - inputs - examples: - Example: - value: - inputs: - - Confirm your email address - - hey i need u to send some $ - examples: - - text: Dermatologists don't like her! - label: Spam - - text: Hello, open to this? - label: Spam - - text: I need help please wire me $1000 right now - label: Spam - - text: Nice to know you ;) - label: Spam - - text: Please help me? - label: Spam - - text: Your parcel will be delivered today - label: Not spam - - text: Review changes to our Terms and Conditions - label: Not spam - - text: Weekly sync notes - label: Not spam - - text: "Re: Follow up from today’s meeting" - label: Not spam - - text: Pre-read for tomorrow - label: Not spam description: "" /v1/datasets: post: @@ -4369,165 +4093,152 @@ paths: - public description: The delimiter used for .csv uploads. - $ref: "#/components/parameters/RequestSource" - x-readme: - samples-languages: - - python - - java - - python - - java - - node - - curl - - go - code-samples: - - language: go - name: Cohere Go SDK - install: go get github.com/cohere-ai/cohere-go/v2 - code: > - package main + x-fern-examples: + - code-samples: + - sdk: go + name: Cohere Go SDK + code: > + package main - import ( - "context" - "io" - "log" - "strings" + import ( + "context" + "io" + "log" + "strings" - cohere "github.com/cohere-ai/cohere-go/v2" - client "github.com/cohere-ai/cohere-go/v2/client" - ) + cohere "github.com/cohere-ai/cohere-go/v2" + client "github.com/cohere-ai/cohere-go/v2/client" + ) - type MyReader struct { - io.Reader - name string - } + type MyReader struct { + io.Reader + name string + } - func (m *MyReader) Name() string { - return m.name - } + func (m *MyReader) Name() string { + return m.name + } - func main() { - co := client.NewClient(client.WithToken("<>")) + func main() { + co := client.NewClient(client.WithToken("<>")) - resp, err := co.Datasets.Create( - context.TODO(), - &MyReader{Reader: strings.NewReader(`{"text": "The quick brown fox jumps over the lazy dog"}`), name: "test.jsonl"}, - &MyReader{Reader: strings.NewReader(""), name: "a.jsonl"}, - &cohere.DatasetsCreateRequest{ - Name: "prompt-completion-dataset", - Type: cohere.DatasetTypeEmbedResult, - }, - ) + resp, err := co.Datasets.Create( + context.TODO(), + &MyReader{Reader: strings.NewReader(`{"text": "The quick brown fox jumps over the lazy dog"}`), name: "test.jsonl"}, + &MyReader{Reader: strings.NewReader(""), name: "a.jsonl"}, + &cohere.DatasetsCreateRequest{ + Name: "prompt-completion-dataset", + Type: cohere.DatasetTypeEmbedResult, + }, + ) - if err != nil { - log.Fatal(err) - } + if err != nil { + log.Fatal(err) + } - log.Printf("%+v", resp) - } - - language: python - name: Sync - install: python -m pip install cohere --upgrade - code: | - import cohere + log.Printf("%+v", resp) + } + - sdk: python + name: Sync + code: | + import cohere - co = cohere.Client("<>") + co = cohere.Client("<>") - # upload a dataset - my_dataset = co.datasets.create( - name="prompt-completion-dataset", - data=open("./prompt-completion.jsonl", "rb"), - type="prompt-completion-finetune-input", - ) + # upload a dataset + my_dataset = co.datasets.create( + name="prompt-completion-dataset", + data=open("./prompt-completion.jsonl", "rb"), + type="prompt-completion-finetune-input", + ) - # wait for validation to complete - response = co.wait(my_dataset) + # wait for validation to complete + response = co.wait(my_dataset) - print(response) - - language: python - name: Async - install: python -m pip install cohere --upgrade - code: | - import cohere - import asyncio + print(response) + - sdk: python + name: Async + code: | + import cohere + import asyncio - co = cohere.AsyncClient("<>") + co = cohere.AsyncClient("<>") - async def main(): + async def main(): - # upload a dataset - response = await co.datasets.create( - name="prompt-completion-dataset", - data=open("./prompt-completion.jsonl", "rb"), - type="prompt-completion-finetune-input", - ) + # upload a dataset + response = await co.datasets.create( + name="prompt-completion-dataset", + data=open("./prompt-completion.jsonl", "rb"), + type="prompt-completion-finetune-input", + ) - # wait for validation to complete - response = await co.wait(response) + # wait for validation to complete + response = await co.wait(response) - print(response) + print(response) - asyncio.run(main()) - - language: java - name: Cohere java SDK - install: implementation 'com.cohere:cohere-java:1.0.4' - code: > - import com.cohere.api.Cohere; + asyncio.run(main()) + - sdk: java + name: Cohere java SDK + code: > + import com.cohere.api.Cohere; - import - com.cohere.api.resources.datasets.requests.DatasetsCreateRequest; + import + com.cohere.api.resources.datasets.requests.DatasetsCreateRequest; - import - com.cohere.api.resources.datasets.types.DatasetsCreateResponse; + import + com.cohere.api.resources.datasets.types.DatasetsCreateResponse; - import com.cohere.api.types.DatasetType; + import com.cohere.api.types.DatasetType; - import java.util.Optional; + import java.util.Optional; - public class DatasetPost { - public static void main(String[] args) { - Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); + public class DatasetPost { + public static void main(String[] args) { + Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); - DatasetsCreateResponse response = cohere.datasets().create(null, Optional.empty(), DatasetsCreateRequest.builder().name("prompt-completion-dataset").type(DatasetType.PROMPT_COMPLETION_FINETUNE_INPUT).build()); + DatasetsCreateResponse response = cohere.datasets().create(null, Optional.empty(), DatasetsCreateRequest.builder().name("prompt-completion-dataset").type(DatasetType.PROMPT_COMPLETION_FINETUNE_INPUT).build()); - System.out.println(response); - } - } - - language: node - name: Cohere TypeScript SDK - install: npm i cohere-ai - code: > - const { CohereClient } = require('cohere-ai'); + System.out.println(response); + } + } + - sdk: typescript + name: Cohere TypeScript SDK + code: > + const { CohereClient } = require('cohere-ai'); - const fs = require('fs'); + const fs = require('fs'); - const cohere = new CohereClient({ - token: '<>', - }); + const cohere = new CohereClient({ + token: '<>', + }); - (async () => { - const file = fs.createReadStream('embed_jobs_sample_data.jsonl'); // {"text": "The quick brown fox jumps over the lazy dog"} + (async () => { + const file = fs.createReadStream('embed_jobs_sample_data.jsonl'); // {"text": "The quick brown fox jumps over the lazy dog"} - const dataset = await cohere.datasets.create({ name: 'my-dataset', type: 'embed-input' }, file); + const dataset = await cohere.datasets.create({ name: 'my-dataset', type: 'embed-input' }, file); - console.log(dataset); - })(); - - language: curl - name: cURL - code: >- - curl --request POST \ - --url "https://api.cohere.com/v1/datasets?name=my-dataset&type=generative-finetune-input" \ - --header 'Content-Type: multipart/form-data' \ - --header "Authorization: Bearer $CO_API_KEY" \ - --form file=@./path/to/file.jsonl + console.log(dataset); + })(); + - sdk: curl + name: cURL + code: >- + curl --request POST \ + --url "https://api.cohere.com/v1/datasets?name=my-dataset&type=generative-finetune-input" \ + --header 'Content-Type: multipart/form-data' \ + --header "Authorization: Bearer $CO_API_KEY" \ + --form file=@./path/to/file.jsonl responses: "200": description: A successful response. @@ -4621,110 +4332,97 @@ paths: schema: $ref: "#/components/schemas/DatasetValidationStatus" - $ref: "#/components/parameters/RequestSource" - x-readme: - samples-languages: - - python - - java - - python - - java - - node - - curl - - go - code-samples: - - language: go - name: Cohere Go SDK - install: go get github.com/cohere-ai/cohere-go/v2 - code: | - package main - - import ( - "context" - "log" + x-fern-examples: + - code-samples: + - sdk: go + name: Cohere Go SDK + code: | + package main - client "github.com/cohere-ai/cohere-go/v2/client" - ) + import ( + "context" + "log" - func main() { - co := client.NewClient(client.WithToken("<>")) + client "github.com/cohere-ai/cohere-go/v2/client" + ) - resp, err := co.Datasets.Get(context.TODO(), "dataset_id") + func main() { + co := client.NewClient(client.WithToken("<>")) - if err != nil { - log.Fatal(err) - } + resp, err := co.Datasets.Get(context.TODO(), "dataset_id") - log.Printf("%+v", resp) - } - - language: python - name: Sync - install: python -m pip install cohere --upgrade - code: | - import cohere + if err != nil { + log.Fatal(err) + } - co = cohere.Client("<>") + log.Printf("%+v", resp) + } + - sdk: python + name: Sync + code: | + import cohere - # get dataset - response = co.datasets.get(id="<>") + co = cohere.Client("<>") - print(response) - - language: python - name: Async - install: python -m pip install cohere --upgrade - code: | - import cohere - import asyncio + # get dataset + response = co.datasets.get(id="<>") - co = cohere.AsyncClient("<>") + print(response) + - sdk: python + name: Async + code: | + import cohere + import asyncio + co = cohere.AsyncClient("<>") - async def main(): - response = await co.datasets.get(id="<>") - print(response) + async def main(): + response = await co.datasets.get(id="<>") - asyncio.run(main()) - - language: java - name: Cohere java SDK - install: implementation 'com.cohere:cohere-java:1.0.4' - code: > - import com.cohere.api.Cohere; + print(response) - import - com.cohere.api.resources.datasets.types.DatasetsGetResponse; + asyncio.run(main()) + - sdk: java + name: Cohere java SDK + code: > + import com.cohere.api.Cohere; + import + com.cohere.api.resources.datasets.types.DatasetsGetResponse; - public class DatasetGet { - public static void main(String[] args) { - Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); - DatasetsGetResponse response = cohere.datasets().get("dataset_id"); + public class DatasetGet { + public static void main(String[] args) { + Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); - System.out.println(response); - } - } - - language: node - name: Cohere TypeScript SDK - install: npm i cohere-ai - code: | - const { CohereClient } = require('cohere-ai'); + DatasetsGetResponse response = cohere.datasets().get("dataset_id"); - const cohere = new CohereClient({ - token: '<>', - }); + System.out.println(response); + } + } + - sdk: typescript + name: Cohere TypeScript SDK + code: | + const { CohereClient } = require('cohere-ai'); - (async () => { - const datasets = await cohere.datasets.get('<>'); + const cohere = new CohereClient({ + token: '<>', + }); - console.log(datasets); - })(); - - language: curl - name: cURL - code: |- - curl --request GET \ - --url https://api.cohere.com/v1/datasets \ - --header 'accept: application/json' \ - --header "Authorization: bearer $CO_API_KEY" + (async () => { + const datasets = await cohere.datasets.get('<>'); + + console.log(datasets); + })(); + - sdk: curl + name: cURL + code: |- + curl --request GET \ + --url https://api.cohere.com/v1/datasets \ + --header 'accept: application/json' \ + --header "Authorization: bearer $CO_API_KEY" responses: "200": description: A successful response. @@ -4779,110 +4477,97 @@ paths: - $ref: "#/components/parameters/RequestSource" x-fern-sdk-group-name: datasets x-fern-sdk-method-name: getUsage - x-readme: - samples-languages: - - python - - java - - python - - java - - node - - curl - - go - code-samples: - - language: go - name: Cohere Go SDK - install: go get github.com/cohere-ai/cohere-go/v2 - code: | - package main - - import ( - "context" - "log" + x-fern-examples: + - code-samples: + - sdk: go + name: Cohere Go SDK + code: | + package main - client "github.com/cohere-ai/cohere-go/v2/client" - ) + import ( + "context" + "log" - func main() { - co := client.NewClient(client.WithToken("<>")) + client "github.com/cohere-ai/cohere-go/v2/client" + ) - resp, err := co.Datasets.GetUsage(context.TODO()) + func main() { + co := client.NewClient(client.WithToken("<>")) - if err != nil { - log.Fatal(err) - } + resp, err := co.Datasets.GetUsage(context.TODO()) - log.Printf("%+v", resp) - } - - language: python - name: Sync - install: python -m pip install cohere --upgrade - code: | - import cohere + if err != nil { + log.Fatal(err) + } - co = cohere.Client("<>") + log.Printf("%+v", resp) + } + - sdk: python + name: Sync + code: | + import cohere - # get usage - response = co.datasets.get_usage() + co = cohere.Client("<>") - print(response) - - language: python - name: Async - install: python -m pip install cohere --upgrade - code: | - import cohere - import asyncio + # get usage + response = co.datasets.get_usage() - co = cohere.AsyncClient("<>") + print(response) + - sdk: python + name: Async + code: | + import cohere + import asyncio + co = cohere.AsyncClient("<>") - async def main(): - response = await co.datasets.get_usage() - print(response) + async def main(): + response = await co.datasets.get_usage() - asyncio.run(main()) - - language: java - name: Cohere java SDK - install: implementation 'com.cohere:cohere-java:1.0.4' - code: > - import com.cohere.api.Cohere; + print(response) - import - com.cohere.api.resources.datasets.types.DatasetsGetUsageResponse; + asyncio.run(main()) + - sdk: java + name: Cohere java SDK + code: > + import com.cohere.api.Cohere; + import + com.cohere.api.resources.datasets.types.DatasetsGetUsageResponse; - public class DatasetUsageGet { - public static void main(String[] args) { - Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); - DatasetsGetUsageResponse response = cohere.datasets().getUsage(); + public class DatasetUsageGet { + public static void main(String[] args) { + Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); - System.out.println(response); - } - } - - language: node - name: Cohere TypeScript SDK - install: npm i cohere-ai - code: | - const { CohereClient } = require('cohere-ai'); + DatasetsGetUsageResponse response = cohere.datasets().getUsage(); - const cohere = new CohereClient({ - token: '<>', - }); + System.out.println(response); + } + } + - sdk: typescript + name: Cohere TypeScript SDK + code: | + const { CohereClient } = require('cohere-ai'); - (async () => { - const usage = await cohere.datasets.getUsage('id'); + const cohere = new CohereClient({ + token: '<>', + }); - console.log(usage); - })(); - - language: curl - name: cURL - code: |- - curl --request GET \ - --url https://api.cohere.com/v1/datasets/usage \ - --header 'accept: application/json' \ - --header "Authorization: bearer $CO_API_KEY" + (async () => { + const usage = await cohere.datasets.getUsage('id'); + + console.log(usage); + })(); + - sdk: curl + name: cURL + code: |- + curl --request GET \ + --url https://api.cohere.com/v1/datasets/usage \ + --header 'accept: application/json' \ + --header "Authorization: bearer $CO_API_KEY" responses: "200": description: A successful response. @@ -4946,110 +4631,97 @@ paths: - public pattern: ^(?!usage$).*$ - $ref: "#/components/parameters/RequestSource" - x-readme: - samples-languages: - - python - - java - - python - - java - - node - - curl - - go - code-samples: - - language: go - name: Cohere Go SDK - install: go get github.com/cohere-ai/cohere-go/v2 - code: | - package main - - import ( - "context" - "log" + x-fern-examples: + - code-samples: + - sdk: go + name: Cohere Go SDK + code: | + package main - client "github.com/cohere-ai/cohere-go/v2/client" - ) + import ( + "context" + "log" - func main() { - co := client.NewClient(client.WithToken("<>")) + client "github.com/cohere-ai/cohere-go/v2/client" + ) - resp, err := co.Datasets.Get(context.TODO(), "dataset_id") + func main() { + co := client.NewClient(client.WithToken("<>")) - if err != nil { - log.Fatal(err) - } + resp, err := co.Datasets.Get(context.TODO(), "dataset_id") - log.Printf("%+v", resp) - } - - language: python - name: Sync - install: python -m pip install cohere --upgrade - code: | - import cohere + if err != nil { + log.Fatal(err) + } - co = cohere.Client("<>") + log.Printf("%+v", resp) + } + - sdk: python + name: Sync + code: | + import cohere - # get dataset - response = co.datasets.get(id="<>") + co = cohere.Client("<>") - print(response) - - language: python - name: Async - install: python -m pip install cohere --upgrade - code: | - import cohere - import asyncio + # get dataset + response = co.datasets.get(id="<>") - co = cohere.AsyncClient("<>") + print(response) + - sdk: python + name: Async + code: | + import cohere + import asyncio + co = cohere.AsyncClient("<>") - async def main(): - response = await co.datasets.get(id="<>") - print(response) + async def main(): + response = await co.datasets.get(id="<>") - asyncio.run(main()) - - language: java - name: Cohere java SDK - install: implementation 'com.cohere:cohere-java:1.0.4' - code: > - import com.cohere.api.Cohere; + print(response) - import - com.cohere.api.resources.datasets.types.DatasetsGetResponse; + asyncio.run(main()) + - sdk: java + name: Cohere java SDK + code: > + import com.cohere.api.Cohere; + import + com.cohere.api.resources.datasets.types.DatasetsGetResponse; - public class DatasetGet { - public static void main(String[] args) { - Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); - DatasetsGetResponse response = cohere.datasets().get("dataset_id"); + public class DatasetGet { + public static void main(String[] args) { + Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); - System.out.println(response); - } - } - - language: node - name: Cohere TypeScript SDK - install: npm i cohere-ai - code: | - const { CohereClient } = require('cohere-ai'); + DatasetsGetResponse response = cohere.datasets().get("dataset_id"); - const cohere = new CohereClient({ - token: '<>', - }); + System.out.println(response); + } + } + - sdk: typescript + name: Cohere TypeScript SDK + code: | + const { CohereClient } = require('cohere-ai'); - (async () => { - const datasets = await cohere.datasets.get('<>'); + const cohere = new CohereClient({ + token: '<>', + }); - console.log(datasets); - })(); - - language: curl - name: cURL - code: |- - curl --request GET \ - --url https://api.cohere.com/v1/datasets \ - --header 'accept: application/json' \ - --header "Authorization: bearer $CO_API_KEY" + (async () => { + const datasets = await cohere.datasets.get('<>'); + + console.log(datasets); + })(); + - sdk: curl + name: cURL + code: |- + curl --request GET \ + --url https://api.cohere.com/v1/datasets \ + --header 'accept: application/json' \ + --header "Authorization: bearer $CO_API_KEY" responses: "200": description: A successful response. @@ -5109,87 +4781,75 @@ paths: - public pattern: ^(?!usage$).*$ - $ref: "#/components/parameters/RequestSource" - x-readme: - samples-languages: - - python - - java - - python - - java - - node - - curl - - go - code-samples: - - language: go - name: Cohere Go SDK - install: go get github.com/cohere-ai/cohere-go/v2 - code: | - package main + x-fern-examples: + - code-samples: + - sdk: go + name: Cohere Go SDK + code: | + package main - import ( - "context" - "log" + import ( + "context" + "log" - client "github.com/cohere-ai/cohere-go/v2/client" - ) + client "github.com/cohere-ai/cohere-go/v2/client" + ) - func main() { - co := client.NewClient(client.WithToken("<>")) + func main() { + co := client.NewClient(client.WithToken("<>")) - _, err := co.Datasets.Delete(context.TODO(), "dataset_id") + _, err := co.Datasets.Delete(context.TODO(), "dataset_id") - if err != nil { - log.Fatal(err) - } + if err != nil { + log.Fatal(err) + } - } - - language: python - name: Sync - install: python -m pip install cohere --upgrade - code: | - import cohere + } + - sdk: python + name: Sync + code: | + import cohere - co = cohere.Client("<>") + co = cohere.Client("<>") - # delete dataset - co.datasets.delete("id") - - language: python - name: Async - install: python -m pip install cohere --upgrade - code: | - import cohere - import asyncio + # delete dataset + co.datasets.delete("id") + - sdk: python + name: Async + code: | + import cohere + import asyncio - co = cohere.AsyncClient("<>") + co = cohere.AsyncClient("<>") - async def main(): - await co.delete_dataset("id") + async def main(): + await co.delete_dataset("id") - asyncio.run(main()) - - language: java - name: Cohere java SDK - install: implementation 'com.cohere:cohere-java:1.0.4' - code: > - import com.cohere.api.Cohere; + asyncio.run(main()) + - sdk: java + name: Cohere java SDK + code: > + import com.cohere.api.Cohere; - public class DatasetDelete { - public static void main(String[] args) { - Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); + public class DatasetDelete { + public static void main(String[] args) { + Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); - cohere.datasets().delete("id"); + cohere.datasets().delete("id"); - } - } - - language: curl - name: cURL - code: |- - curl --request DELETE \ - --url https://api.cohere.com/v1/datasets/id \ - --header 'accept: application/json' \ - --header 'content-type: application/json' \ - --header "Authorization: bearer $CO_API_KEY" + } + } + - sdk: curl + name: cURL + code: |- + curl --request DELETE \ + --url https://api.cohere.com/v1/datasets/id \ + --header 'accept: application/json' \ + --header 'content-type: application/json' \ + --header "Authorization: bearer $CO_API_KEY" responses: "200": description: A successful response. @@ -5223,231 +4883,220 @@ paths: $ref: "#/components/responses/ServiceUnavailable" "504": $ref: "#/components/responses/GatewayTimeout" - /v1/summarize: - post: - x-fern-audiences: - - public - summary: Summarize - operationId: summarize - parameters: - - $ref: "#/components/parameters/RequestSource" - x-readme: - samples-languages: - - python - - java - - curl - - node - - go - code-samples: - - language: go - name: Cohere Go SDK - install: go get github.com/cohere-ai/cohere-go/v2 - code: > - package main - - - import ( - "context" - "log" - - cohere "github.com/cohere-ai/cohere-go/v2" - client "github.com/cohere-ai/cohere-go/v2/client" - ) - - - func main() { - co := client.NewClient(client.WithToken("<>")) - - resp, err := co.Summarize( - context.TODO(), - &cohere.SummarizeRequest{ - Text: "the quick brown fox jumped over the lazy dog and then the dog jumped over the fox the quick brown fox jumped over the lazy dog the quick brown fox jumped over the lazy dog the quick brown fox jumped over the lazy dog the quick brown fox jumped over the lazy dog", - }, - ) - - if err != nil { - log.Fatal(err) - } - - log.Printf("%+v", resp) - } - - language: node - name: Cohere TypeScript SDK - install: npm i cohere-ai - code: > - const { CohereClient } = require('cohere-ai'); - - - const cohere = new CohereClient({ - token: '<>', - }); - - - (async () => { - const summarize = await cohere.summarize({ - text: - 'Ice cream is a sweetened frozen food typically eaten as a snack or dessert. ' + - 'It may be made from milk or cream and is flavoured with a sweetener, ' + - 'either sugar or an alternative, and a spice, such as cocoa or vanilla, ' + - 'or with fruit such as strawberries or peaches. ' + - 'It can also be made by whisking a flavored cream base and liquid nitrogen together. ' + - 'Food coloring is sometimes added, in addition to stabilizers. ' + - 'The mixture is cooled below the freezing point of water and stirred to incorporate air spaces ' + - 'and to prevent detectable ice crystals from forming. The result is a smooth, ' + - 'semi-solid foam that is solid at very low temperatures (below 2 °C or 35 °F). ' + - 'It becomes more malleable as its temperature increases.\n\n' + - 'The meaning of the name "ice cream" varies from one country to another. ' + - 'In some countries, such as the United States, "ice cream" applies only to a specific variety, ' + - 'and most governments regulate the commercial use of the various terms according to the ' + - 'relative quantities of the main ingredients, notably the amount of cream. ' + - 'Products that do not meet the criteria to be called ice cream are sometimes labelled ' + - '"frozen dairy dessert" instead. In other countries, such as Italy and Argentina, ' + - 'one word is used fo\r all variants. Analogues made from dairy alternatives, ' + - "such as goat's or sheep's milk, or milk substitutes " + - '(e.g., soy, cashew, coconut, almond milk or tofu), are available for those who are ' + - 'lactose intolerant, allergic to dairy protein or vegan.', - }); - - console.log(summarize); - })(); - - language: python - name: Sync - install: python -m pip install cohere --upgrade - code: > - import cohere - - - co = cohere.Client("<>") - - - text = ( - "Ice cream is a sweetened frozen food typically eaten as a snack or dessert. " - "It may be made from milk or cream and is flavoured with a sweetener, " - "either sugar or an alternative, and a spice, such as cocoa or vanilla, " - "or with fruit such as strawberries or peaches. " - "It can also be made by whisking a flavored cream base and liquid nitrogen together. " - "Food coloring is sometimes added, in addition to stabilizers. " - "The mixture is cooled below the freezing point of water and stirred to incorporate air spaces " - "and to prevent detectable ice crystals from forming. The result is a smooth, " - "semi-solid foam that is solid at very low temperatures (below 2 °C or 35 °F). " - "It becomes more malleable as its temperature increases.\n\n" - 'The meaning of the name "ice cream" varies from one country to another. ' - 'In some countries, such as the United States, "ice cream" applies only to a specific variety, ' - "and most governments regulate the commercial use of the various terms according to the " - "relative quantities of the main ingredients, notably the amount of cream. " - "Products that do not meet the criteria to be called ice cream are sometimes labelled " - '"frozen dairy dessert" instead. In other countries, such as Italy and Argentina, ' - "one word is used fo\r all variants. Analogues made from dairy alternatives, " - "such as goat's or sheep's milk, or milk substitutes " - "(e.g., soy, cashew, coconut, almond milk or tofu), are available for those who are " - "lactose intolerant, allergic to dairy protein or vegan." - ) - - - response = co.summarize( - text=text, - ) - - print(response) - - language: python - name: Async - install: python -m pip install cohere --upgrade - code: > - import cohere - - import asyncio - - - co = cohere.AsyncClient("<>") - + /v1/summarize: + post: + x-fern-audiences: + - public + summary: Summarize + operationId: summarize + parameters: + - $ref: "#/components/parameters/RequestSource" + x-fern-examples: + - code-samples: + - sdk: go + name: Cohere Go SDK + code: > + package main - text = ( - "Ice cream is a sweetened frozen food typically eaten as a snack or dessert. " - "It may be made from milk or cream and is flavoured with a sweetener, " - "either sugar or an alternative, and a spice, such as cocoa or vanilla, " - "or with fruit such as strawberries or peaches. " - "It can also be made by whisking a flavored cream base and liquid nitrogen together. " - "Food coloring is sometimes added, in addition to stabilizers. " - "The mixture is cooled below the freezing point of water and stirred to incorporate air spaces " - "and to prevent detectable ice crystals from forming. The result is a smooth, " - "semi-solid foam that is solid at very low temperatures (below 2 °C or 35 °F). " - "It becomes more malleable as its temperature increases.\n\n" - 'The meaning of the name "ice cream" varies from one country to another. ' - 'In some countries, such as the United States, "ice cream" applies only to a specific variety, ' - "and most governments regulate the commercial use of the various terms according to the " - "relative quantities of the main ingredients, notably the amount of cream. " - "Products that do not meet the criteria to be called ice cream are sometimes labelled " - '"frozen dairy dessert" instead. In other countries, such as Italy and Argentina, ' - "one word is used fo\r all variants. Analogues made from dairy alternatives, " - "such as goat's or sheep's milk, or milk substitutes " - "(e.g., soy, cashew, coconut, almond milk or tofu), are available for those who are " - "lactose intolerant, allergic to dairy protein or vegan." - ) + import ( + "context" + "log" + cohere "github.com/cohere-ai/cohere-go/v2" + client "github.com/cohere-ai/cohere-go/v2/client" + ) - async def main(): - response = await co.summarize( - text=text, - ) - print(response) - asyncio.run(main()) - - language: java - name: Cohere java SDK - install: implementation 'com.cohere:cohere-java:1.0.4' - code: > - import com.cohere.api.Cohere; + func main() { + co := client.NewClient(client.WithToken("<>")) - import com.cohere.api.requests.SummarizeRequest; + resp, err := co.Summarize( + context.TODO(), + &cohere.SummarizeRequest{ + Text: "the quick brown fox jumped over the lazy dog and then the dog jumped over the fox the quick brown fox jumped over the lazy dog the quick brown fox jumped over the lazy dog the quick brown fox jumped over the lazy dog the quick brown fox jumped over the lazy dog", + }, + ) - import com.cohere.api.types.SummarizeResponse; + if err != nil { + log.Fatal(err) + } + log.Printf("%+v", resp) + } + - sdk: typescript + name: Cohere TypeScript SDK + code: > + const { CohereClient } = require('cohere-ai'); - public class SummarizePost { - public static void main(String[] args) { - Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); + const cohere = new CohereClient({ + token: '<>', + }); - SummarizeResponse response = cohere.summarize(SummarizeRequest.builder().text( - """ - Ice cream is a sweetened frozen food typically eaten as a snack or dessert.\s - It may be made from milk or cream and is flavoured with a sweetener,\s - either sugar or an alternative, and a spice, such as cocoa or vanilla,\s - or with fruit such as strawberries or peaches.\s - It can also be made by whisking a flavored cream base and liquid nitrogen together.\s - Food coloring is sometimes added, in addition to stabilizers.\s - The mixture is cooled below the freezing point of water and stirred to incorporate air spaces\s - and to prevent detectable ice crystals from forming. The result is a smooth,\s - semi-solid foam that is solid at very low temperatures (below 2 °C or 35 °F).\s - It becomes more malleable as its temperature increases.\\n\\n - The meaning of the name "ice cream" varies from one country to another.\s - In some countries, such as the United States, "ice cream" applies only to a specific variety,\s - and most governments regulate the commercial use of the various terms according to the\s - relative quantities of the main ingredients, notably the amount of cream.\s - Products that do not meet the criteria to be called ice cream are sometimes labelled\s - "frozen dairy dessert" instead. In other countries, such as Italy and Argentina,\s - one word is used fo\\r all variants. Analogues made from dairy alternatives,\s - such as goat's or sheep's milk, or milk substitutes\s - (e.g., soy, cashew, coconut, almond milk or tofu), are available for those who are\s - lactose intolerant, allergic to dairy protein or vegan. - """ - ).build()); - System.out.println(response); - } - } - - language: curl - name: cURL - code: >- - curl --request POST \ - --url https://api.cohere.com/v1/summarize \ - --header 'accept: application/json' \ - --header 'content-type: application/json' \ - --header "Authorization: bearer $CO_API_KEY" \ - --data '{ - "text": "Ice cream is a sweetened frozen food typically eaten as a snack or dessert. It may be made from milk or cream and is flavoured with a sweetener, either sugar or an alternative, and a spice, such as cocoa or vanilla, or with fruit such as strawberries or peaches. It can also be made by whisking a flavored cream base and liquid nitrogen together. Food coloring is sometimes added, in addition to stabilizers. The mixture is cooled below the freezing point of water and stirred to incorporate air spaces and to prevent detectable ice crystals from forming. The result is a smooth, semi-solid foam that is solid at very low temperatures (below 2 °C or 35 °F). It becomes more malleable as its temperature increases.\n\nThe meaning of the name \"ice cream\" varies from one country to another. In some countries, such as the United States, \"ice cream\" applies only to a specific variety, and most governments regulate the commercial use of the various terms according to the relative quantities of the main ingredients, notably the amount of cream. Products that do not meet the criteria to be called ice cream are sometimes labelled \"frozen dairy dessert\" instead. In other countries, such as Italy and Argentina, one word is used for all variants. Analogues made from dairy alternatives, such as goat'\''s or sheep'\''s milk, or milk substitutes (e.g., soy, cashew, coconut, almond milk or tofu), are available for those who are lactose intolerant, allergic to dairy protein or vegan." - }' + (async () => { + const summarize = await cohere.summarize({ + text: + 'Ice cream is a sweetened frozen food typically eaten as a snack or dessert. ' + + 'It may be made from milk or cream and is flavoured with a sweetener, ' + + 'either sugar or an alternative, and a spice, such as cocoa or vanilla, ' + + 'or with fruit such as strawberries or peaches. ' + + 'It can also be made by whisking a flavored cream base and liquid nitrogen together. ' + + 'Food coloring is sometimes added, in addition to stabilizers. ' + + 'The mixture is cooled below the freezing point of water and stirred to incorporate air spaces ' + + 'and to prevent detectable ice crystals from forming. The result is a smooth, ' + + 'semi-solid foam that is solid at very low temperatures (below 2 °C or 35 °F). ' + + 'It becomes more malleable as its temperature increases.\n\n' + + 'The meaning of the name "ice cream" varies from one country to another. ' + + 'In some countries, such as the United States, "ice cream" applies only to a specific variety, ' + + 'and most governments regulate the commercial use of the various terms according to the ' + + 'relative quantities of the main ingredients, notably the amount of cream. ' + + 'Products that do not meet the criteria to be called ice cream are sometimes labelled ' + + '"frozen dairy dessert" instead. In other countries, such as Italy and Argentina, ' + + 'one word is used fo\r all variants. Analogues made from dairy alternatives, ' + + "such as goat's or sheep's milk, or milk substitutes " + + '(e.g., soy, cashew, coconut, almond milk or tofu), are available for those who are ' + + 'lactose intolerant, allergic to dairy protein or vegan.', + }); + + console.log(summarize); + })(); + - sdk: python + name: Sync + code: > + import cohere + + + co = cohere.Client("<>") + + + text = ( + "Ice cream is a sweetened frozen food typically eaten as a snack or dessert. " + "It may be made from milk or cream and is flavoured with a sweetener, " + "either sugar or an alternative, and a spice, such as cocoa or vanilla, " + "or with fruit such as strawberries or peaches. " + "It can also be made by whisking a flavored cream base and liquid nitrogen together. " + "Food coloring is sometimes added, in addition to stabilizers. " + "The mixture is cooled below the freezing point of water and stirred to incorporate air spaces " + "and to prevent detectable ice crystals from forming. The result is a smooth, " + "semi-solid foam that is solid at very low temperatures (below 2 °C or 35 °F). " + "It becomes more malleable as its temperature increases.\n\n" + 'The meaning of the name "ice cream" varies from one country to another. ' + 'In some countries, such as the United States, "ice cream" applies only to a specific variety, ' + "and most governments regulate the commercial use of the various terms according to the " + "relative quantities of the main ingredients, notably the amount of cream. " + "Products that do not meet the criteria to be called ice cream are sometimes labelled " + '"frozen dairy dessert" instead. In other countries, such as Italy and Argentina, ' + "one word is used fo\r all variants. Analogues made from dairy alternatives, " + "such as goat's or sheep's milk, or milk substitutes " + "(e.g., soy, cashew, coconut, almond milk or tofu), are available for those who are " + "lactose intolerant, allergic to dairy protein or vegan." + ) + + + response = co.summarize( + text=text, + ) + + print(response) + - sdk: python + name: Async + code: > + import cohere + + import asyncio + + + co = cohere.AsyncClient("<>") + + + text = ( + "Ice cream is a sweetened frozen food typically eaten as a snack or dessert. " + "It may be made from milk or cream and is flavoured with a sweetener, " + "either sugar or an alternative, and a spice, such as cocoa or vanilla, " + "or with fruit such as strawberries or peaches. " + "It can also be made by whisking a flavored cream base and liquid nitrogen together. " + "Food coloring is sometimes added, in addition to stabilizers. " + "The mixture is cooled below the freezing point of water and stirred to incorporate air spaces " + "and to prevent detectable ice crystals from forming. The result is a smooth, " + "semi-solid foam that is solid at very low temperatures (below 2 °C or 35 °F). " + "It becomes more malleable as its temperature increases.\n\n" + 'The meaning of the name "ice cream" varies from one country to another. ' + 'In some countries, such as the United States, "ice cream" applies only to a specific variety, ' + "and most governments regulate the commercial use of the various terms according to the " + "relative quantities of the main ingredients, notably the amount of cream. " + "Products that do not meet the criteria to be called ice cream are sometimes labelled " + '"frozen dairy dessert" instead. In other countries, such as Italy and Argentina, ' + "one word is used fo\r all variants. Analogues made from dairy alternatives, " + "such as goat's or sheep's milk, or milk substitutes " + "(e.g., soy, cashew, coconut, almond milk or tofu), are available for those who are " + "lactose intolerant, allergic to dairy protein or vegan." + ) + + + + async def main(): + response = await co.summarize( + text=text, + ) + print(response) + + asyncio.run(main()) + - sdk: java + name: Cohere java SDK + code: > + import com.cohere.api.Cohere; + + import com.cohere.api.requests.SummarizeRequest; + + import com.cohere.api.types.SummarizeResponse; + + + + public class SummarizePost { + public static void main(String[] args) { + Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); + + SummarizeResponse response = cohere.summarize(SummarizeRequest.builder().text( + """ + Ice cream is a sweetened frozen food typically eaten as a snack or dessert.\s + It may be made from milk or cream and is flavoured with a sweetener,\s + either sugar or an alternative, and a spice, such as cocoa or vanilla,\s + or with fruit such as strawberries or peaches.\s + It can also be made by whisking a flavored cream base and liquid nitrogen together.\s + Food coloring is sometimes added, in addition to stabilizers.\s + The mixture is cooled below the freezing point of water and stirred to incorporate air spaces\s + and to prevent detectable ice crystals from forming. The result is a smooth,\s + semi-solid foam that is solid at very low temperatures (below 2 °C or 35 °F).\s + It becomes more malleable as its temperature increases.\\n\\n + The meaning of the name "ice cream" varies from one country to another.\s + In some countries, such as the United States, "ice cream" applies only to a specific variety,\s + and most governments regulate the commercial use of the various terms according to the\s + relative quantities of the main ingredients, notably the amount of cream.\s + Products that do not meet the criteria to be called ice cream are sometimes labelled\s + "frozen dairy dessert" instead. In other countries, such as Italy and Argentina,\s + one word is used fo\\r all variants. Analogues made from dairy alternatives,\s + such as goat's or sheep's milk, or milk substitutes\s + (e.g., soy, cashew, coconut, almond milk or tofu), are available for those who are\s + lactose intolerant, allergic to dairy protein or vegan. + """ + ).build()); + + System.out.println(response); + } + } + - sdk: curl + name: cURL + code: >- + curl --request POST \ + --url https://api.cohere.com/v1/summarize \ + --header 'accept: application/json' \ + --header 'content-type: application/json' \ + --header "Authorization: bearer $CO_API_KEY" \ + --data '{ + "text": "Ice cream is a sweetened frozen food typically eaten as a snack or dessert. It may be made from milk or cream and is flavoured with a sweetener, either sugar or an alternative, and a spice, such as cocoa or vanilla, or with fruit such as strawberries or peaches. It can also be made by whisking a flavored cream base and liquid nitrogen together. Food coloring is sometimes added, in addition to stabilizers. The mixture is cooled below the freezing point of water and stirred to incorporate air spaces and to prevent detectable ice crystals from forming. The result is a smooth, semi-solid foam that is solid at very low temperatures (below 2 °C or 35 °F). It becomes more malleable as its temperature increases.\n\nThe meaning of the name \"ice cream\" varies from one country to another. In some countries, such as the United States, \"ice cream\" applies only to a specific variety, and most governments regulate the commercial use of the various terms according to the relative quantities of the main ingredients, notably the amount of cream. Products that do not meet the criteria to be called ice cream are sometimes labelled \"frozen dairy dessert\" instead. In other countries, such as Italy and Argentina, one word is used for all variants. Analogues made from dairy alternatives, such as goat'\''s or sheep'\''s milk, or milk substitutes (e.g., soy, cashew, coconut, almond milk or tofu), are available for those who are lactose intolerant, allergic to dairy protein or vegan." + }' responses: "200": description: OK @@ -5504,9 +5153,9 @@ paths: "504": $ref: "#/components/responses/GatewayTimeout" description: | - - This API is marked as "Legacy" and is no longer maintained. Follow the [migration guide](/docs/migrating-from-cogenerate-to-cochat) to start using the Chat API. - + > 🚧 Warning + > + > This API is marked as "Legacy" and is no longer maintained. Follow the [migration guide](/docs/migrating-from-cogenerate-to-cochat) to start using the Chat API. Generates a summary in English for a given text. requestBody: @@ -5602,38 +5251,6 @@ paths: writeOnly: true required: - text - examples: - Example: - value: - text: "Ice cream is a sweetened frozen food typically eaten as a snack or - dessert. It may be made from milk or cream and is flavoured - with a sweetener, either sugar or an alternative, and a - spice, such as cocoa or vanilla, or with fruit such as - strawberries or peaches. It can also be made by whisking a - flavored cream base and liquid nitrogen together. Food - coloring is sometimes added, in addition to stabilizers. The - mixture is cooled below the freezing point of water and - stirred to incorporate air spaces and to prevent detectable - ice crystals from forming. The result is a smooth, - semi-solid foam that is solid at very low temperatures - (below 2 °C or 35 °F). It becomes more malleable as its - temperature increases. - - - The meaning of the name \"ice cream\" varies from one - country to another. In some countries, such as the United - States, \"ice cream\" applies only to a specific variety, - and most governments regulate the commercial use of the - various terms according to the relative quantities of the - main ingredients, notably the amount of cream. Products that - do not meet the criteria to be called ice cream are - sometimes labelled \"frozen dairy dessert\" instead. In - other countries, such as Italy and Argentina, one word is - used fo\r all variants. Analogues made from dairy - alternatives, such as goat's or sheep's milk, or milk - substitutes (e.g., soy, cashew, coconut, almond milk or - tofu), are available for those who are lactose intolerant, - allergic to dairy protein or vegan." description: "" /v1/tokenize: post: @@ -5643,134 +5260,122 @@ paths: operationId: tokenize parameters: - $ref: "#/components/parameters/RequestSource" - x-readme: - samples-languages: - - python - - java - - curl - - node - - go - code-samples: - - language: go - name: Cohere Go SDK - install: go get github.com/cohere-ai/cohere-go/v2 - code: | - package main - - import ( - "context" - "log" - - cohere "github.com/cohere-ai/cohere-go/v2" - client "github.com/cohere-ai/cohere-go/v2/client" - ) - - func main() { - co := client.NewClient(client.WithToken("<>")) - - resp, err := co.Tokenize( - context.TODO(), - &cohere.TokenizeRequest{ - Text: "cohere <3", - Model: "base", - }, - ) - - if err != nil { - log.Fatal(err) - } - - log.Printf("%+v", resp) - } - - language: node - name: Cohere TypeScript SDK - install: npm i cohere-ai - code: | - const cohere = require('cohere-ai'); - cohere.init('<>')(async () => { - const response = await cohere.tokenize({ - text: 'tokenize me! :D', - model: 'command', // optional - }); - console.log(response); - })(); - - language: python - name: Sync - install: python -m pip install cohere --upgrade - code: > - import cohere + x-fern-examples: + - code-samples: + - sdk: go + name: Cohere Go SDK + code: | + package main + + import ( + "context" + "log" + + cohere "github.com/cohere-ai/cohere-go/v2" + client "github.com/cohere-ai/cohere-go/v2/client" + ) + + func main() { + co := client.NewClient(client.WithToken("<>")) + + resp, err := co.Tokenize( + context.TODO(), + &cohere.TokenizeRequest{ + Text: "cohere <3", + Model: "base", + }, + ) + + if err != nil { + log.Fatal(err) + } + + log.Printf("%+v", resp) + } + - sdk: typescript + name: Cohere TypeScript SDK + code: | + const cohere = require('cohere-ai'); + cohere.init('<>')(async () => { + const response = await cohere.tokenize({ + text: 'tokenize me! :D', + model: 'command', // optional + }); + console.log(response); + })(); + - sdk: python + name: Sync + code: > + import cohere - co = cohere.Client("<>") + co = cohere.Client("<>") - response = co.tokenize(text="tokenize me! :D", model="command") # - optional + response = co.tokenize(text="tokenize me! :D", + model="command") # optional - print(response) - - language: python - name: Async - install: python -m pip install cohere --upgrade - code: > - import cohere + print(response) + - sdk: python + name: Async + code: > + import cohere - import asyncio + import asyncio - co = cohere.AsyncClient("<>") + co = cohere.AsyncClient("<>") - async def main(): - response = await co.tokenize(text="tokenize me! :D", model="command") - print(response) + async def main(): + response = await co.tokenize(text="tokenize me! :D", model="command") + print(response) - asyncio.run(main()) - - language: java - name: Cohere java SDK - install: implementation 'com.cohere:cohere-java:1.0.4' - code: > - import com.cohere.api.Cohere; + asyncio.run(main()) + - sdk: java + name: Cohere java SDK + code: > + import com.cohere.api.Cohere; - import com.cohere.api.requests.TokenizeRequest; + import com.cohere.api.requests.TokenizeRequest; - import com.cohere.api.types.TokenizeResponse; + import com.cohere.api.types.TokenizeResponse; - public class TokenizePost { - public static void main(String[] args) { - Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); + public class TokenizePost { + public static void main(String[] args) { + Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); - TokenizeResponse response = cohere.tokenize(TokenizeRequest.builder().text("tokenize me").model("command").build()); + TokenizeResponse response = cohere.tokenize(TokenizeRequest.builder().text("tokenize me").model("command").build()); - System.out.println(response); - } - } - - language: node - name: Cohere Node.js SDK - install: npm install cohere-ai - code: | - const cohere = require('cohere-ai'); - cohere.init('<>')(async () => { - const response = await cohere.tokenize({ - text: 'tokenize me! :D', - model: 'command', // optional - }); - console.log(response); - })(); - - language: curl - name: cURL - code: |- - curl --request POST \ - --url https://api.cohere.com/v1/tokenize \ - --header 'accept: application/json' \ - --header 'content-type: application/json' \ - --header "Authorization: bearer $CO_API_KEY" \ - --data '{ - "model": "command", - "text": "tokenize me! :D" - }' + System.out.println(response); + } + } + - sdk: typescript + name: Cohere Node.js SDK + code: | + const cohere = require('cohere-ai'); + cohere.init('<>')(async () => { + const response = await cohere.tokenize({ + text: 'tokenize me! :D', + model: 'command', // optional + }); + console.log(response); + })(); + - sdk: curl + name: cURL + code: |- + curl --request POST \ + --url https://api.cohere.com/v1/tokenize \ + --header 'accept: application/json' \ + --header 'content-type: application/json' \ + --header "Authorization: bearer $CO_API_KEY" \ + --data '{ + "model": "command", + "text": "tokenize me! :D" + }' responses: "200": description: OK @@ -5900,135 +5505,124 @@ paths: operationId: detokenize parameters: - $ref: "#/components/parameters/RequestSource" - x-readme: - samples-languages: - - python - - java - - curl - - node - - go - code-samples: - - language: go - name: Cohere Go SDK - install: go get github.com/cohere-ai/cohere-go/v2 - code: | - package main - - import ( - "context" - "log" - - cohere "github.com/cohere-ai/cohere-go/v2" - client "github.com/cohere-ai/cohere-go/v2/client" - ) - - func main() { - co := client.NewClient(client.WithToken("<>")) - - resp, err := co.Detokenize( - context.TODO(), - &cohere.DetokenizeRequest{ - Tokens: []int{10002, 1706, 1722, 5169, 4328}, - }, - ) - - if err != nil { - log.Fatal(err) - } - - log.Printf("%+v", resp) - } - - language: node - name: Cohere TypeScript SDK - install: npm i cohere-ai - code: | - const { CohereClient } = require('cohere-ai'); - - const cohere = new CohereClient({ - token: '<>', - }); + x-fern-examples: + - code-samples: + - sdk: go + name: Cohere Go SDK + code: | + package main + + import ( + "context" + "log" + + cohere "github.com/cohere-ai/cohere-go/v2" + client "github.com/cohere-ai/cohere-go/v2/client" + ) + + func main() { + co := client.NewClient(client.WithToken("<>")) + + resp, err := co.Detokenize( + context.TODO(), + &cohere.DetokenizeRequest{ + Tokens: []int{10002, 1706, 1722, 5169, 4328}, + }, + ) + + if err != nil { + log.Fatal(err) + } + + log.Printf("%+v", resp) + } + - sdk: typescript + name: Cohere TypeScript SDK + code: | + const { CohereClient } = require('cohere-ai'); - (async () => { - const detokenize = await cohere.detokenize({ - tokens: [10002, 2261, 2012, 8, 2792, 43], - model: 'command', + const cohere = new CohereClient({ + token: '<>', }); - console.log(detokenize); - })(); - - language: python - name: Sync - install: python -m pip install cohere --upgrade - code: > - import cohere + (async () => { + const detokenize = await cohere.detokenize({ + tokens: [10002, 2261, 2012, 8, 2792, 43], + model: 'command', + }); + console.log(detokenize); + })(); + - sdk: python + name: Sync + code: > + import cohere - co = cohere.Client("<>") + co = cohere.Client("<>") - response = co.detokenize( - tokens=[8466, 5169, 2594, 8, 2792, 43], model="command" # optional - ) - print(response) - - language: python - name: Async - install: python -m pip install cohere --upgrade - code: > - import cohere + response = co.detokenize( + tokens=[8466, 5169, 2594, 8, 2792, 43], model="command" # optional + ) - import asyncio + print(response) + - sdk: python + name: Async + code: > + import cohere + import asyncio - co = cohere.AsyncClient("<>") + co = cohere.AsyncClient("<>") - async def main(): - response = await co.detokenize( - tokens=[8466, 5169, 2594, 8, 2792, 43], model="command" # optional - ) - print(response) - asyncio.run(main()) - - language: java - name: Cohere java SDK - install: implementation 'com.cohere:cohere-java:1.0.4' - code: > - import com.cohere.api.Cohere; + async def main(): + response = await co.detokenize( + tokens=[8466, 5169, 2594, 8, 2792, 43], model="command" # optional + ) + print(response) - import com.cohere.api.requests.DetokenizeRequest; + asyncio.run(main()) + - sdk: java + name: Cohere java SDK + code: > + import com.cohere.api.Cohere; - import com.cohere.api.types.DetokenizeResponse; + import com.cohere.api.requests.DetokenizeRequest; + import com.cohere.api.types.DetokenizeResponse; - import java.util.List; + import java.util.List; - public class DetokenizePost { - public static void main(String[] args) { - Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); - DetokenizeResponse response = cohere.detokenize( - DetokenizeRequest.builder().model("command").tokens(List.of(8466, 5169, 2594, 8, 2792, 43)).build() - ); + public class DetokenizePost { + public static void main(String[] args) { + Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); - System.out.println(response); - } - } - - language: curl - name: cURL - code: |- - curl --request POST \ - --url https://api.cohere.com/v1/detokenize \ - --header 'accept: application/json' \ - --header 'content-type: application/json' \ - --header "Authorization: bearer $CO_API_KEY" \ - --data '{ - "model": "command", - "tokens": [8466, 5169, 2594, 8, 2792, 43] - }' + DetokenizeResponse response = cohere.detokenize( + DetokenizeRequest.builder().model("command").tokens(List.of(8466, 5169, 2594, 8, 2792, 43)).build() + ); + + System.out.println(response); + } + } + - sdk: curl + name: cURL + code: |- + curl --request POST \ + --url https://api.cohere.com/v1/detokenize \ + --header 'accept: application/json' \ + --header 'content-type: application/json' \ + --header "Authorization: bearer $CO_API_KEY" \ + --data '{ + "model": "command", + "tokens": [8466, 5169, 2594, 8, 2792, 43] + }' responses: "200": description: OK @@ -6058,13 +5652,6 @@ paths: - public required: - text - examples: - Example: - value: - text: detokenized! :D - meta: - api_version: - version: "1" "400": $ref: "#/components/responses/BadRequest" "401": @@ -6122,17 +5709,6 @@ paths: required: - tokens - model - examples: - Example: - value: - tokens: - - 10104 - - 12221 - - 1315 - - 34 - - 1420 - - 69 - model: command description: "" parameters: [] /v1/connectors: @@ -6198,108 +5774,95 @@ paths: $ref: "#/components/responses/ServiceUnavailable" "504": $ref: "#/components/responses/GatewayTimeout" - x-readme: - samples-languages: - - python - - java - - python - - java - - node - - curl - - go - code-samples: - - language: go - name: Cohere Go SDK - install: go get github.com/cohere-ai/cohere-go/v2 - code: | - package main - - import ( - "context" - "log" + x-fern-examples: + - code-samples: + - sdk: go + name: Cohere Go SDK + code: | + package main - cohere "github.com/cohere-ai/cohere-go/v2" - client "github.com/cohere-ai/cohere-go/v2/client" - ) + import ( + "context" + "log" - func main() { - co := client.NewClient(client.WithToken("<>")) + cohere "github.com/cohere-ai/cohere-go/v2" + client "github.com/cohere-ai/cohere-go/v2/client" + ) - resp, err := co.Connectors.List( - context.TODO(), - &cohere.ConnectorsListRequest{}) + func main() { + co := client.NewClient(client.WithToken("<>")) - if err != nil { - log.Fatal(err) - } + resp, err := co.Connectors.List( + context.TODO(), + &cohere.ConnectorsListRequest{}) - log.Printf("%+v", resp) - } - - language: python - name: Sync - install: python -m pip install cohere --upgrade - code: | - import cohere + if err != nil { + log.Fatal(err) + } - co = cohere.Client("<>") - response = co.connectors.list() - print(response) - - language: python - name: Async - install: python -m pip install cohere --upgrade - code: | - import cohere - import asyncio + log.Printf("%+v", resp) + } + - sdk: python + name: Sync + code: | + import cohere - co = cohere.AsyncClient("<>") + co = cohere.Client("<>") + response = co.connectors.list() + print(response) + - sdk: python + name: Async + code: | + import cohere + import asyncio + co = cohere.AsyncClient("<>") - async def main(): - response = await co.connectors.list() - print(response) - asyncio.run(main()) - - language: java - name: Cohere java SDK - install: implementation 'com.cohere:cohere-java:1.0.4' - code: > - import com.cohere.api.Cohere; + async def main(): + response = await co.connectors.list() + print(response) - import com.cohere.api.types.ListConnectorsResponse; + asyncio.run(main()) + - sdk: java + name: Cohere java SDK + code: > + import com.cohere.api.Cohere; + import com.cohere.api.types.ListConnectorsResponse; - public class ConnectorsList { - public static void main(String[] args) { - Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); - ListConnectorsResponse list = cohere.connectors().list(); + public class ConnectorsList { + public static void main(String[] args) { + Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); - System.out.println(list); - } - } - - language: node - name: Cohere TypeScript SDK - install: npm i cohere-ai - code: | - const { CohereClient } = require('cohere-ai'); + ListConnectorsResponse list = cohere.connectors().list(); - const cohere = new CohereClient({ - token: '<>', - }); + System.out.println(list); + } + } + - sdk: typescript + name: Cohere TypeScript SDK + code: | + const { CohereClient } = require('cohere-ai'); - (async () => { - const connectors = await cohere.connectors.list(); + const cohere = new CohereClient({ + token: '<>', + }); - console.log(connectors); - })(); - - language: curl - name: cURL - code: |- - curl --request GET \ - --url https://api.cohere.com/v1/connectors \ - --header 'accept: application/json' \ - --header "Authorization: bearer $CO_API_KEY" + (async () => { + const connectors = await cohere.connectors.list(); + + console.log(connectors); + })(); + - sdk: curl + name: cURL + code: |- + curl --request GET \ + --url https://api.cohere.com/v1/connectors \ + --header 'accept: application/json' \ + --header "Authorization: bearer $CO_API_KEY" post: x-fern-audiences: - public @@ -6353,136 +5916,123 @@ paths: $ref: "#/components/responses/ServiceUnavailable" "504": $ref: "#/components/responses/GatewayTimeout" - x-readme: - samples-languages: - - python - - java - - python - - java - - node - - curl - - go - code-samples: - - language: go - name: Cohere Go SDK - install: go get github.com/cohere-ai/cohere-go/v2 - code: | - package main - - import ( - "context" - "log" - - cohere "github.com/cohere-ai/cohere-go/v2" - client "github.com/cohere-ai/cohere-go/v2/client" - ) - - func main() { - co := client.NewClient(client.WithToken("<>")) - - resp, err := co.Connectors.Create( - context.TODO(), - &cohere.CreateConnectorRequest{ - Name: "Example connector", - Url: "https://you-connector-url", - ServiceAuth: &cohere.CreateConnectorServiceAuth{ - Token: "dummy-connector-token", - Type: "bearer", - }, - }, - ) - - if err != nil { - log.Fatal(err) - } - - log.Printf("%+v", resp) - } - - language: python - name: Sync - install: python -m pip install cohere --upgrade - code: | - import cohere - - co = cohere.Client("<>") - response = co.connectors.create( - name="Example connector", - url="https://connector-example.com/search", - ) - print(response) - - language: python - name: Async - install: python -m pip install cohere --upgrade - code: | - import cohere - import asyncio + x-fern-examples: + - code-samples: + - sdk: go + name: Cohere Go SDK + code: | + package main + + import ( + "context" + "log" + + cohere "github.com/cohere-ai/cohere-go/v2" + client "github.com/cohere-ai/cohere-go/v2/client" + ) + + func main() { + co := client.NewClient(client.WithToken("<>")) + + resp, err := co.Connectors.Create( + context.TODO(), + &cohere.CreateConnectorRequest{ + Name: "Example connector", + Url: "https://you-connector-url", + ServiceAuth: &cohere.CreateConnectorServiceAuth{ + Token: "dummy-connector-token", + Type: "bearer", + }, + }, + ) + + if err != nil { + log.Fatal(err) + } + + log.Printf("%+v", resp) + } + - sdk: python + name: Sync + code: | + import cohere - co = cohere.AsyncClient("<>") + co = cohere.Client("<>") + response = co.connectors.create( + name="Example connector", + url="https://connector-example.com/search", + ) + print(response) + - sdk: python + name: Async + code: | + import cohere + import asyncio + co = cohere.AsyncClient("<>") - async def main(): - response = await co.connectors.create( - name="Example connector", - url="https://connector-example.com/search", - ) - print(response) - asyncio.run(main()) - - language: java - name: Cohere java SDK - install: implementation 'com.cohere:cohere-java:1.0.4' - code: > - import com.cohere.api.Cohere; + async def main(): + response = await co.connectors.create( + name="Example connector", + url="https://connector-example.com/search", + ) + print(response) - import - com.cohere.api.resources.connectors.requests.CreateConnectorRequest; + asyncio.run(main()) + - sdk: java + name: Cohere java SDK + code: > + import com.cohere.api.Cohere; - import com.cohere.api.types.CreateConnectorResponse; + import + com.cohere.api.resources.connectors.requests.CreateConnectorRequest; + import com.cohere.api.types.CreateConnectorResponse; - public class ConnectorCreate { - public static void main(String[] args) { - Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); - CreateConnectorResponse response = cohere.connectors().create(CreateConnectorRequest.builder() - .name("Example connector") - .url("https://connector-example.com/search").build()); + public class ConnectorCreate { + public static void main(String[] args) { + Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); - System.out.println(response); - } - } - - language: node - name: Cohere TypeScript SDK - install: npm i cohere-ai - code: | - const { CohereClient } = require('cohere-ai'); + CreateConnectorResponse response = cohere.connectors().create(CreateConnectorRequest.builder() + .name("Example connector") + .url("https://connector-example.com/search").build()); - const cohere = new CohereClient({ - token: '<>', - }); + System.out.println(response); + } + } + - sdk: typescript + name: Cohere TypeScript SDK + code: | + const { CohereClient } = require('cohere-ai'); - (async () => { - const connector = await cohere.connectors.create({ - name: 'test-connector', - url: 'https://example.com/search', - description: 'A test connector', + const cohere = new CohereClient({ + token: '<>', }); - console.log(connector); - })(); - - language: curl - name: Curl - code: |- - curl --request POST \ - --url https://api.cohere.com/v1/connectors \ - --header 'accept: application/json' \ - --header 'content-type: application/json' \ - --header "Authorization: bearer $CO_API_KEY" \ - --data '{ - "name": "Example connector", - "url": "https://connector-example.com/search" - }' + (async () => { + const connector = await cohere.connectors.create({ + name: 'test-connector', + url: 'https://example.com/search', + description: 'A test connector', + }); + + console.log(connector); + })(); + - sdk: curl + name: Curl + code: |- + curl --request POST \ + --url https://api.cohere.com/v1/connectors \ + --header 'accept: application/json' \ + --header 'content-type: application/json' \ + --header "Authorization: bearer $CO_API_KEY" \ + --data '{ + "name": "Example connector", + "url": "https://connector-example.com/search" + }' "/v1/connectors/{id}": get: x-fern-audiences: @@ -6537,103 +6087,92 @@ paths: $ref: "#/components/responses/ServiceUnavailable" "504": $ref: "#/components/responses/GatewayTimeout" - x-readme: - samples-languages: - - python - - java - - node - - curl - - go - code-samples: - - language: go - name: Cohere Go SDK - install: go get github.com/cohere-ai/cohere-go/v2 - code: | - package main - - import ( - "context" - "log" + x-fern-examples: + - code-samples: + - sdk: go + name: Cohere Go SDK + code: | + package main - client "github.com/cohere-ai/cohere-go/v2/client" - ) + import ( + "context" + "log" - func main() { - co := client.NewClient(client.WithToken("<>")) + client "github.com/cohere-ai/cohere-go/v2/client" + ) - resp, err := co.Connectors.Get(context.TODO(), "connector_id") + func main() { + co := client.NewClient(client.WithToken("<>")) - if err != nil { - log.Fatal(err) - } + resp, err := co.Connectors.Get(context.TODO(), "connector_id") - log.Printf("%+v", resp) - } - - language: python - name: Sync - install: python -m pip install cohere --upgrade - code: | - import cohere + if err != nil { + log.Fatal(err) + } - co = cohere.Client("<>") - response = co.connectors.get("test-id") - print(response) - - language: python - name: Async - install: python -m pip install cohere --upgrade - code: | - import cohere - import asyncio + log.Printf("%+v", resp) + } + - sdk: python + name: Sync + code: | + import cohere - co = cohere.AsyncClient("<>") + co = cohere.Client("<>") + response = co.connectors.get("test-id") + print(response) + - sdk: python + name: Async + code: | + import cohere + import asyncio + co = cohere.AsyncClient("<>") - async def main(): - response = await co.connectors.get("test-id") - print(response) - asyncio.run(main()) - - language: java - name: Cohere java SDK - install: implementation 'com.cohere:cohere-java:1.0.4' - code: > - import com.cohere.api.Cohere; + async def main(): + response = await co.connectors.get("test-id") + print(response) - import com.cohere.api.types.GetConnectorResponse; + asyncio.run(main()) + - sdk: java + name: Cohere java SDK + code: > + import com.cohere.api.Cohere; + import com.cohere.api.types.GetConnectorResponse; - public class ConnectorGet { - public static void main(String[] args) { - Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); - GetConnectorResponse response = cohere.connectors().get("test-id"); + public class ConnectorGet { + public static void main(String[] args) { + Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); - System.out.println(response); - } - } - - language: node - name: Cohere TypeScript SDK - install: npm i cohere-ai - code: | - const { CohereClient } = require('cohere-ai'); + GetConnectorResponse response = cohere.connectors().get("test-id"); - const cohere = new CohereClient({ - token: '<>', - }); + System.out.println(response); + } + } + - sdk: typescript + name: Cohere TypeScript SDK + code: | + const { CohereClient } = require('cohere-ai'); - (async () => { - const connector = await cohere.connectors.get('connector-id'); + const cohere = new CohereClient({ + token: '<>', + }); - console.log(connector); - })(); - - language: curl - name: cURL - code: |- - curl --request GET \ - --url https://api.cohere.com/v1/connectors/id \ - --header 'accept: application/json' \ - --header "Authorization: bearer $CO_API_KEY" + (async () => { + const connector = await cohere.connectors.get('connector-id'); + + console.log(connector); + })(); + - sdk: curl + name: cURL + code: |- + curl --request GET \ + --url https://api.cohere.com/v1/connectors/id \ + --header 'accept: application/json' \ + --header "Authorization: bearer $CO_API_KEY" patch: x-fern-audiences: - public @@ -6694,129 +6233,120 @@ paths: $ref: "#/components/responses/ServiceUnavailable" "504": $ref: "#/components/responses/GatewayTimeout" - x-readme: - samples-languages: - - python - - java - - node - - curl - - go - code-samples: - - language: go - name: Cohere Go SDK - install: go get github.com/cohere-ai/cohere-go/v2 - code: | - package main - - import ( - "context" - "log" - - cohere "github.com/cohere-ai/cohere-go/v2" - client "github.com/cohere-ai/cohere-go/v2/client" - ) - - func main() { - co := client.NewClient(client.WithToken("<>")) - - resp, err := co.Connectors.Update( - context.TODO(), - "connector_id", - &cohere.UpdateConnectorRequest{ - Name: cohere.String("Example connector renamed"), - }, - ) - - if err != nil { - log.Fatal(err) - } - - log.Printf("%+v", resp) - } - - language: python - name: Sync - install: python -m pip install cohere --upgrade - code: > - import cohere - - - co = cohere.Client("<>") - - response = co.connectors.update( - connector_id="test-id", name="new name", url="https://example.com/search" - ) + x-fern-examples: + - code-samples: + - sdk: go + name: Cohere Go SDK + code: | + package main + + import ( + "context" + "log" + + cohere "github.com/cohere-ai/cohere-go/v2" + client "github.com/cohere-ai/cohere-go/v2/client" + ) + + func main() { + co := client.NewClient(client.WithToken("<>")) + + resp, err := co.Connectors.Update( + context.TODO(), + "connector_id", + &cohere.UpdateConnectorRequest{ + Name: cohere.String("Example connector renamed"), + }, + ) + + if err != nil { + log.Fatal(err) + } + + log.Printf("%+v", resp) + } + - sdk: python + name: Sync + code: > + import cohere - print(response) - - language: python - name: Async - install: python -m pip install cohere --upgrade - code: > - import cohere - import asyncio + co = cohere.Client("<>") + response = co.connectors.update( + connector_id="test-id", name="new name", url="https://example.com/search" + ) - co = cohere.AsyncClient("<>") + print(response) + - sdk: python + name: Async + code: > + import cohere + import asyncio - async def main(): - response = await co.connectors.update( - connector_id="test-id", name="new name", url="https://example.com/search" - ) - print(response) + co = cohere.AsyncClient("<>") - asyncio.run(main()) - - language: java - name: Cohere java SDK - install: implementation 'com.cohere:cohere-java:1.0.4' - code: > - import com.cohere.api.Cohere; - import - com.cohere.api.resources.connectors.requests.UpdateConnectorRequest; + async def main(): + response = await co.connectors.update( + connector_id="test-id", name="new name", url="https://example.com/search" + ) + print(response) + asyncio.run(main()) + - sdk: java + name: Cohere java SDK + code: > + import com.cohere.api.Cohere; - public class ConnectorPatch { - public static void main(String[] args) { - Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); + import + com.cohere.api.resources.connectors.requests.UpdateConnectorRequest; - cohere.connectors().update("test-id", UpdateConnectorRequest.builder() - .name("new name") - .url("https://connector-example.com/search").build()); - } - } - - language: node - name: Cohere TypeScript SDK - install: npm i cohere-ai - code: | - const { CohereClient } = require('cohere-ai'); - const cohere = new CohereClient({ - token: '<>', - }); - (async () => { - const connector = await cohere.connectors.update(connector.id, { - name: 'test-connector-renamed', - description: 'A test connector renamed', + public class ConnectorPatch { + public static void main(String[] args) { + Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); + + cohere.connectors().update("test-id", UpdateConnectorRequest.builder() + .name("new name") + .url("https://connector-example.com/search").build()); + } + } + - sdk: typescript + name: Cohere TypeScript SDK + code: > + const { CohereClient } = require('cohere-ai'); + + + const cohere = new CohereClient({ + token: '<>', }); - console.log(connector); - })(); - - language: curl - name: Curl - code: |- - curl --request PATCH \ - --url https://api.cohere.com/v1/connectors/id \ - --header 'accept: application/json' \ - --header 'content-type: application/json' \ - --header "Authorization: bearer $CO_API_KEY" \ - --data '{ - "name": "new name", - "url": "https://example.com/search" - }' + + (async () => { + const connector = await cohere.connectors.update(connector.id, { + name: 'test-connector-renamed', + description: 'A test connector renamed', + }); + + console.log(connector); + })(); + - sdk: curl + name: Curl + code: |- + curl --request PATCH \ + --url https://api.cohere.com/v1/connectors/id \ + --header 'accept: application/json' \ + --header 'content-type: application/json' \ + --header "Authorization: bearer $CO_API_KEY" \ + --data '{ + "name": "new name", + "url": "https://example.com/search" + }' delete: x-fern-audiences: - public @@ -6870,96 +6400,87 @@ paths: $ref: "#/components/responses/ServiceUnavailable" "504": $ref: "#/components/responses/GatewayTimeout" - x-readme: - samples-languages: - - python - - java - - node - - curl - - go - code-samples: - - language: go - name: Cohere Go SDK - install: go get github.com/cohere-ai/cohere-go/v2 - code: | - package main + x-fern-examples: + - code-samples: + - sdk: go + name: Cohere Go SDK + code: > + package main - import ( - "context" - "log" - client "github.com/cohere-ai/cohere-go/v2/client" - ) + import ( + "context" + "log" - func main() { - co := client.NewClient(client.WithToken("<>")) + client "github.com/cohere-ai/cohere-go/v2/client" + ) - resp, err := co.Connectors.Delete(context.TODO(), "connector_id") - if err != nil { - log.Fatal(err) - } + func main() { + co := client.NewClient(client.WithToken("<>")) - log.Printf("%+v", resp) - } - - language: node - name: Cohere TypeScript SDK - install: npm i cohere-ai - code: | - const { CohereClient } = require('cohere-ai'); + resp, err := co.Connectors.Delete(context.TODO(), "connector_id") - const cohere = new CohereClient({ - token: '<>', - }); + if err != nil { + log.Fatal(err) + } - (async () => { - await cohere.connectors.delete('connector-id'); - })(); - - language: python - name: Sync - install: python -m pip install cohere --upgrade - code: | - import cohere + log.Printf("%+v", resp) + } + - sdk: typescript + name: Cohere TypeScript SDK + code: | + const { CohereClient } = require('cohere-ai'); - co = cohere.Client("<>") - co.connectors.delete("test-id") - - language: python - name: Async - install: python -m pip install cohere --upgrade - code: | - import cohere - import asyncio + const cohere = new CohereClient({ + token: '<>', + }); - co = cohere.AsyncClient("<>") + (async () => { + await cohere.connectors.delete('connector-id'); + })(); + - sdk: python + name: Sync + code: | + import cohere + co = cohere.Client("<>") + co.connectors.delete("test-id") + - sdk: python + name: Async + code: | + import cohere + import asyncio - async def main(): - await co.connectors.delete("test-id") + co = cohere.AsyncClient("<>") - asyncio.run(main()) - - language: java - name: Cohere java SDK - install: implementation 'com.cohere:cohere-java:1.0.4' - code: >+ - import com.cohere.api.Cohere; + async def main(): + await co.connectors.delete("test-id") + asyncio.run(main()) + - sdk: java + name: Cohere java SDK + code: >+ + import com.cohere.api.Cohere; - public class ConnectorDelete { - public static void main(String[] args) { - Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); - cohere.connectors().delete("test-id"); - } - } - - language: curl - name: cURL - code: |- - curl --request DELETE \ - --url https://api.cohere.com/v1/connectors/id \ - --header 'accept: application/json' \ - --header "Authorization: bearer $CO_API_KEY" + public class ConnectorDelete { + public static void main(String[] args) { + Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); + + cohere.connectors().delete("test-id"); + } + } + + - sdk: curl + name: cURL + code: |- + curl --request DELETE \ + --url https://api.cohere.com/v1/connectors/id \ + --header 'accept: application/json' \ + --header "Authorization: bearer $CO_API_KEY" "/v1/connectors/{id}/oauth/authorize": post: x-fern-audiences: @@ -7022,129 +6543,116 @@ paths: $ref: "#/components/responses/ServiceUnavailable" "504": $ref: "#/components/responses/GatewayTimeout" - x-readme: - samples-languages: - - python - - java - - python - - java - - node - - curl - - go - code-samples: - - language: go - name: Cohere Go SDK - install: go get github.com/cohere-ai/cohere-go/v2 - code: | - package main - - import ( - "context" - "log" - - cohere "github.com/cohere-ai/cohere-go/v2" - client "github.com/cohere-ai/cohere-go/v2/client" - ) - - func main() { - co := client.NewClient(client.WithToken("<>")) - - resp, err := co.Connectors.OAuthAuthorize( - context.TODO(), - "connector_id", - &cohere.ConnectorsOAuthAuthorizeRequest{ - AfterTokenRedirect: cohere.String("https://test.com"), - }, - ) - - if err != nil { - log.Fatal(err) - } - - log.Printf("%+v", resp) - } - - language: python - name: Sync - install: python -m pip install cohere --upgrade - code: > - import cohere - - - co = cohere.Client("<>") + x-fern-examples: + - code-samples: + - sdk: go + name: Cohere Go SDK + code: | + package main + + import ( + "context" + "log" + + cohere "github.com/cohere-ai/cohere-go/v2" + client "github.com/cohere-ai/cohere-go/v2/client" + ) + + func main() { + co := client.NewClient(client.WithToken("<>")) + + resp, err := co.Connectors.OAuthAuthorize( + context.TODO(), + "connector_id", + &cohere.ConnectorsOAuthAuthorizeRequest{ + AfterTokenRedirect: cohere.String("https://test.com"), + }, + ) + + if err != nil { + log.Fatal(err) + } + + log.Printf("%+v", resp) + } + - sdk: python + name: Sync + code: > + import cohere - response = co.connectors.o_auth_authorize( - connector_id="test-id", after_token_redirect="https://test.com" - ) - print(response) - - language: python - name: Async - install: python -m pip install cohere --upgrade - code: > - import cohere + co = cohere.Client("<>") - import asyncio + response = co.connectors.o_auth_authorize( + connector_id="test-id", after_token_redirect="https://test.com" + ) + print(response) + - sdk: python + name: Async + code: > + import cohere - co = cohere.AsyncClient("<>") + import asyncio + co = cohere.AsyncClient("<>") - async def main(): - response = await co.connectors.o_auth_authorize( - connector_id="test-id", after_token_redirect="https://test.com" - ) - print(response) - asyncio.run(main()) - - language: java - name: Cohere java SDK - install: implementation 'com.cohere:cohere-java:1.0.4' - code: > - import com.cohere.api.Cohere; - import - com.cohere.api.resources.connectors.requests.ConnectorsOAuthAuthorizeRequest; + async def main(): + response = await co.connectors.o_auth_authorize( + connector_id="test-id", after_token_redirect="https://test.com" + ) + print(response) - import com.cohere.api.types.OAuthAuthorizeResponse; + asyncio.run(main()) + - sdk: java + name: Cohere java SDK + code: > + import com.cohere.api.Cohere; + import + com.cohere.api.resources.connectors.requests.ConnectorsOAuthAuthorizeRequest; + import com.cohere.api.types.OAuthAuthorizeResponse; - public class ConnectorsIdOauthAuthorizePost { - public static void main(String[] args) { - Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); - OAuthAuthorizeResponse response = cohere.connectors().oAuthAuthorize("test-id", ConnectorsOAuthAuthorizeRequest.builder().afterTokenRedirect("https://connector-example.com/search").build()); - System.out.println(response); - } - } - - language: node - name: Cohere TypeScript SDK - install: npm i cohere-ai - code: > - const { CohereClient } = require('cohere-ai'); + public class ConnectorsIdOauthAuthorizePost { + public static void main(String[] args) { + Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); + OAuthAuthorizeResponse response = cohere.connectors().oAuthAuthorize("test-id", ConnectorsOAuthAuthorizeRequest.builder().afterTokenRedirect("https://connector-example.com/search").build()); - const cohere = new CohereClient({ - token: '<>', - }); + System.out.println(response); + } + } + - sdk: typescript + name: Cohere TypeScript SDK + code: > + const { CohereClient } = require('cohere-ai'); - (async () => { - const connector = await cohere.connectors.oAuthAuthorize('connector-id', { - redirect_uri: 'https://example.com/oauth/callback', + const cohere = new CohereClient({ + token: '<>', }); - console.log(connector); - })(); - - language: curl - name: cURL - code: |- - curl --request POST \ - --url https://api.cohere.com/v1/connectors/id/oauth/authorize \ - --header 'accept: application/json' \ - --header "Authorization: bearer $CO_API_KEY" + + (async () => { + const connector = await cohere.connectors.oAuthAuthorize('connector-id', { + redirect_uri: 'https://example.com/oauth/callback', + }); + + console.log(connector); + })(); + - sdk: curl + name: cURL + code: >- + curl --request POST \ + --url https://api.cohere.com/v1/connectors/id/oauth/authorize \ + --header 'accept: application/json' \ + --header "Authorization: bearer $CO_API_KEY" "/v1/models/{model}": get: summary: Get a Model @@ -7282,106 +6790,95 @@ paths: $ref: "#/components/responses/ServiceUnavailable" "504": $ref: "#/components/responses/GatewayTimeout" - x-readme: - samples-languages: - - node - - curl - - python - - java - - go - code-samples: - - language: python - name: Sync - install: python -m pip install cohere --upgrade - code: | - import cohere - - co = cohere.Client("<>") - response = co.models.list() - print(response) - - language: python - name: Async - install: python -m pip install cohere --upgrade - code: | - import cohere - import asyncio + x-fern-examples: + - code-samples: + - sdk: python + name: Sync + code: | + import cohere - co = cohere.AsyncClient("<>") + co = cohere.Client("<>") + response = co.models.list() + print(response) + - sdk: python + name: Async + code: | + import cohere + import asyncio + co = cohere.AsyncClient("<>") - async def main(): - response = await co.models.list() - print(response) - asyncio.run(main()) - - language: java - name: Cohere java SDK - install: implementation 'com.cohere:cohere-java:1.0.4' - code: > - import com.cohere.api.Cohere; + async def main(): + response = await co.models.list() + print(response) - import com.cohere.api.types.ListModelsResponse; + asyncio.run(main()) + - sdk: java + name: Cohere java SDK + code: > + import com.cohere.api.Cohere; + import com.cohere.api.types.ListModelsResponse; - public class ModelsListGet { - public static void main(String[] args) { - Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); - ListModelsResponse response = cohere.models().list(); + public class ModelsListGet { + public static void main(String[] args) { + Cohere cohere = Cohere.builder().token("<>").clientName("snippet").build(); - System.out.println(response); - } - } - - language: curl - name: cURL - code: |- - curl --request GET \ - --url https://api.cohere.com/v1/models \ - --header 'accept: application/json' \ - --header "Authorization: bearer $CO_API_KEY" - - language: node - name: Cohere TypeScript SDK - install: npm i cohere-ai - code: | - const { CohereClient } = require('cohere-ai'); + ListModelsResponse response = cohere.models().list(); - const cohere = new CohereClient({ - token: '<>', - }); + System.out.println(response); + } + } + - sdk: curl + name: cURL + code: |- + curl --request GET \ + --url https://api.cohere.com/v1/models \ + --header 'accept: application/json' \ + --header "Authorization: bearer $CO_API_KEY" + - sdk: typescript + name: Cohere TypeScript SDK + code: | + const { CohereClient } = require('cohere-ai'); + + const cohere = new CohereClient({ + token: '<>', + }); - (async () => { - const models = await cohere.models.list(); + (async () => { + const models = await cohere.models.list(); - console.log(models); - })(); - - language: go - name: Cohere Go SDK - install: go get github.com/cohere-ai/cohere-go/v2 - code: > - package main + console.log(models); + })(); + - sdk: go + name: Cohere Go SDK + code: > + package main - import ( - "context" - "log" + import ( + "context" + "log" - cohere "github.com/cohere-ai/cohere-go/v2" - client "github.com/cohere-ai/cohere-go/v2/client" - ) + cohere "github.com/cohere-ai/cohere-go/v2" + client "github.com/cohere-ai/cohere-go/v2/client" + ) - func main() { - co := client.NewClient(client.WithToken("<>")) + func main() { + co := client.NewClient(client.WithToken("<>")) - resp, err := co.Models.List(context.TODO(), &cohere.ModelsListRequest{}) + resp, err := co.Models.List(context.TODO(), &cohere.ModelsListRequest{}) - if err != nil { - log.Fatal(err) - } + if err != nil { + log.Fatal(err) + } - log.Printf("%+v", resp) - } + log.Printf("%+v", resp) + } /v1/check-api-key: post: parameters: @@ -9806,7 +9303,6 @@ components: description: Content block of the message that contains information about documents. required: - type - - id - document properties: type: @@ -9848,6 +9344,9 @@ components: enum: - user content: + description: | + The content of the message. This can be a string or a list of content blocks. + If a string is provided, it will be treated as a text content block. oneOf: - type: string - type: array @@ -9923,11 +9422,14 @@ components: - function function: type: object + description: The function to be executed. properties: name: type: string + description: The name of the function. description: type: string + description: The description of the function. parameters: type: object description: The parameters of the function as a JSON schema. @@ -13010,20 +12512,6 @@ components: description: The text of the document to rerank. required: - text - ClassifyExample: - type: object - properties: - text: - type: string - x-fern-audiences: - - public - writeOnly: true - label: - type: string - x-fern-audiences: - - public - writeOnly: true - writeOnly: true DatasetValidationStatus: x-fern-audiences: - public @@ -14606,5 +14094,3 @@ components: properties: data: type: string -x-readme: - disable-tag-sorting: true