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

nbdoc -> quarto #14156

Merged
merged 14 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/.local_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ mkdir -p ../_dist
rsync -ruv . ../_dist
cd ../_dist
poetry run python scripts/model_feat_table.py
poetry run nbdoc_build --srcdir docs --pause 0
quarto render docs/
cp ../cookbook/README.md src/pages/cookbook.mdx
cp ../.github/CONTRIBUTING.md docs/contributing.md
mkdir -p docs/templates
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/guides/debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Platforms with tracing capabilities like [LangSmith](/docs/langsmith/) and [Wand

For anyone building production-grade LLM applications, we highly recommend using a platform like this.

![LangSmith run](/img/run_details.png)
![LangSmith run](../../static/img/run_details.png)

## `set_debug` and `set_verbose`

Expand Down
6 changes: 3 additions & 3 deletions docs/docs/guides/local_llms.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"1. `Base model`: What is the base-model and how was it trained?\n",
"2. `Fine-tuning approach`: Was the base-model fine-tuned and, if so, what [set of instructions](https://cameronrwolfe.substack.com/p/beyond-llama-the-power-of-open-llms#%C2%A7alpaca-an-instruction-following-llama-model) was used?\n",
"\n",
"![Image description](/img/OSS_LLM_overview.png)\n",
"![Image description](../../static/img/OSS_LLM_overview.png)\n",
"\n",
"The relative performance of these models can be assessed using several leaderboards, including:\n",
"\n",
Expand All @@ -55,15 +55,15 @@
"\n",
"In particular, see [this excellent post](https://finbarr.ca/how-is-llama-cpp-possible/) on the importance of quantization.\n",
"\n",
"![Image description](/img/llama-memory-weights.png)\n",
"![Image description](../../static/img/llama-memory-weights.png)\n",
"\n",
"With less precision, we radically decrease the memory needed to store the LLM in memory.\n",
"\n",
"In addition, we can see the importance of GPU memory bandwidth [sheet](https://docs.google.com/spreadsheets/d/1OehfHHNSn66BP2h3Bxp2NJTVX97icU0GmCXF6pK23H8/edit#gid=0)!\n",
"\n",
"A Mac M2 Max is 5-6x faster than a M1 for inference due to the larger GPU memory bandwidth.\n",
"\n",
"![Image description](/img/llama_t_put.png)\n",
"![Image description](../../static/img/llama_t_put.png)\n",
"\n",
"## Quickstart\n",
"\n",
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/modules/chains/document/map_reduce.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"\n",
"The map reduce documents chain first applies an LLM chain to each document individually (the Map step), treating the chain output as a new document. It then passes all the new documents to a separate combine documents chain to get a single output (the Reduce step). It can optionally first compress, or collapse, the mapped documents to make sure that they fit in the combine documents chain (which will often pass them to an LLM). This compression step is performed recursively if necessary.\n",
"\n",
"![map_reduce_diagram](/img/map_reduce.jpg)"
"![map_reduce_diagram](../../../../static/img/map_reduce.jpg)"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/modules/chains/document/map_rerank.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"\n",
"The map re-rank documents chain runs an initial prompt on each document, that not only tries to complete a task but also gives a score for how certain it is in its answer. The highest scoring response is returned.\n",
"\n",
"![map_rerank_diagram](/img/map_rerank.jpg)"
"![map_rerank_diagram](../../../../static/img/map_rerank.jpg)"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/modules/chains/document/refine.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"The obvious tradeoff is that this chain will make far more LLM calls than, for example, the Stuff documents chain.\n",
"There are also certain tasks which are difficult to accomplish iteratively. For example, the Refine chain can perform poorly when documents frequently cross-reference one another or when a task requires detailed information from many documents.\n",
"\n",
"![refine_diagram](/img/refine.jpg)\n"
"![refine_diagram](../../../../static/img/refine.jpg)\n"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/modules/chains/document/stuff.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"\n",
"This chain is well-suited for applications where documents are small and only a few are passed in for most calls.\n",
"\n",
"![stuff_diagram](/img/stuff.jpg)"
"![stuff_diagram](../../../../static/img/stuff.jpg)"
]
},
{
Expand Down
8 changes: 4 additions & 4 deletions docs/docs/use_cases/apis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"* `Functions`: For example, [OpenAI functions](https://platform.openai.com/docs/guides/gpt/function-calling) is one popular means of doing this.\n",
"* `LLM-generated interface`: Use an LLM with access to API documentation to create an interface.\n",
"\n",
"![Image description](/img/api_use_case.png)"
"![Image description](../../static/img/api_use_case.png)"
]
},
{
Expand Down Expand Up @@ -188,7 +188,7 @@
" }\n",
" ```\n",
" \n",
"![Image description](/img/api_function_call.png)\n",
"![Image description](../../static/img/api_function_call.png)\n",
" \n",
"* This `Dict` above split and the [API is called here](https://github.com/langchain-ai/langchain/blob/7fc07ba5df99b9fa8bef837b0fafa220bc5c932c/libs/langchain/langchain/chains/openai_functions/openapi.py#L215)."
]
Expand Down Expand Up @@ -293,12 +293,12 @@
"\n",
"* The `api_request_chain` produces the API url from our question and the API documentation:\n",
"\n",
"![Image description](/img/api_chain.png)\n",
"![Image description](../../static/img/api_chain.png)\n",
"\n",
"* [Here](https://github.com/langchain-ai/langchain/blob/bbd22b9b761389a5e40fc45b0570e1830aabb707/libs/langchain/langchain/chains/api/base.py#L82) we make the API request with the API url.\n",
"* The `api_answer_chain` takes the response from the API and provides us with a natural language response:\n",
"\n",
"![Image description](/img/api_chain_response.png)"
"![Image description](../../static/img/api_chain_response.png)"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/use_cases/chatbots.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"id": "56615b45",
"metadata": {},
"source": [
"![Image description](/img/chat_use_case.png)"
"![Image description](../../static/img/chat_use_case.png)"
]
},
{
Expand Down Expand Up @@ -546,7 +546,7 @@
"source": [
"We can see the chat history preserved in the prompt using the [LangSmith trace](https://smith.langchain.com/public/dce34c57-21ca-4283-9020-a8e0d78a59de/r).\n",
"\n",
"![Image description](/img/chat_use_case_2.png)"
"![Image description](../../static/img/chat_use_case_2.png)"
]
},
{
Expand Down
14 changes: 10 additions & 4 deletions docs/docs/use_cases/extraction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"id": "178dbc59",
"metadata": {},
"source": [
"![Image description](/img/extraction.png)"
"![Image description](../../static/img/extraction.png)"
]
},
{
Expand Down Expand Up @@ -139,7 +139,7 @@
"\n",
"The [LangSmith trace](https://smith.langchain.com/public/72bc3205-7743-4ca6-929a-966a9d4c2a77/r) shows that we call the function `information_extraction` on the input string, `inp`.\n",
"\n",
"![Image description](/img/extraction_trace_function.png)\n",
"![Image description](../../static/img/extraction_trace_function.png)\n",
"\n",
"This `information_extraction` function is defined [here](https://github.com/langchain-ai/langchain/blob/master/libs/langchain/langchain/chains/openai_functions/extraction.py) and returns a dict.\n",
"\n",
Expand Down Expand Up @@ -497,7 +497,7 @@
"source": [
"We can see from the [LangSmith trace](https://smith.langchain.com/public/8e3aa858-467e-46a5-aa49-5db65f0a2b9a/r) that we get the same output as above.\n",
"\n",
"![Image description](/img/extraction_trace_function_2.png)\n",
"![Image description](../../static/img/extraction_trace_function_2.png)\n",
"\n",
"We can see that we provide a two-shot prompt in order to instruct the LLM to output in our desired format.\n",
"\n",
Expand Down Expand Up @@ -577,7 +577,7 @@
"\n",
"We can look at the [LangSmith trace](https://smith.langchain.com/public/69f11d41-41be-4319-93b0-6d0eda66e969/r) to see exactly what is going on under the hood.\n",
"\n",
"![Image description](/img/extraction_trace_joke.png)\n",
"![Image description](../../static/img/extraction_trace_joke.png)\n",
"\n",
"### Going deeper\n",
"\n",
Expand All @@ -587,6 +587,12 @@
"* [JSONFormer](/docs/integrations/llms/jsonformer_experimental) offers another way for structured decoding of a subset of the JSON Schema.\n",
"* [Kor](https://eyurtsev.github.io/kor/) is another library for extraction where schema and examples can be provided to the LLM."
]
},
{
"cell_type": "markdown",
"id": "aab95ecf",
"metadata": {},
"source": []
}
],
"metadata": {
Expand Down
8 changes: 4 additions & 4 deletions docs/docs/use_cases/qa_structured/sql.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"2. `Query a SQL database` using chains for query creation and execution\n",
"3. `Interact with a SQL database` using agents for robust and flexible querying \n",
"\n",
"![sql_usecase.png](/img/sql_usecase.png)\n",
"![sql_usecase.png](../../../static/img/sql_usecase.png)\n",
"\n",
"## Quickstart\n",
"\n",
Expand Down Expand Up @@ -240,7 +240,7 @@
"* Followed by three example rows in a `SELECT` statement\n",
"\n",
"`create_sql_query_chain` adopts this the best practice (see more in this [blog](https://blog.langchain.dev/llms-and-sql/)). \n",
"![sql_usecase.png](/img/create_sql_query_chain.png)\n",
"![sql_usecase.png](../../../static/img/create_sql_query_chain.png)\n",
"\n",
"**Improvements**\n",
"\n",
Expand Down Expand Up @@ -397,7 +397,7 @@
"\n",
"* Then, it executes the query and passes the results to an LLM for synthesis.\n",
"\n",
"![sql_usecase.png](/img/sqldbchain_trace.png)\n",
"![sql_usecase.png](../../../static/img/sqldbchain_trace.png)\n",
"\n",
"**Improvements**\n",
"\n",
Expand Down Expand Up @@ -661,7 +661,7 @@
"\n",
"* It finally executes the generated query using tool `sql_db_query`\n",
"\n",
"![sql_usecase.png](/img/SQLDatabaseToolkit.png)"
"![sql_usecase.png](../../../static/img/SQLDatabaseToolkit.png)"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"- Using LLMs for suggesting refactors or improvements\n",
"- Using LLMs for documenting the code\n",
"\n",
"![Image description](/img/code_understanding.png)\n",
"![Image description](../../../static/img/code_understanding.png)\n",
"\n",
"## Overview\n",
"\n",
Expand Down Expand Up @@ -339,7 +339,7 @@
"* In particular, the code well structured and kept together in the retrieval output\n",
"* The retrieved code and chat history are passed to the LLM for answer distillation\n",
"\n",
"![Image description](/img/code_retrieval.png)"
"![Image description](../../../static/img/code_retrieval.png)"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/use_cases/question_answering/index.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@
"2. **Split**: [Text splitters](/docs/modules/data_connection/document_transformers/) break large `Documents` into smaller chunks. This is useful both for indexing data and for passing it in to a model, since large chunks are harder to search over and won't in a model's finite context window.\n",
"3. **Store**: We need somewhere to store and index our splits, so that they can later be searched over. This is often done using a [VectorStore](/docs/modules/data_connection/vectorstores/) and [Embeddings](/docs/modules/data_connection/text_embedding/) model.\n",
"\n",
"![index_diagram](/img/rag_indexing.png)\n",
"![index_diagram](../../../static/img/rag_indexing.png)\n",
"\n",
"#### Retrieval and generation\n",
"4. **Retrieve**: Given a user input, relevant splits are retrieved from storage using a [Retriever](/docs/modules/data_connection/retrievers/).\n",
"5. **Generate**: A [ChatModel](/docs/modules/model_io/chat_models) / [LLM](/docs/modules/model_io/llms/) produces an answer using a prompt that includes the question and the retrieved data\n",
"\n",
"![retrieval_diagram](/img/rag_retrieval_generation.png)"
"![retrieval_diagram](../../../static/img/rag_retrieval_generation.png)"
]
},
{
Expand Down
6 changes: 3 additions & 3 deletions docs/docs/use_cases/summarization.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"id": "8e233997",
"metadata": {},
"source": [
"![Image description](/img/summarization_use_case_1.png)"
"![Image description](../../static/img/summarization_use_case_1.png)"
]
},
{
Expand All @@ -56,7 +56,7 @@
"id": "08ec66bc",
"metadata": {},
"source": [
"![Image description](/img/summarization_use_case_2.png)"
"![Image description](../../static/img/summarization_use_case_2.png)"
]
},
{
Expand Down Expand Up @@ -514,7 +514,7 @@
"* The blog post and associated [repo](https://github.com/mendableai/QA_clustering) also introduce clustering as a means of summarization.\n",
"* This opens up a third path beyond the `stuff` or `map-reduce` approaches that is worth considering.\n",
"\n",
"![Image description](/img/summarization_use_case_3.png)"
"![Image description](../../static/img/summarization_use_case_3.png)"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/use_cases/tagging.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"- covered topics\n",
"- political tendency\n",
"\n",
"![Image description](/img/tagging.png)\n",
"![Image description](../../static/img/tagging.png)\n",
"\n",
"## Overview\n",
"\n",
Expand Down Expand Up @@ -293,7 +293,7 @@
"* As with [extraction](/docs/use_cases/extraction), we call the `information_extraction` function [here](https://github.com/langchain-ai/langchain/blob/269f85b7b7ffd74b38cd422d4164fc033388c3d0/libs/langchain/langchain/chains/openai_functions/extraction.py#L20) on the input string.\n",
"* This OpenAI function extraction information based upon the provided schema.\n",
"\n",
"![Image description](/img/tagging_trace.png)"
"![Image description](../../static/img/tagging_trace.png)"
]
},
{
Expand Down
6 changes: 3 additions & 3 deletions docs/docs/use_cases/web_scraping.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"* Users have [highlighted it](https://twitter.com/GregKamradt/status/1679913813297225729?s=20) as one of his top desired AI tools. \n",
"* OSS repos like [gpt-researcher](https://github.com/assafelovic/gpt-researcher) are growing in popularity. \n",
" \n",
"![Image description](/img/web_scraping.png)\n",
"![Image description](../../static/img/web_scraping.png)\n",
" \n",
"## Overview\n",
"\n",
Expand Down Expand Up @@ -443,7 +443,7 @@
"source": [
"We can compare the headlines scraped to the page:\n",
"\n",
"![Image description](/img/wsj_page.png)\n",
"![Image description](../../static/img/wsj_page.png)\n",
"\n",
"Looking at the [LangSmith trace](https://smith.langchain.com/public/c3070198-5b13-419b-87bf-3821cdf34fa6/r), we can see what is going on under the hood:\n",
"\n",
Expand All @@ -463,7 +463,7 @@
"\n",
"We can automate the process of [web research](https://blog.langchain.dev/automating-web-research/) using a retriever, such as the `WebResearchRetriever` ([docs](https://python.langchain.com/docs/modules/data_connection/retrievers/web_research)).\n",
"\n",
"![Image description](/img/web_research.png)\n",
"![Image description](../../static/img/web_research.png)\n",
"\n",
"Copy requirements [from here](https://github.com/langchain-ai/web-explorer/blob/main/requirements.txt):\n",
"\n",
Expand Down
62 changes: 15 additions & 47 deletions docs/vercel_build.sh
Copy link
Member Author

Choose a reason for hiding this comment

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

@hinthornw would love your eyes on this. Everything seems to work, but cuts a lot of the deps

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ya seems fine. The 3.11 stuff was only to generate the API refs, which we seem to not be doing anymore anyhow

Original file line number Diff line number Diff line change
@@ -1,57 +1,25 @@
#!/bin/bash

version_compare() {
local v1=(${1//./ })
local v2=(${2//./ })
for i in {0..2}; do
if (( ${v1[i]} < ${v2[i]} )); then
return 1
fi
done
return 0
}
yum -y update
yum install gcc bzip2-devel libffi-devel zlib-devel wget tar gzip -y
amazon-linux-extras install python3.8 -y
Copy link
Member Author

Choose a reason for hiding this comment

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

python3.8 is available in amazon linux, and is much faster to install

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice. ya was only required previously for some other functionality, now not used. Is python 3.8 installation even required at this point


openssl_version=$(openssl version | awk '{print $2}')
required_openssl_version="1.1.1"
# install quarto
wget -q https://github.com/quarto-dev/quarto-cli/releases/download/v1.3.450/quarto-1.3.450-linux-amd64.tar.gz
tar -xzf quarto-1.3.450-linux-amd64.tar.gz
export PATH=$PATH:$(pwd)/quarto-1.3.450/bin/

python_version=$(python3 --version 2>&1 | awk '{print $2}')
required_python_version="3.10"

echo "OpenSSL Version"
echo $openssl_version
echo "Python Version"
echo $python_version
# If openssl version is less than 1.1.1 AND python version is less than 3.10
if ! version_compare $openssl_version $required_openssl_version && ! version_compare $python_version $required_python_version; then
### See: https://github.com/urllib3/urllib3/issues/2168
# Requests lib breaks for old SSL versions,
# which are defaults on Amazon Linux 2 (which Vercel uses for builds)
yum -y update
yum remove openssl-devel -y
yum install gcc bzip2-devel libffi-devel zlib-devel wget tar -y
yum install openssl11 -y
yum install openssl11-devel -y

wget https://www.python.org/ftp/python/3.11.4/Python-3.11.4.tgz
tar xzf Python-3.11.4.tgz
cd Python-3.11.4
./configure
make altinstall
echo "Python Version"
python3.11 --version
cd ..
fi
Comment on lines -25 to -43
Copy link
Member Author

Choose a reason for hiding this comment

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

openssl only took a second to install, but the custom python install took more than 3 minutes


python3.11 -m venv .venv
python3.8 -m venv .venv
source .venv/bin/activate
python3.11 -m pip install --upgrade pip
python3.11 -m pip install -r vercel_requirements.txt
python3.11 scripts/model_feat_table.py
python3.8 -m pip install --upgrade pip
python3.8 -m pip install -r vercel_requirements.txt
python3.8 scripts/model_feat_table.py
mkdir docs/templates
cp ../templates/docs/INDEX.md docs/templates/index.md
python3.11 scripts/copy_templates.py
python3.8 scripts/copy_templates.py
cp ../cookbook/README.md src/pages/cookbook.mdx
cp ../.github/CONTRIBUTING.md docs/contributing.md
wget https://raw.githubusercontent.com/langchain-ai/langserve/main/README.md -O docs/langserve.md
nbdoc_build --srcdir docs --pause 0
python3.11 scripts/generate_api_reference_links.py
wget -q https://raw.githubusercontent.com/langchain-ai/langserve/main/README.md -O docs/langserve.md
quarto render docs/
python3.8 scripts/generate_api_reference_links.py
Loading