Skip to content

Commit

Permalink
Merge pull request #973 from guardrails-ai/fix-lc-docs
Browse files Browse the repository at this point in the history
Fix Langchain Integration Docs
  • Loading branch information
CalebCourier authored Jul 29, 2024
2 parents fb6c157 + 0bdd99b commit 8bcf75a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion docs/integrations/langchain.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ Here's a basic example of how to integrate Guardrails with a LangChain LCEL chai
2. Create a Guard object with two validators: CompetitorCheck and ToxicLanguage.
```python
from guardrails import Guard
from guardrails.hub import CompetitorCheck, ToxicLanguage
competitors_list = ["delta", "american airlines", "united"]
guard = Guard().use_many(
CompetitorCheck(competitors=competitors_list, on_fail="fix"),
Expand All @@ -60,7 +63,7 @@ The `guard.to_runnable()` method converts the Guardrails guard into a LangChain-
prompt = ChatPromptTemplate.from_template("Answer this question {question}")
output_parser = StrOutputParser()
chain = prompt | model | output_parser | guard.to_runnable()
chain = prompt | model | guard.to_runnable() | output_parser
```
4. Invoke the chain
Expand Down

0 comments on commit 8bcf75a

Please sign in to comment.