OutputParserException in extraction use case
Labels: name: auto:bug, name: area: models

### System Info

Hi, i'm obtaining this error trace when performing a basic `create_extraction_chain` example.I'm using CTransformers (llama2 type), more specifically, this model here: https://huggingface.co/clibrain/Llama-2-13b-ft-instruct-es-gguf

Python version: 3.11
Environment:
```
accelerate                0.24.1
aiofiles                  22.1.0
aiohttp                   3.9.0
aiosignal                 1.3.1
aiosqlite                 0.19.0
alembic                   1.9.4
anyio                     3.7.1
appnope                   0.1.3
argilla                   1.19.0
argon2-cffi               23.1.0
argon2-cffi-bindings      21.2.0
arrow                     1.3.0
asttokens                 2.4.1
async-lru                 2.0.4
attrs                     23.1.0
Babel                     2.13.1
backoff                   1.11.1
bcrypt                    4.0.1
beautifulsoup4            4.12.2
bleach                    6.1.0
Brotli                    1.1.0
brotli-asgi               1.2.0
certifi                   2023.11.17
cffi                      1.16.0
charset-normalizer        3.3.2
click                     8.1.7
coloredlogs               15.0.1
comm                      0.2.0
commonmark                0.9.1
cryptography              41.0.5
ctransformers             0.2.27
dataclasses-json          0.6.3
datasets                  2.15.0
debugpy                   1.8.0
decorator                 5.1.1
defusedxml                0.7.1
Deprecated                1.2.14
dill                      0.3.7
diskcache                 5.6.3
ecdsa                     0.18.0
elastic-transport         8.10.0
elasticsearch8            8.7.0
executing                 2.0.1
fastapi                   0.104.1
fastjsonschema            2.19.0
filelock                  3.13.1
fqdn                      1.5.1
frozenlist                1.4.0
fsspec                    2023.10.0
greenlet                  3.0.1
h11                       0.14.0
httpcore                  0.16.3
httptools                 0.6.1
httpx                     0.23.3
huggingface-hub           0.19.4
humanfriendly             10.0
idna                      3.4
ipykernel                 6.27.0
ipython                   8.17.2
isoduration               20.11.0
jedi                      0.19.1
Jinja2                    3.1.2
joblib                    1.3.2
json5                     0.9.14
jsonpatch                 1.33
jsonpointer               2.4
jsonschema                4.20.0
jsonschema-specifications 2023.11.1
jupyter_client            8.6.0
jupyter_core              5.5.0
jupyter-events            0.9.0
jupyter-lsp               2.2.0
jupyter_server            2.11.0
jupyter_server_terminals  0.4.4
jupyterlab                4.0.9
jupyterlab-pygments       0.2.2
jupyterlab_server         2.25.2
langchain                 0.0.341
langchain-core            0.0.6
langsmith                 0.0.67
llama_cpp_python          0.2.20
Mako                      1.3.0
markdown-it-py            3.0.0
MarkupSafe                2.1.3
marshmallow               3.20.1
matplotlib-inline         0.1.6
mdurl                     0.1.2
mistune                   3.0.2
monotonic                 1.6
mpmath                    1.3.0
multidict                 6.0.4
multiprocess              0.70.15
mypy-extensions           1.0.0
nbclient                  0.9.0
nbconvert                 7.11.0
nbformat                  5.9.2
nest-asyncio              1.5.8
networkx                  3.2.1
nltk                      3.8.1
notebook_shim             0.2.3
numpy                     1.23.5
opensearch-py             2.0.1
optimum                   1.14.1
overrides                 7.4.0
packaging                 23.2
pandas                    1.5.3
pandocfilters             1.5.0
parso                     0.8.3
passlib                   1.7.4
pexpect                   4.8.0
Pillow                    10.1.0
pip                       23.3.1
platformdirs              4.0.0
prometheus-client         0.19.0
prompt-toolkit            3.0.41
protobuf                  4.25.1
psutil                    5.9.6
ptyprocess                0.7.0
pure-eval                 0.2.2
py-cpuinfo                9.0.0
pyarrow                   14.0.1
pyarrow-hotfix            0.6
pyasn1                    0.5.1
pycparser                 2.21
pydantic                  1.10.13
Pygments                  2.17.2
python-dateutil           2.8.2
python-dotenv             1.0.0
python-jose               3.3.0
python-json-logger        2.0.7
python-multipart          0.0.6
pytz                      2023.3.post1
PyYAML                    6.0.1
pyzmq                     25.1.1
referencing               0.31.0
regex                     2023.10.3
requests                  2.31.0
rfc3339-validator         0.1.4
rfc3986                   1.5.0
rfc3986-validator         0.1.1
rich                      13.0.1
rpds-py                   0.13.1
rsa                       4.9
safetensors               0.4.0
scikit-learn              1.3.2
scipy                     1.11.4
segment-analytics-python  2.2.0
Send2Trash                1.8.2
sentence-transformers     2.2.2
sentencepiece             0.1.99
setuptools                68.2.2
six                       1.16.0
smart-open                6.4.0
sniffio                   1.3.0
soupsieve                 2.5
SQLAlchemy                2.0.23
stack-data                0.6.3
starlette                 0.27.0
sympy                     1.12
tenacity                  8.2.3
terminado                 0.18.0
threadpoolctl             3.2.0
tinycss2                  1.2.1
tokenizers                0.15.0
torch                     2.1.1
torchvision               0.16.1
tornado                   6.3.3
tqdm                      4.66.1
traitlets                 5.13.0
transformers              4.35.2
typer                     0.9.0
types-python-dateutil     2.8.19.14
typing_extensions         4.8.0
typing-inspect            0.9.0
uri-template              1.3.0
urllib3                   1.26.18
uvicorn                   0.20.0
uvloop                    0.19.0
watchfiles                0.21.0
wcwidth                   0.2.12
webcolors                 1.13
webencodings              0.5.1
websocket-client          1.6.4
websockets                12.0
wrapt                     1.14.1
xxhash                    3.4.1
yarl                      1.9.3

```

### Who can help?

_No response_

### Information

- [ ] The official example notebooks/scripts
- [ ] My own modified scripts

### Related Components

- [ ] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [X] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

Hi, i'm obtaining this error trace when performing a basic `create_extraction_chain` example.I'm using CTransformers (llama2 type), more specifically, this model here: https://huggingface.co/clibrain/Llama-2-13b-ft-instruct-es-gguf

```
OutputParserException                     Traceback (most recent call last)
Cell In[9], line 17
     12 chain = create_extraction_chain(schema, llm)
     14 inp = """Alex is 5 feet tall. Claudia is 1 feet taller Alex and jumps higher than him. Claudia is a brunette and Alex is blonde.
     15 Willow is a German Shepherd that likes to play with other dogs and can always be found playing with Milo, a border collie that lives close by."""
---> 17 chain.run(inp)

File ~/Desktop/green-jobs/genv/lib/python3.11/site-packages/langchain/chains/base.py:507, in Chain.run(self, callbacks, tags, metadata, *args, **kwargs)
    505     if len(args) != 1:
    506         raise ValueError("`run` supports only one positional argument.")
--> 507     return self(args[0], callbacks=callbacks, tags=tags, metadata=metadata)[
    508         _output_key
    509     ]
    511 if kwargs and not args:
    512     return self(kwargs, callbacks=callbacks, tags=tags, metadata=metadata)[
    513         _output_key
    514     ]

File ~/Desktop/green-jobs/genv/lib/python3.11/site-packages/langchain/chains/base.py:312, in Chain.__call__(self, inputs, return_only_outputs, callbacks, tags, metadata, run_name, include_run_info)
    310 except BaseException as e:
    311     run_manager.on_chain_error(e)
--> 312     raise e
    313 run_manager.on_chain_end(outputs)
    314 final_outputs: Dict[str, Any] = self.prep_outputs(
    315     inputs, outputs, return_only_outputs
    316 )

File ~/Desktop/green-jobs/genv/lib/python3.11/site-packages/langchain/chains/base.py:306, in Chain.__call__(self, inputs, return_only_outputs, callbacks, tags, metadata, run_name, include_run_info)
    299 run_manager = callback_manager.on_chain_start(
    300     dumpd(self),
    301     inputs,
    302     name=run_name,
    303 )
    304 try:
    305     outputs = (
--> 306         self._call(inputs, run_manager=run_manager)
    307         if new_arg_supported
    308         else self._call(inputs)
    309     )
    310 except BaseException as e:
    311     run_manager.on_chain_error(e)

File ~/Desktop/green-jobs/genv/lib/python3.11/site-packages/langchain/chains/llm.py:104, in LLMChain._call(self, inputs, run_manager)
     98 def _call(
     99     self,
    100     inputs: Dict[str, Any],
    101     run_manager: Optional[CallbackManagerForChainRun] = None,
    102 ) -> Dict[str, str]:
    103     response = self.generate([inputs], run_manager=run_manager)
--> 104     return self.create_outputs(response)[0]

File ~/Desktop/green-jobs/genv/lib/python3.11/site-packages/langchain/chains/llm.py:258, in LLMChain.create_outputs(self, llm_result)
    256 def create_outputs(self, llm_result: LLMResult) -> List[Dict[str, Any]]:
    257     """Create outputs from response."""
--> 258     result = [
    259         # Get the text of the top generated string.
    260         {
    261             self.output_key: self.output_parser.parse_result(generation),
    262             "full_generation": generation,
    263         }
    264         for generation in llm_result.generations
    265     ]
    266     if self.return_final_only:
    267         result = [{self.output_key: r[self.output_key]} for r in result]

File ~/Desktop/green-jobs/genv/lib/python3.11/site-packages/langchain/chains/llm.py:261, in <listcomp>(.0)
    256 def create_outputs(self, llm_result: LLMResult) -> List[Dict[str, Any]]:
    257     """Create outputs from response."""
    258     result = [
    259         # Get the text of the top generated string.
    260         {
--> 261             self.output_key: self.output_parser.parse_result(generation),
    262             "full_generation": generation,
    263         }
    264         for generation in llm_result.generations
    265     ]
    266     if self.return_final_only:
    267         result = [{self.output_key: r[self.output_key]} for r in result]

File ~/Desktop/green-jobs/genv/lib/python3.11/site-packages/langchain/output_parsers/openai_functions.py:130, in JsonKeyOutputFunctionsParser.parse_result(self, result, partial)
    129 def parse_result(self, result: List[Generation], *, partial: bool = False) -> Any:
--> 130     res = super().parse_result(result, partial=partial)
    131     if partial and res is None:
    132         return None

File ~/Desktop/green-jobs/genv/lib/python3.11/site-packages/langchain/output_parsers/openai_functions.py:68, in JsonOutputFunctionsParser.parse_result(self, result, partial)
     66 generation = result[0]
     67 if not isinstance(generation, ChatGeneration):
---> 68     raise OutputParserException(
     69         "This output parser can only be used with a chat generation."
     70     )
     71 message = generation.message
     72 try:

OutputParserException: This output parser can only be used with a chat generation.
```

Im using the following example:
```
schema = {
    "properties": {
        "person_name": {"type": "string"},
        "person_height": {"type": "integer"},
        "person_hair_color": {"type": "string"},
        "dog_name": {"type": "string"},
        "dog_breed": {"type": "string"},
    },
    "required": [],
}

chain = create_extraction_chain(schema, llm)

inp = """Alex is 5 feet tall. Claudia is 1 feet taller Alex and jumps higher than him. Claudia is a brunette and Alex is blonde.
Willow is a German Shepherd that likes to play with other dogs and can always be found playing with Milo, a border collie that lives close by."""

chain.run(inp)
```

### Expected behavior

I expect not to get an error when executing the code