From 2f3982fdf6d5d2d98ae67afd2b7ecf6c4cc56811 Mon Sep 17 00:00:00 2001 From: jacoblee93 Date: Tue, 24 Sep 2024 17:23:14 -0700 Subject: [PATCH] Update section on formatting prompt hub prompts without LangChain --- .../manage_prompts_programatically.mdx | 82 +++++++++++++++++-- 1 file changed, 77 insertions(+), 5 deletions(-) diff --git a/versioned_docs/version-2.0/how_to_guides/prompts/manage_prompts_programatically.mdx b/versioned_docs/version-2.0/how_to_guides/prompts/manage_prompts_programatically.mdx index 82c52fda..d620945f 100644 --- a/versioned_docs/version-2.0/how_to_guides/prompts/manage_prompts_programatically.mdx +++ b/versioned_docs/version-2.0/how_to_guides/prompts/manage_prompts_programatically.mdx @@ -112,7 +112,7 @@ print(url) `), TypeScriptBlock(`import * as prompts from "langchain/hub"; import { ChatPromptTemplate } from "@langchain/core/prompts"; -import { ChatOpenAI } from "langchain-openai";\n +import { ChatOpenAI } from "@langchain/openai";\n const model = new ChatOpenAI({ model: "gpt-4o-mini" });\n const prompt = ChatPromptTemplate.fromTemplate("tell me a joke about {topic}"); const chain = prompt.pipe(model);\n @@ -145,11 +145,11 @@ model = ChatOpenAI(model="gpt-4o-mini")\n chain = prompt | model chain.invoke({"topic": "cats"})`), TypeScriptBlock(`import * as prompts from "langchain/hub"; -import { ChatOpenAI } from "langchain-openai";\n +import { ChatOpenAI } from "@langchain/openai";\n const prompt = prompts.pull("joke-generator"); const model = new ChatOpenAI({ model: "gpt-4o-mini" });\n const chain = prompt.pipe(model); -chain.invoke({"topic": "cats"});`), +await chain.invoke({"topic": "cats"});`), ]} groupId="client-language" /> @@ -171,7 +171,7 @@ chain.invoke({"topic": "cats"})`), TypeScriptBlock(`import * as prompts from "langchain/hub"; import { Runnable } from "@langchain/core/runnables";\n const chain = prompts.pull("joke-generator-with-model", { includeModel: true }); -chain.invoke({"topic": "cats"});`), +await chain.invoke({"topic": "cats"});`), ]} groupId="client-language" /> @@ -203,6 +203,21 @@ To pull a public prompt from the LangChain Hub, you need to specify the handle o If you want to store your prompts in LangSmith but use them directly with a model provider's API, you can use our conversion methods. These convert your prompt into the payload required for the OpenAI or Anthropic API. +These conversion methods rely on logic from within LangChain integration packages, and you will need to install the appropriate package as a dependency +in addition to your official SDK of choice. Here are some examples: + +### OpenAI + += 0.3.2` + ), + ]} + groupId="client-language" +/> + + +### Anthropic + += 0.3.3` + ), + ]} + groupId="client-language" +/> + +