From 12a1d4c257eda7af42c24c42dddf8e404f00af01 Mon Sep 17 00:00:00 2001 From: Erick Friis Date: Tue, 22 Oct 2024 13:08:13 -0700 Subject: [PATCH] x --- docs/src/theme/RedirectAnchors.js | 94 +++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 docs/src/theme/RedirectAnchors.js diff --git a/docs/src/theme/RedirectAnchors.js b/docs/src/theme/RedirectAnchors.js new file mode 100644 index 00000000000..83189e20a70 --- /dev/null +++ b/docs/src/theme/RedirectAnchors.js @@ -0,0 +1,94 @@ +import {Redirect} from '@docusaurus/router'; + +const RedirectAnchors = () => { + // get # anchor from url + const lookup = { + "#conceptual-guide": "/docs/concepts", + "#architecture": "/docs/concepts/architecture", + "#langchaincore": "/docs/concepts/architecture/#langchain-core", + "#langchain": "/docs/concepts/architecture/#langchain", + "#langchaincommunity": "/docs/concepts/architecture/#langchain-community", + "#partner-packages": "/docs/concepts/architecture/#partner-packages", + "#langgraph": "/docs/concepts/architecture/#langgraph", + "#langserve": "/docs/concepts/architecture/#langserve", + "#langsmith": "/docs/concepts/architecture/#langsmith", + "#langchain-expression-language-lcel": "/docs/concepts/lcel", + "#runnable-interface": "/docs/concepts/runnables", + "#components": "/docs/concepts/", + "#chat-models": "/docs/concepts/chat_models", + "#multimodality": "/docs/concepts/multimodality", + "#llms": "/docs/concepts/chat_models", + "#messages": "/docs/concepts/messages", + "#humanmessage": "/docs/concepts/messages/#humanmessage", + "#aimessage": "/docs/concepts/messages/#aimessage", + "#systemmessage": "/docs/concepts/messages/#systemmessage", + "#toolmessage": "/docs/concepts/messages/#toolmessage", + "#legacy-functionmessage": "/docs/concepts/messages/#legacy-functionmessage", + "#prompt-templates": "/docs/concepts/prompt_templates", + "#string-prompttemplates": "/docs/concepts/prompt_templates", + "#chatprompttemplates": "/docs/concepts/prompt_templates", + "#messagesplaceholder": "/docs/concepts/prompt_templates", + "#example-selectors": "/docs/concepts/example_selectors", + "#output-parsers": "/docs/concepts/output_parsers", + "#chat-history": "/docs/concepts/chat_history", + "#documents": "https://python.langchain.com/api_reference/core/documents/langchain_core.documents.base.Document.html", + "#document-loaders": "/docs/concepts/document_loaders", + "#text-splitters": "/docs/concepts/text_splitters", + "#embedding-models": "/docs/concepts/embedding_models", + "#vector-stores": "/docs/concepts/vectorstores", + "#retrievers": "/docs/concepts/retrievers", + "#keyvalue-stores": "/docs/concepts/key_value_stores", + "#interface": "/docs/concepts/runnables", + "#tools": "/docs/concepts/tools", + "#invoke-with-just-the-arguments": "/docs/concepts/tools", + "#invoke-with-toolcall": "/docs/concepts/tools", + "#best-practices": "/docs/concepts/tools/#best-practices", + "#related": "/docs/concepts/tools", + "#toolkits": "/docs/concepts/toosl/#toolkits", + "#initialize-a-toolkit": "/docs/concepts/toosl/#toolkits", + "#get-list-of-tools": "/docs/concepts/toosl/#toolkits", + "#agents": "/docs/concepts/agents", + "#react-agents": "/docs/concepts/agents", + "#callbacks": "/docs/concepts/callbacks", + "#callback-events": "/docs/concepts/callbacks/#callback-events", + "#callback-handlers": "/docs/concepts/callbacks/#callback-handlers", + "#passing-callbacks": "/docs/concepts/callbacks/#passing-callbacks", + "#techniques": "/docs/concepts/", + "#streaming": "/docs/concepts/streaming", + "#stream-and-astream": "/docs/concepts/streaming#stream-and-astream", + "#astreamevents": "/docs/concepts/astream_events", + "#callbacks": "/docs/concepts/callbacks", + "#tokens": "/docs/concepts/tokens", + "#functiontool-calling": "/docs/concepts/tool_calling", + "#tool-usage": "/docs/concepts/tool_calling", + "#structured-output": "/docs/concepts/structured_outputs", + "#withstructuredoutput": "/docs/concepts/structured_outputs", + "#raw-prompting": "/docs/concepts/structured_outputs", + "#json-mode": "/docs/concepts/structured_outputs/#json-mode", + "#tool-calling-structuredoutputtoolcalling": "/docs/concepts/structured_outputs", + "#fewshot-prompting": "/docs/concepts/few_shot_prompting", + "#1-generating-examples": "/docs/concepts/few_shot_prompting/#1-generating-examples", + "#2-number-of-examples": "/docs/concepts/few_shot_prompting/#2-number-of-examples", + "#3-selecting-examples": "/docs/concepts/few_shot_prompting/#3-selecting-examples", + "#4-formatting-examples": "/docs/concepts/few_shot_prompting/#4-formatting-examples", + "#retrieval": "/docs/concepts/retrieval", + "#query-translation": "/docs/concepts/retrieval/#query-re-writing", + "#routing": "/docs/concepts/", + "#query-construction": "/docs/concepts/retrieval/#query-construction", + "#indexing": "/docs/concepts/retrieval/", + "#postprocessing": "/docs/concepts/retrieval/", + "#generation": "/docs/concepts/rag", + "#text-splitting": "/docs/concepts/text_splitting", + "#evaluation": "/docs/concepts/evaluation", + "#tracing": "/docs/concepts/tracing", + }; + const hash = window?.location?.hash; + if (hash) { + if (lookup[hash]) { + return ; + } + } + return null; +}; + +export default RedirectAnchors; \ No newline at end of file