From 654853b7f96a755536c834ddb6edcb5c3922fa2c Mon Sep 17 00:00:00 2001 From: Andrew Jiang Date: Thu, 8 Aug 2024 11:44:18 -0400 Subject: [PATCH] fixes a few more titles --- fern/pages/cookbooks/basic-rag.mdx | 2 +- fern/pages/cookbooks/sql-agent.mdx | 2 +- ...ting-a-multi-step-agent-with-langchain.mdx | 21 +++++++++++-------- fern/pages/text-generation/tools/tool-use.mdx | 2 +- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/fern/pages/cookbooks/basic-rag.mdx b/fern/pages/cookbooks/basic-rag.mdx index 7823ea71..8f696e8b 100644 --- a/fern/pages/cookbooks/basic-rag.mdx +++ b/fern/pages/cookbooks/basic-rag.mdx @@ -365,7 +365,7 @@ print(insert_citations_in_order(response.text, response.citations)) ``` -```markdown title="Output" +```markdown OUTPUT Here are the key crew members involved in 'Dune: Part Two': - **Denis Villeneuve**[1]: **director and producer**[1] diff --git a/fern/pages/cookbooks/sql-agent.mdx b/fern/pages/cookbooks/sql-agent.mdx index cb70d083..097a9475 100644 --- a/fern/pages/cookbooks/sql-agent.mdx +++ b/fern/pages/cookbooks/sql-agent.mdx @@ -378,7 +378,7 @@ print('Table Schemas') print(context['table_info']) ``` -```sql title="Output" +```sql OUTPUT **Context to pass to LLM on tables** Table Names Album, Artist, Customer, Employee, Genre, Invoice, InvoiceLine, MediaType, Playlist, PlaylistTrack, Track diff --git a/fern/pages/text-generation/tools/multi-step-tool-use/implementing-a-multi-step-agent-with-langchain.mdx b/fern/pages/text-generation/tools/multi-step-tool-use/implementing-a-multi-step-agent-with-langchain.mdx index 77a4a3b9..45d15b77 100644 --- a/fern/pages/text-generation/tools/multi-step-tool-use/implementing-a-multi-step-agent-with-langchain.mdx +++ b/fern/pages/text-generation/tools/multi-step-tool-use/implementing-a-multi-step-agent-with-langchain.mdx @@ -6,14 +6,17 @@ hidden: false createdAt: "Mon Jun 17 2024 19:41:14 GMT+0000 (Coordinated Universal Time)" updatedAt: "Wed Jun 19 2024 12:58:15 GMT+0000 (Coordinated Universal Time)" --- + In this document, we'll go through the nuts-and-bolts of building a generative-AI agent with Cohere's multi-step tool use functionality and the Langchain framework. ## Building the Langchain ReAct Agent Multi-step tool use with Cohere can be implemented using the [Langchain framework](https://python.langchain.com/docs/integrations/providers/cohere), which conveniently comes with many pre-defined tools. More specifically, we recommend using the [ReAct](https://react-lm.github.io/) agent abstraction in Langchain, powered by `create_cohere_react_agent`. Let’s see how we can easily build an agent, using the multi-step tool use capabilities of Langchain and Cohere. - - The example below is also available in [this Jupyter Notebook](https://github.com/cohere-ai/notebooks/blob/main/notebooks/agents/Vanilla_Multi_Step_Tool_Use.ipynb) for convenience. + + The example below is also available in [this Jupyter + Notebook](https://github.com/cohere-ai/notebooks/blob/main/notebooks/agents/Vanilla_Multi_Step_Tool_Use.ipynb) + for convenience. First, we'll install the dependencies. (Note: the `!` is required for notebooks, but you must omit it if you're in the command line). @@ -149,7 +152,7 @@ We can get some insight into what's going on under the hood by taking a look at # Here is the model plan I will search for tips on writing an essay and fun facts about the Roman Empire. - + # The model decides to use a first tool: the vector store {'tool_name': 'vectorstore_search', 'parameters': {'query': 'tips for writing an essay'}} @@ -163,16 +166,16 @@ need [ … more of retrieved snippet 2 … ] You don't have to get an answer right the first time, but there's no excuse for not getting it right eventually, because [ more of retrieved snippet 3 … ] - + # The model decides to use another tool: web search {'tool_name': 'internet_search', 'parameters': {'query': 'fun facts about the roman empire'}} # Here are the results from the web search call: retrieved passages [{'url': 'https://www.natgeokids.com/uk/discover/history/romans/10-facts-about-the-ancient-romans/', 'content': 'i love this website\nBIG BOBBY\nbooby\nI love shell my bae;)\ni like bobby fishes ;0\nI like turtles\nOmg soy cool\ngreeeeeeeeeeeeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaatttttttttttttttttttttttt\nbest fact ever\nthis artical is cool\nHANDY\nrubbish did not help what so ever\nha\nRocking\nTHIS IS THE BEST\nproper rad in it cool\nthis is cool\nawesomeness\nawsome\nawsome\nthank you captain\nit is a lot of help\ni like this\nwebsite it helps me on my projects and isabel likes munier\nmark uses this for research\nlot of help\nthis is awsome\nTHE BEST BOOBOO\nCool webpage helped me get 4 housepoints\n This helped me A LOT on a school project\ncool wow awesomoe\nCOOL WEBSITE LOL\nthis helped me with a school project :)\nthat was awesome\ncool\nthat helped me out for my research test\nReally its very cool really COOL\nLIKE COOL best website so far its nice\nI love it\nnice facts\nIt help with my history\n i mean u made animaljam a awesome nice safe place for kids and this site to have kids a safe website to get facts for reports and stuff\nLots of Love ,\nRose\npretty good website if u ask me\nbut definently not gonna use it on a daily basis\nIll try it again another time\ngood\nCool webcite\nterrible\nquite impressive\nAwesome website it real helps\nits good\nthis is a great website! You really a lot with my project!:)\nthis has helleped\nme get\nmy progect\ndone\nthank you\nsoooooooooooooooooo\nmuchchchchchch\nthis helleped me\nsooooooooo much with my progect thank you\nvery good website\nthank us very much your nice one today!!\n'}, {'url': 'https://ohfact.com/roman-empire-facts/', 'content': 'Learn about the ancient Roman Civilization, its history, culture, army, architecture, food and more from this list of 27 facts. Discover how the Romans started, conquered, lived, died and influenced the world with their legends, myths and facts.'}, {'url': 'https://factnight.com/fun-facts-about-the-roman-empire/', 'content': 'The Roman Empire was one of the most influential and significant civilizations in world history. At its peak, the empire stretched from North Africa to Britain, reigning over 60 million people. From its legendary beginnings and remarkable achievements to its eventual decline and fall, the Roman Empire is a fascinating topic full of little-known facts and intriguing trivia.'}, {'url': 'https://www.historyhit.com/facts-about-ancient-rome-and-the-romans/', 'content': 'The Enduring Legacy of C.S. Lewis\nMargaret J. Winkler: A Forgotten Pioneer in Disney’s Success\n10 Facts About Harper Lee\nAntarctica Expedition Cruise\nUncover Pompeii\nSophie Hay and Tristan Hughes\nRediscovering Richard III with Matt Lewis\nOrder the History Hit Miscellany\nHistory Hit Holidays\nGift Subscriptions\n100 Facts About Ancient Rome and the Romans\nRome wasn’t built in a day, as the cliché reminds us. The Crossing of the Rhine in 405/6 AD brought around 100,000 barbarians into the Empire\nBarbarian factions, tribes and war leaders were now a factor in the power struggles at the top of Roman politics and one of the once-strong boundaries of the Empire had proved to be permeable.\n Related Articles\n10 Facts About Saint Andrew\nThe Rise of Pompey the Great, the ‘Roman Alexander’\nWatch and Listen\nCleopatra\nSex in Ancient Rome\nRelated Locations\nBaelo Claudia\nMausoleum of Cecilia Metella\nColin Ricketts\n30 July 2021\n By the fourth century BC, the story was accepted by Romans who were proud of their warrior founder\nThe story was included in the first history of the city, by the Greek writer Diocles of Peparethus, and the twins and their wolf step-mother were depicted on Rome’s first coins.\n The History Hit Miscellany of Facts, Figures and Fascinating Finds\nA History of England: Part One\nDragons: Myth & Reality\nA Tudor Wonder - Hardwick Hall\nThe Battle of Shrewsbury\nEurope’s 1848 Revolutions\nThe Boston Tea Party\nHow Did 3 People Seemingly Escape From Alcatraz?\n'}, {'url': 'https://www.countryfaq.com/facts-about-the-roman-empire/', 'content': 'Facts about the Roman Empire. Explore some of the interesting, fun, cool facts bout the Roman Empire: 1. The Magnificent Roman Empire. The Roman Empire, a colossal entity of unparalleled grandeur, occupies an indomitable position within the annals of human history, a name that resonates resoundingly across the eons.'}]Relevant Documents: 0,3,4,5 - + # The model decides it has enough info to generate a final response. - + # Below is the answer by the model Answer: Here are some tips for writing an essay: - Start with a question that spurs some response. @@ -259,7 +262,7 @@ vectorstore_search = create_retriever_tool( ### Multi-turn Conversations and Chat History -So far, we asked one-off questions to the ReAct agent. In many enterprise applications, end users want to have conversations with the ReAct agent. +So far, we asked one-off questions to the ReAct agent. In many enterprise applications, end users want to have conversations with the ReAct agent. The ReAct agent can handle multi-turn conversations by using `chat_history`. @@ -296,7 +299,7 @@ response['output'] ### Can the ReAct Agent Directly Answer a Question? -Yes. The ReAct agent from Cohere comes out of the box with the ability to answer a user question directly. This happens when answering the user's question doesn’t require using a tool. +Yes. The ReAct agent from Cohere comes out of the box with the ability to answer a user question directly. This happens when answering the user's question doesn’t require using a tool. For example, let’s look at the following question: @@ -311,7 +314,7 @@ By inspecting the logs, we see that the ReAct agent decided to just respond dire ````asp > Entering new AgentExecutor chain... Plan: I will respond to the user's greeting. -Action: ```json JSON +Action: ```json [ { "tool_name": "directly_answer", diff --git a/fern/pages/text-generation/tools/tool-use.mdx b/fern/pages/text-generation/tools/tool-use.mdx index ba95a52a..d5af67c0 100644 --- a/fern/pages/text-generation/tools/tool-use.mdx +++ b/fern/pages/text-generation/tools/tool-use.mdx @@ -297,7 +297,7 @@ for cite in response.citations: There may be times when a single-step tool use query doesn't turn up a tool that will help answer the question. In those scenarios the model will return an empty list of `tool_calls`, along with an empty string in the `text` field. In that case, call the Chat API again with an empty list of `tool_results` -```python python +```python PYTHON res = co.chat(message=message, tools=tools) if not response.tool_calls: