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

Output Parser Exception for Tagging UseCase #18906

Open
5 tasks done
yadavalok1 opened this issue Mar 11, 2024 · 5 comments
Open
5 tasks done

Output Parser Exception for Tagging UseCase #18906

yadavalok1 opened this issue Mar 11, 2024 · 5 comments
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature 🔌: openai Primarily related to OpenAI integrations Ɑ: parsing Related to output parser module

Comments

@yadavalok1
Copy link

yadavalok1 commented Mar 11, 2024

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangChain documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

Example Code

schema = {
"properties": {
"sentiment": {"type": "string"},
"aggressiveness": {"type": "integer"},
"language": {"type": "string"},
}
}

chain = create_tagging_chain(schema, model)

test_string = "Hey there!! We are going to celerate john's birthday. Suggest some celebration idea."

res = chain.invoke(test_string)

Error Message and Stack Trace (if applicable)

File "/python3.11/site-packages/langchain/chains/llm.py", line 104, in _call
return self.create_outputs(response)[0]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/python3.11/site-packages/langchain/chains/llm.py", line 258, in create_outputs
result = [
^
File "/python3.11/site-packages/langchain/chains/llm.py", line 261, in
self.output_key: self.output_parser.parse_result(generation),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/python3.11/site-packages/langchain_core/output_parsers/openai_functions.py", line 102, in parse_result
raise OutputParserException(
langchain_core.exceptions.OutputParserException: Could not parse function call data: Expecting property name enclosed in double quotes: line 2 column 3 (char 4)

Description

System Info

System Information

OS: Linux
OS Version: #18~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC
Python Version: 3.11.6 (main, Oct 23 2023, 22:47:21) [GCC 9.4.0]

Package Information

langchain_core: 0.1.29
langchain: 0.1.11
langchain_community: 0.0.25
langsmith: 0.1.22
langchain_openai: 0.0.8
langchain_text_splitters: 0.0.1

Packages not installed (Not Necessarily a Problem)

The following packages were not found:

langgraph
langserve

@dosubot dosubot bot added Ɑ: parsing Related to output parser module 🔌: openai Primarily related to OpenAI integrations 🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature labels Mar 11, 2024
@maximeperrindev
Copy link
Contributor

Hi @yadavalok1

Which model are you using ?
I tried to use LLM Model OpenAI() and it didn't work.
However when i tried with ChatOpenAI, it worked.

So, I recommend you to use a chat model instead of llm

@yadavalok1
Copy link
Author

Hi @yadavalok1

Which model are you using ? I tried to use LLM Model OpenAI() and it didn't work. However when i tried with ChatOpenAI, it worked.

So, I recommend you to use a chat model instead of llm

Hi @maximeperrindev , I am using AzureOpenAI, I will try using AzureChatOpenAI and confirm you here if it works for me.

@yadavalok1
Copy link
Author

Still getting the same error with AzureChatOpenAI, is there any workaround for this because I am directly using the tagging usecase code from the langchain repo and it seems to be not working.

My requirement is that , whenever a conversation starts I need to collect some required info from the user like personal details and once all required data are provided then only, I can help the user with it's query/questions. Also I need to store the collected also in some memory so the AI should know the context of it. So, it will be really helpful if you can suggest something or something like this is already.

Thanks!!

@maximeperrindev
Copy link
Contributor

@yadavalok1,
Well, I tried with this code and it's working. I used the same libs versions.

from langchain_openai import AzureChatOpenAI
from langchain.chains import create_tagging_chain
schema = {
    "properties": {
        "sentiment": {"type": "string"},
        "aggressiveness": {"type": "integer"},
        "language": {"type": "string"},
    }
}

chain = create_tagging_chain(schema,AzureChatOpenAI(
            azure_deployment="gpt-4-32k",
            openai_api_version="2023-05-15",
        ))

test_string = "Hey there!! We are going to celerate john's birthday. Suggest some celebration idea."

res = chain.invoke(test_string)
print(res)

@yadavalok1
Copy link
Author

@yadavalok1, Well, I tried with this code and it's working. I used the same libs versions.

from langchain_openai import AzureChatOpenAI
from langchain.chains import create_tagging_chain
schema = {
    "properties": {
        "sentiment": {"type": "string"},
        "aggressiveness": {"type": "integer"},
        "language": {"type": "string"},
    }
}

chain = create_tagging_chain(schema,AzureChatOpenAI(
            azure_deployment="gpt-4-32k",
            openai_api_version="2023-05-15",
        ))

test_string = "Hey there!! We are going to celerate john's birthday. Suggest some celebration idea."

res = chain.invoke(test_string)
print(res)

Thanks @maximeperrindev . I tried this but no luck , still facing the same error. Tried in different machine as well but same error. I hope this is not related to the model as I am using gpt35.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature 🔌: openai Primarily related to OpenAI integrations Ɑ: parsing Related to output parser module
Projects
None yet
Development

No branches or pull requests

2 participants