Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[bug] [langgraph] failed to parse messages of type <class 'tuple'> #1119

Open
yeesian opened this issue Nov 13, 2024 · 3 comments
Open

[bug] [langgraph] failed to parse messages of type <class 'tuple'> #1119

yeesian opened this issue Nov 13, 2024 · 3 comments
Assignees
Labels
bug Something isn't working language: python Related to Python integration priority: low

Comments

@yeesian
Copy link

yeesian commented Nov 13, 2024

Describe the bug

ERROR:openinference.instrumentation.langchain._tracer:Failed to get attribute.
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/openinference/instrumentation/langchain/_tracer.py", line 282, in wrapper
    yield from wrapped(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/openinference/instrumentation/langchain/_tracer.py", line 382, in _input_messages
    raise ValueError(f"failed to parse messages of type {type(first_messages)}")
ValueError: failed to parse messages of type <class 'tuple'>

To Reproduce

Installation:

!pip install -q -U \
    google-cloud-aiplatform==1.72.0 \
    langgraph==0.2.46 \
    langchain-google-vertexai==2.0.7 \
    opentelemetry-sdk \
    openinference-instrumentation-langchain==0.1.29

Reproducing the issue:

import vertexai
from langchain_google_vertexai import ChatVertexAI
from langgraph.prebuilt import create_react_agent
from opentelemetry import trace as trace_api
from opentelemetry.sdk import trace as trace_sdk
from opentelemetry.sdk.trace.export import ConsoleSpanExporter, SimpleSpanProcessor
from openinference.instrumentation.langchain import LangChainInstrumentor

tracer_provider = trace_sdk.TracerProvider()
trace_api.set_tracer_provider(tracer_provider)
tracer_provider.add_span_processor(SimpleSpanProcessor(ConsoleSpanExporter()))

LangChainInstrumentor().instrument()
vertexai.init(project=PROJECT_ID, location=LOCATION)

def get_exchange_rate(
    currency_from: str = "USD",
    currency_to: str = "EUR",
    currency_date: str = "latest",
):
    """Retrieves the exchange rate between two currencies."""
    import requests
    response = requests.get(
        f"https://api.frankfurter.app/{currency_date}",
        params={"from": currency_from, "to": currency_to},
    )
    return response.json()

model = ChatVertexAI(model="gemini-1.5-pro")
agent = create_react_agent(
    model,
    tools=[get_exchange_rate],
)
for resp in agent.stream(
    input={"messages": [
        ("user", "What is the exchange rate from US dollars to Swedish currency?")
    ]},
    config={"configurable": {"thread_id": "thread-id"}},
):
    print(resp)

Expected behavior
No ValueError to be raised.

Additional context
You can switch to OpenAI if preferred, I just happen to have ChatVertexAI available on hand for myself to reproduce.

@yeesian yeesian added bug Something isn't working triage Issues that require triage labels Nov 13, 2024
@github-project-automation github-project-automation bot moved this to 📘 Todo in phoenix Nov 13, 2024
@dosubot dosubot bot added the language: python Related to Python integration label Nov 13, 2024
@RogerHYang
Copy link
Contributor

Thanks for the report @yeesian. We'll be looking into this

@RogerHYang RogerHYang self-assigned this Nov 14, 2024
@RogerHYang RogerHYang removed the triage Issues that require triage label Nov 14, 2024
@RogerHYang
Copy link
Contributor

Alright, I was able to reproduce this issue. Before we work on a fix, I’d like to point out that it has minimal impact on the trace’s usability, as it occurs in a minor section and can be generally ignored.

@axiomofjoy
Copy link
Contributor

Hey @yeesian, thanks for reporting this issue! We are heads down on our current milestone, but we will circle back when we free up to take a look at this. Thanks for your patience.

@RogerHYang RogerHYang moved this from 📘 Todo to 👨‍💻 In progress in phoenix Dec 12, 2024
@RogerHYang RogerHYang moved this from 👨‍💻 In progress to 📘 Todo in phoenix Dec 13, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working language: python Related to Python integration priority: low
Projects
Status: 📘 Todo
Development

No branches or pull requests

4 participants