Skip to content

Commit 9721684

Browse files
authored
Merge branch 'master' into wip-v1.0
2 parents a4e135b + fe740a9 commit 9721684

File tree

15 files changed

+526
-85
lines changed

15 files changed

+526
-85
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,4 @@ concepts behind the LangChain framework.
8383
- [LangChain Forum](https://forum.langchain.com/): Connect with the community and share all of your technical questions, ideas, and feedback.
8484
- [API Reference](https://python.langchain.com/api_reference/): Detailed reference on
8585
navigating base packages and integrations for LangChain.
86+
- [Chat LangChain](https://chat.langchain.com/): Ask questions & chat with our documentation

docs/docs/contributing/how_to/code/setup.mdx

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,49 @@ If codespell is incorrectly flagging a word, you can skip spellcheck for that wo
223223
ignore-words-list = 'momento,collison,ned,foor,reworkd,parth,whats,aapply,mysogyny,unsecure'
224224
```
225225

226+
### Pre-commit
227+
228+
We use [pre-commit](https://pre-commit.com/) to ensure commits are formatted/linted.
229+
230+
#### Installing Pre-commit
231+
232+
First, install pre-commit:
233+
234+
```bash
235+
# Option 1: Using uv (recommended)
236+
uv tool install pre-commit
237+
238+
# Option 2: Using Homebrew (globally for macOS/Linux)
239+
brew install pre-commit
240+
241+
# Option 3: Using pip
242+
pip install pre-commit
243+
```
244+
245+
Then install the git hook scripts:
246+
247+
```bash
248+
pre-commit install
249+
```
250+
251+
#### How Pre-commit Works
252+
253+
Once installed, pre-commit will automatically run on every `git commit`. Hooks are specified in `.pre-commit-config.yaml` and will:
254+
255+
- Format code using `ruff` for the specific library/package you're modifying
256+
- Only run on files that have changed
257+
- Prevent commits if formatting fails
258+
259+
#### Skipping Pre-commit
260+
261+
In exceptional cases, you can skip pre-commit hooks with:
262+
263+
```bash
264+
git commit --no-verify
265+
```
266+
267+
However, this is discouraged as the CI system will still enforce the same formatting rules.
268+
226269
## Working with optional dependencies
227270

228271
`langchain`, `langchain-community`, and `langchain-experimental` rely on optional dependencies to keep these packages lightweight.

docs/docs/how_to/trim_messages.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"\n",
5454
"To keep the most recent messages, we set `strategy=\"last\"`. We'll also set `include_system=True` to include the `SystemMessage`, and `start_on=\"human\"` to make sure the resulting chat history is valid. \n",
5555
"\n",
56-
"This is a good default configuration when using `trim_messages` based on token count. Remember to adjust `token_counter` and `max_tokens` for your use case.\n",
56+
"This is a good default configuration when using `trim_messages` based on token count. Remember to adjust `token_counter` and `max_tokens` for your use case. Keep in mind that new queries added to the chat history will be included in the token count unless you trim prior to adding the new query.\n",
5757
"\n",
5858
"Notice that for our `token_counter` we can pass in a function (more on that below) or a language model (since language models have a message token counting method). It makes sense to pass in a model when you're trimming your messages to fit into the context window of that specific model:"
5959
]
@@ -525,7 +525,7 @@
525525
"id": "4d91d390-e7f7-467b-ad87-d100411d7a21",
526526
"metadata": {},
527527
"source": [
528-
"Looking at the LangSmith trace we can see that before the messages are passed to the model they are first trimmed: https://smith.langchain.com/public/65af12c4-c24d-4824-90f0-6547566e59bb/r\n",
528+
"Looking at [the LangSmith trace](https://smith.langchain.com/public/65af12c4-c24d-4824-90f0-6547566e59bb/r) we can see that before the messages are passed to the model they are first trimmed.\n",
529529
"\n",
530530
"Looking at just the trimmer, we can see that it's a Runnable object that can be invoked like all Runnables:"
531531
]
@@ -620,7 +620,7 @@
620620
"id": "556b7b4c-43cb-41de-94fc-1a41f4ec4d2e",
621621
"metadata": {},
622622
"source": [
623-
"Looking at the LangSmith trace we can see that we retrieve all of our messages but before the messages are passed to the model they are trimmed to be just the system message and last human message: https://smith.langchain.com/public/17dd700b-9994-44ca-930c-116e00997315/r"
623+
"Looking at [the LangSmith trace](https://smith.langchain.com/public/17dd700b-9994-44ca-930c-116e00997315/r) we can see that we retrieve all of our messages but before the messages are passed to the model they are trimmed to be just the system message and last human message."
624624
]
625625
},
626626
{
@@ -630,7 +630,7 @@
630630
"source": [
631631
"## API reference\n",
632632
"\n",
633-
"For a complete description of all arguments head to the API reference: https://python.langchain.com/api_reference/core/messages/langchain_core.messages.utils.trim_messages.html"
633+
"For a complete description of all arguments head to the [API reference](https://python.langchain.com/api_reference/core/messages/langchain_core.messages.utils.trim_messages.html)."
634634
]
635635
}
636636
],

0 commit comments

Comments
 (0)