Issue: LCEL output parser error
Labels: name: auto:bug, name: area: lcel

### Issue you'd like to raise.

Hello everyone I'm trying to use the langchain LCEL for the autogen script assembly pipeline. The first point that I'm trying to implement is for AI to determine which roles are needed in the autogen group chat to solve the user's task. I'm trying to parse the neural network's response to get a list of these roles and their number, I need this for the further operation of the pipeline, but the whole chain just refuses to work normally (model: mixtral-8x7b). Here is the code that I wrote based on the langchain documentation about [output parsers](https://python.langchain.com/docs/modules/model_io/output_parsers/quick_start):
```
from langchain.output_parsers import PydanticOutputParser
from langchain.prompts import PromptTemplate
from langchain_community.llms import OpenAI
from langchain_core.pydantic_v1 import BaseModel, Field, validator
from typing import List

model = llm

# Define your desired data structure.
class Task(BaseModel):
    task_description: str = Field(description="Description of the task")
    role_list: List[str] = Field(description="List of roles that can solve the task")
    number_of_roles: int = Field(description="Number of roles that can solve the task")

    # You can add custom validation logic easily with Pydantic.
    @validator("task_description")
    def validate_task_description(cls, field):
        if not field:
            raise ValueError("Task description cannot be empty!")
        return field

    @validator("role_list")
    def validate_role_list(cls, field):
        if not field:
            raise ValueError("Role list cannot be empty!")
        return field

    @validator("number_of_roles")
    def validate_number_of_roles(cls, field):
        if field < 0:
            raise ValueError("Number of roles cannot be negative!")
        return field


# Set up a parser + inject instructions into the prompt template.
parser = PydanticOutputParser(pydantic_object=Task)

prompt = PromptTemplate(
    template="Enter your task description:\n{format_instructions}\n{task_description}\n",
    input_variables=["task_description"],
    partial_variables={"format_instructions": parser.get_format_instructions()},
)

# And a query intended to prompt a language model to populate the data structure.
prompt_and_model = prompt | model
output = prompt_and_model.invoke({"task_description": "Write code for game on python."})
parser.invoke(output)
```
that's what it does, except for a huge number of errors:
```
Task(task_description='The task is to simulate a simple multiplayer game. Players take turns to play. In each turn, a player can do only one of two things: * Add a number to a running total, or * Divide the running total by two, rounding down to the nearest integer. The game ends when the running total reaches a pre-specified target value. ', role_list=['admin', 'player'], number_of_roles=2)
```
here is one of the errors:
```
---------------------------------------------------------------------------
JSONDecodeError                           Traceback (most recent call last)
File ~\AppData\Roaming\Python\Python311\site-packages\langchain\output_parsers\pydantic.py:29, in PydanticOutputParser.parse(self, text)
     28     json_str = match.group()
---> 29 json_object = json.loads(json_str, strict=False)
     30 return self.pydantic_object.parse_obj(json_object)

File C:\Program Files\Python311\Lib\json\__init__.py:359, in loads(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
    358     kw['parse_constant'] = parse_constant
--> 359 return cls(**kw).decode(s)

File C:\Program Files\Python311\Lib\json\decoder.py:337, in JSONDecoder.decode(self, s, _w)
    333 """Return the Python representation of ``s`` (a ``str`` instance
    334 containing a JSON document).
    335 
    336 """
--> 337 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
    338 end = _w(s, end).end()

File C:\Program Files\Python311\Lib\json\decoder.py:353, in JSONDecoder.raw_decode(self, s, idx)
    352 try:
--> 353     obj, end = self.scan_once(s, idx)
    354 except StopIteration as err:

JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)

During handling of the above exception, another exception occurred:

OutputParserException                     Traceback (most recent call last)
Cell In[76], line 47
     45 prompt_and_model = prompt | model
     46 output = prompt_and_model.invoke({"task_description": "Write code for game on python."})
---> 47 parser.invoke(output)

File ~\AppData\Roaming\Python\Python311\site-packages\langchain_core\output_parsers\base.py:179, in BaseOutputParser.invoke(self, input, config)
    170     return self._call_with_config(
    171         lambda inner_input: self.parse_result(
    172             [ChatGeneration(message=inner_input)]
   (...)
    176         run_type="parser",
    177     )
    178 else:
--> 179     return self._call_with_config(
    180         lambda inner_input: self.parse_result([Generation(text=inner_input)]),
    181         input,
    182         config,
    183         run_type="parser",
    184     )

File ~\AppData\Roaming\Python\Python311\site-packages\langchain_core\runnables\base.py:886, in Runnable._call_with_config(self, func, input, config, run_type, **kwargs)
    879 run_manager = callback_manager.on_chain_start(
    880     dumpd(self),
    881     input,
    882     run_type=run_type,
    883     name=config.get("run_name"),
    884 )
    885 try:
--> 886     output = call_func_with_variable_args(
    887         func, input, config, run_manager, **kwargs
    888     )
    889 except BaseException as e:
    890     run_manager.on_chain_error(e)

File ~\AppData\Roaming\Python\Python311\site-packages\langchain_core\runnables\config.py:308, in call_func_with_variable_args(func, input, config, run_manager, **kwargs)
    306 if run_manager is not None and accepts_run_manager(func):
    307     kwargs["run_manager"] = run_manager
--> 308 return func(input, **kwargs)

File ~\AppData\Roaming\Python\Python311\site-packages\langchain_core\output_parsers\base.py:180, in BaseOutputParser.invoke.<locals>.<lambda>(inner_input)
    170     return self._call_with_config(
    171         lambda inner_input: self.parse_result(
    172             [ChatGeneration(message=inner_input)]
   (...)
    176         run_type="parser",
    177     )
    178 else:
    179     return self._call_with_config(
--> 180         lambda inner_input: self.parse_result([Generation(text=inner_input)]),
    181         input,
    182         config,
    183         run_type="parser",
    184     )

File ~\AppData\Roaming\Python\Python311\site-packages\langchain_core\output_parsers\base.py:222, in BaseOutputParser.parse_result(self, result, partial)
    209 def parse_result(self, result: List[Generation], *, partial: bool = False) -> T:
    210     """Parse a list of candidate model Generations into a specific format.
    211 
    212     The return value is parsed from only the first Generation in the result, which
   (...)
    220         Structured output.
    221     """
--> 222     return self.parse(result[0].text)

File ~\AppData\Roaming\Python\Python311\site-packages\langchain\output_parsers\pydantic.py:35, in PydanticOutputParser.parse(self, text)
     33 name = self.pydantic_object.__name__
     34 msg = f"Failed to parse {name} from completion {text}. Got: {e}"
---> 35 raise OutputParserException(msg, llm_output=text)

OutputParserException: Failed to parse Task from completion 
Create a class `Game` that has the following attributes:
* `task_description`: a string attribute that describes the task that the game is about
* `role_list`: a list of strings that contains the names of the roles that can solve the task
* `number_of_roles`: an integer attribute that contains the number of roles that can solve the task

The `Game` class should have the following methods:
* `__init__`: the constructor should take three parameters: `task_description`, `role_list`, and `number_of_roles` and initialize the corresponding attributes.
* `get_task_description`: a method that returns the value of the `task_description` attribute
* `get_role_list`: a method that returns the value of the `role_list` attribute
* `get_number_of_roles`: a method that returns the value of the `number_of_roles` attribute
* `get_roles`: a method that returns a list of dictionaries, where each dictionary contains the name of the role and a boolean value that indicates if the role can solve the task. The list should contain `number_of_roles` dictionaries.

Here's an example of how to use the `Game` class:
'''
game = Game("Save the princess from the dragon", ["knight", "prince", "wizard"], 2)
print(game.get_task_description())
print(game.get_role_list())
print(game.get_number_of_roles())
roles = game.get_roles()
for role in roles:
    print(role)
'''
Output:
'''
Save the princess from the dragon
['knight', 'prince', 'wizard']
2
{'name': 'knight', 'can_solve': True}
{'name': 'prince', 'can_solve': True}
{'name': 'wizard', 'can_solve': False}
'''
Write the `Game` class and format the output as a JSON instance that conforms to the schema provided above.
'''json
{
    "task_description": "Save the princess from the. Got: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)
```

### Suggestion:

_No response_