Skip to content

Json parser not working correctly #22103

Answered by dosubot bot
NexTimE11 asked this question in Q&A
May 24, 2024 · 2 comments · 19 replies
Discussion options

You must be logged in to vote

To make the check for the keys pricechange and year case-insensitive in the CustomRetryOutputParser, you can modify the parse_with_prompt method to convert the keys to lowercase before performing the check. Here is an example of how you can achieve this:

from enum import Enum
from langchain_core.output_parsers import JsonOutputParser
from langchain.output_parsers.retry import RetryOutputParser, OutputParserException
from langchain_core.prompts import PromptTemplate
from langchain_core.pydantic_v1 import BaseModel, Field
from langchain_community.llms import Ollama
from langchain_core.prompt_values import StringPromptValue

model = Ollama(base_url='http://155.198.89.235:11434', model="llama3"

Replies: 2 comments 19 replies

Comment options

You must be logged in to vote
18 replies
@NexTimE11
Comment options

@dosubot
Comment options

@NexTimE11
Comment options

@dosubot
Comment options

Answer selected by NexTimE11
Comment options

You must be logged in to vote
1 reply
@linnabrown
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants