Skip to content

Commit fc4ad2d

Browse files
hwchase17scadEfUr
andauthored
langchain hub docs (#704)
Co-authored-by: scadEfUr <[email protected]>
1 parent 34932dd commit fc4ad2d

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

docs/index.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ Additional Resources
137137

138138
Additional collection of resources we think may be useful as you develop your application!
139139

140+
- `LangChainHub <https://github.com/hwchase17/langchain-hub>`_: The LangChainHub is a place to share and explore other prompts, chains, and agents.
141+
140142
- `Glossary <./glossary.html>`_: A glossary of all related terms, papers, methods, etc. Whether implemented in LangChain or not!
141143

142144
- `Gallery <./gallery.html>`_: A collection of our favorite projects that use LangChain. Useful for finding inspiration or seeing how things were done in other applications.
@@ -152,6 +154,7 @@ Additional collection of resources we think may be useful as you develop your ap
152154
:name: resources
153155
:hidden:
154156

157+
LangChainHub <https://github.com/hwchase17/langchain-hub>
155158
./glossary.md
156159
./gallery.rst
157160
./deployments.md

docs/modules/prompts/getting_started.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,20 @@ Currently, the template should be formatted as a Python f-string. We also suppor
8080
:::
8181

8282

83+
## Load a prompt template from LangChainHub
84+
85+
LangChainHub contains a collection of prompts which can be loaded directly via LangChain.
86+
87+
88+
```python
89+
from langchain.prompts import load_prompt
90+
91+
prompt = load_prompt("lc://prompts/conversation/prompt.json")
92+
prompt.format(history="", input="What is 1 + 1?")
93+
```
94+
95+
You can read more about LangChainHub and the prompts available with it [here](https://github.com/hwchase17/langchain-hub).
96+
8397
## Pass few shot examples to a prompt template
8498

8599
Few shot examples are a set of examples that can be used to help the language model generate a better response.

langchain/prompts/loading.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Load prompts from disk."""
22
import importlib
33
import json
4+
import os
45
import tempfile
56
from pathlib import Path
67
from typing import Union
@@ -98,7 +99,7 @@ def _load_prompt(config: dict) -> PromptTemplate:
9899
def load_prompt(path: Union[str, Path]) -> BasePromptTemplate:
99100
"""Unified method for loading a prompt from LangChainHub or local fs."""
100101
if isinstance(path, str) and path.startswith("lc://prompts"):
101-
path = path.lstrip("lc://prompts/")
102+
path = os.path.relpath("lc://prompts/conversation/prompt.json", "lc://prompts/")
102103
return _load_from_hub(path)
103104
else:
104105
return _load_prompt_from_file(path)

0 commit comments

Comments
 (0)