-
Notifications
You must be signed in to change notification settings - Fork 50
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
Add Function to Preprocess Request Prompt & Address String Escape Symbol Issue #279
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
davidgxue
requested review from
Lee-W,
pankajastro and
sunank200
as code owners
January 24, 2024 03:08
davidgxue
changed the title
Add request preprecessor function
Add Function to Preprocess Request Prompt & Address String Escape Symbol Issue
Jan 24, 2024
Lee-W
reviewed
Jan 25, 2024
sunank200
reviewed
Jan 25, 2024
Co-authored-by: Wei Lee <weilee.rx@gmail.com>
Deploying with Cloudflare Pages
|
Addressed your comment about custom error type in the new commit. I changed up the error propagation logic a little bit as well to make it cleaner. Thanks for the help reviewing @Lee-W @sunank200 |
Lee-W
reviewed
Jan 29, 2024
…mer/ask-astro into add_request_preprocessor
sunank200
approved these changes
Jan 29, 2024
Lee-W
approved these changes
Jan 29, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
.build()
instead of.do()
. Usingbuild()
would have prevented symbols such as\
in the original string to be properly transformed into GraphQL syntax compatible string. However, LangChain implemented this part of the code using.do()
which causes issues with certain symbols that conflict with the GraphQL syntax. See here https://github.com/langchain-ai/langchain/blob/master/libs/community/langchain_community/retrievers/weaviate_hybrid_search.py#L152 on line 152.\
. We can achieve this by parsing any single standalone\
used to do string escape out of the original query. This shouldn't affect the original meaning of the prompt as the\
gets auto added downstream anyway when querying the LLMs with string escape needed so that is not a concern.Technical Changes
_preprocess_request
function that does input validation and transformation on the user prompt to workaround this issue in LangChain.Tests
When question exceeds character limit
When thread has more 6 questions/answers pairs, checked langsmith and saw only most recent 5 pairs
Questions with more than 1
\
is kept the same and questions with a single\
the\
is removed.For example, the original github issue's error causing query is now being successfully executed.
Enter prompt:
KeyError: \'gcp\'
(note in Langsmith logs the prompt it auto adds another backslack to existing backslashs`)closes #278