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

Add Function to Preprocess Request Prompt & Address String Escape Symbol Issue #279

Merged
merged 6 commits into from
Jan 30, 2024

Conversation

davidgxue
Copy link
Contributor

@davidgxue davidgxue commented Jan 24, 2024

Description

Technical Changes

  • Add a _preprocess_request function that does input validation and transformation on the user prompt to workaround this issue in LangChain.

Tests

  1. When question exceeds character limit
    image

  2. When thread has more 6 questions/answers pairs, checked langsmith and saw only most recent 5 pairs

  3. 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`)

image

closes #278

@davidgxue davidgxue marked this pull request as draft January 24, 2024 03:08
@davidgxue davidgxue self-assigned this Jan 24, 2024
@davidgxue davidgxue changed the title Add request preprecessor function Add Function to Preprocess Request Prompt & Address String Escape Symbol Issue Jan 24, 2024
@davidgxue davidgxue marked this pull request as ready for review January 24, 2024 07:45
api/ask_astro/services/questions.py Outdated Show resolved Hide resolved
api/ask_astro/services/questions.py Outdated Show resolved Hide resolved
Co-authored-by: Wei Lee <weilee.rx@gmail.com>
Copy link

cloudflare-workers-and-pages bot commented Jan 25, 2024

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: b166010
Status: ✅  Deploy successful!
Preview URL: https://7484616d.ask-astro.pages.dev
Branch Preview URL: https://add-request-preprocessor.ask-astro.pages.dev

View logs

@davidgxue
Copy link
Contributor Author

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

@davidgxue davidgxue requested review from Lee-W and sunank200 January 25, 2024 23:51
@davidgxue davidgxue requested a review from Lee-W January 29, 2024 05:09
@davidgxue davidgxue merged commit e5f7fa2 into main Jan 30, 2024
8 checks passed
@davidgxue davidgxue deleted the add_request_preprocessor branch January 30, 2024 01:33
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.

GraphQL Syntax Error Due to String Escape Character in LangSmith Log History
3 participants