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

feat(langchain): Add support for LangSmith and executing RunnableConfig for our Runnables #915

Merged
merged 5 commits into from
Jul 16, 2024

Conversation

kaushikb11
Copy link
Contributor

Overview

This PR introduces support for LangSmith and executing RunnableConfig for our Runnables, enhancing users' ability to trace, debug and monitor Guardrails and execute the Runnables with user defined configuration.

We have also introduced BaseRunnable to improve code reusability and maintain consistency across both Runnable implementations.

Guard Runnable

guard = Guard().use(CompetitorCheck(competitors=competitors_list, on_fail="fix"))
prompt = ChatPromptTemplate.from_template("Answer this question {question}")
output_parser = StrOutputParser()

chain = prompt | model | output_parser | guard.to_runnable()

result = chain.invoke({"question": "Tell me five Italian car companies?"})
Screenshot 2024-07-12 at 7 09 47 PM

Validator Runnable

regex_match = RegexMatch(
    "Ice cream", match_type="search", on_fail="refrain"
).to_runnable()
reading_time = ReadingTime(0.05, on_fail="refrain").to_runnable()
output_parser = StrOutputParser()

chain = prompt | model | regex_match | reading_time | output_parser
result = chain.invoke({"topic": topic})
Screenshot 2024-07-12 at 7 07 24 PM

@kaushikb11 kaushikb11 marked this pull request as draft July 12, 2024 14:26
@kaushikb11 kaushikb11 marked this pull request as ready for review July 15, 2024 00:00
@kaushikb11 kaushikb11 mentioned this pull request Jul 15, 2024
24 tasks
@CalebCourier CalebCourier changed the base branch from main to 0.5.0-dev July 15, 2024 15:12
@CalebCourier
Copy link
Collaborator

@kaushikb11 please address any checks that are failing. Thanks!

@kaushikb11
Copy link
Contributor Author

@CalebCourier Fixed the tests. Could you please run (approve) the workflow?

Copy link
Collaborator

@CalebCourier CalebCourier left a comment

Choose a reason for hiding this comment

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

Since this is from a fork, Codecov isn't being called with a token. Therefore the checks keep encountering rate limit issues. I verified locally that the tests are passing so I'm merging.

@CalebCourier CalebCourier merged commit 7cdf815 into guardrails-ai:0.5.0-dev Jul 16, 2024
8 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants