Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: update tutorials #7358

Open
wants to merge 34 commits into
base: main
Choose a base branch
from
Open

docs: update tutorials #7358

wants to merge 34 commits into from

Conversation

ccurme
Copy link
Contributor

@ccurme ccurme commented Dec 12, 2024

Copy link

vercel bot commented Dec 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchainjs-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 13, 2024 8:02pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchainjs-api-refs ⬜️ Ignored (Inspect) Dec 13, 2024 8:02pm

@ccurme ccurme marked this pull request as ready for review December 13, 2024 19:47
@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. auto:documentation Changes to documentation and examples, like .md, .rst, .ipynb files. Changes to the docs/ folder labels Dec 13, 2024
Copy link
Collaborator

@jacoblee93 jacoblee93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for this!

@@ -61,6 +61,18 @@
"source": "/docs/integrations/llms/togetherai(/?)",
"destination": "/docs/integrations/llms/together/"
},
{
"source": "/docs/tutorials/query_analysis(/?)",
"destination": "/docs/tutorials/rag#query-analysis/"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this hash will do anything since this happens on the backend - not sure though

"- [Prompt Templates](/docs/concepts/prompt_templates)\n",
"- [Chat History](/docs/concepts/chat_history)\n",
"\n",
"This guide requires `langgraph >= 0.2.28`.\n",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are moving all this to use LangGraph, should we just work towards combine docs?

Not in this PR obviously but in general

"\n",
"This guide (and most of the other guides in the documentation) uses [Jupyter notebooks](https://jupyter.org/) and assumes the reader is as well. Jupyter notebooks are perfect for learning how to work with LLM systems because oftentimes things can go wrong (unexpected output, API down, etc) and going through guides in an interactive environment is a great way to better understand them.\n",
"\n",
"This and other tutorials are perhaps most conveniently run in a Jupyter notebook. See [here](https://jupyter.org/install) for instructions on how to install.\n",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be in a followup but we should have a guide on how to set up TSLab since it's not a typical experience for JS devs

"\n",
"const promptTemplate = ChatPromptTemplate.fromMessages([\n",
" [\"system\", \"You talk like a pirate. Answer all questions to the best of your ability.\"],\n",
" new MessagesPlaceholder(\"messages\"),\n",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: use shorthand:

["placeholder", "{messages}"],

But also, should we just be using a function rather than a prompt template?

"})\n",
"\n",
"const messages = [\n",
" new SystemMessage(\"you're a good assistant\"),\n",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we just make these OpenAI dicts to remove the need to import?

"metadata": {},
"outputs": [],
"source": [
"const structuredLlm = llm.withStructuredOutput({\n",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: prefer Zod?

"import { StateGraph } from \"@langchain/langgraph\";\n",
"\n",
"const graphBuilder = new StateGraph({\n",
" input: InputStateAnnotation,\n",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above, we don't need all 3 declared here

"const prettyPrint = (message: BaseMessage) => {\n",
" let txt = `[${message._getType()}]: ${message.content}`;\n",
" if (\n",
" (isAIMessage(message) && (message as AIMessage)?.tool_calls?.length) ||\n",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above, you shouldn't need the cast

"source": [
"## Stuff: summarize in a single LLM call {#stuff}\n",
"\n",
"We can use [create_stuff_documents_chain](https://python.langchain.com/api_reference/langchain/chains/langchain.chains.combine_documents.stuff.create_stuff_documents_chain.html), especially if using larger context window models such as:\n",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update to JS equivalents

"}\n",
"\n",
"// Here we generate a summary, given a document\n",
"const generateSummary = async (state: SummaryState): Promise<{ summaries: string[] }> => {\n",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why declare another type here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:documentation Changes to documentation and examples, like .md, .rst, .ipynb files. Changes to the docs/ folder size:XXL This PR changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants