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

Amadeus searchflight not working #17375

Closed
4 tasks done
SiruX21 opened this issue Feb 11, 2024 · 5 comments
Closed
4 tasks done

Amadeus searchflight not working #17375

SiruX21 opened this issue Feb 11, 2024 · 5 comments
Labels
Ɑ: agent Related to agents module 🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature 🔌: google Primarily related to Google GenAI or VertexAI integrations

Comments

@SiruX21
Copy link

SiruX21 commented Feb 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.

Example Code

from langchain_google_genai import ChatGoogleGenerativeAI
from langchain_community.agent_toolkits.amadeus.toolkit import AmadeusToolkit
from langchain import hub
from langchain.agents import AgentExecutor, create_react_agent
llm = ChatGoogleGenerativeAI(model="gemini-pro")
toolkit = AmadeusToolkit(llm=llm)
tools = toolkit.get_tools()
prompt = hub.pull("sirux21/react")
agent = create_react_agent(llm, tools, prompt)
val = {
     "input": "Find flights from NYC to LAX tomorrow",
}
agent_executor = AgentExecutor(
    agent=agent,
    tools=tools,
    verbose=True,
    agent=AgentType.STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION,
)

agent_executor.invoke(val)

Error Message and Stack Trace (if applicable)

NYC is too broad of a location, I should narrow it down to a specific airport
Action: closest_airport
Action Input: {
"location": "New York City, NY"
}content='json\n{\n "iataCode": "JFK"\n}\n'JFK is the closest airport to NYC, I will use that as the origin airport
Action: single_flight_search
Action Input: {
"originLocationCode": "JFK",
"destinationLocationCode": "LAX",
"departureDateTimeEarliest": "2023-06-08T00:00:00",
"departureDateTimeLatest": "2023-06-08T23:59:59"
}Traceback (most recent call last):
File "C:\Users\sirux21\Nextcloud\CodeRed-Oddysey\CodeRed-Odyssey\python\main4.py", line 24, in
agent_executor.invoke(val)
File "C:\Users\sirux21\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\langchain\chains\base.py", line 162, in invoke
raise e
File "C:\Users\sirux21\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\langchain\chains\base.py", line 156, in invoke
self._call(inputs, run_manager=run_manager)
File "C:\Users\sirux21\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\langchain\agents\agent.py", line 1391, in _call
next_step_output = self._take_next_step(
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\sirux21\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\langchain\agents\agent.py", line 1097, in _take_next_step
[
File "C:\Users\sirux21\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\langchain\agents\agent.py", line 1097, in
[
File "C:\Users\sirux21\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\langchain\agents\agent.py", line 1182, in _iter_next_step
yield self._perform_agent_action(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\sirux21\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\langchain\agents\agent.py", line 1204, in _perform_agent_action
observation = tool.run(
^^^^^^^^^
File "C:\Users\sirux21\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\langchain_core\tools.py", line 364, in run
raise e
File "C:\Users\sirux21\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\langchain_core\tools.py", line 355, in run
parsed_input = self._parse_input(tool_input)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\sirux21\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\langchain_core\tools.py", line 258, in parse_input
input_args.validate({key
: tool_input})
File "C:\Users\sirux21\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\pydantic\v1\main.py", line 711, in validate
return cls(**value)
^^^^^^^^^^^^
File "C:\Users\sirux21\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\pydantic\v1\main.py", line 341, in init
raise validation_error
pydantic.v1.error_wrappers.ValidationError: 3 validation errors for FlightSearchSchema
destinationLocationCode
field required (type=value_error.missing)
departureDateTimeEarliest
field required (type=value_error.missing)
departureDateTimeLatest
field required (type=value_error.missing)

Description

FlightSearchSchema is unable to parse the input

System Info

langchain==0.1.6
langchain-community==0.0.19
langchain-core==0.1.22
langchain-google-genai==0.0.8
langchainhub==0.1.14
windows
3.11

Copy link

dosubot bot commented Feb 11, 2024

🤖

Hey @SiruX21, great to see you back with us! How's everything going on your end?

Thank you for providing the detailed error log. It seems like the issue is related to the input parameters for the FlightSearchSchema in the AmadeusToolkit. The error message indicates that the destinationLocationCode, departureDateTimeEarliest, and departureDateTimeLatest fields are missing.

Based on the context provided, the FlightSearchSchema expects the following input parameters:

  1. originLocationCode: A string representing the three-letter International Air Transport Association (IATA) Location Identifier for the search's origin airport.

  2. destinationLocationCode: A string representing the three-letter International Air Transport Association (IATA) Location Identifier for the search's destination airport.

  3. departureDateTimeEarliest: A string representing the earliest departure datetime from the origin airport for the flight search in the following format: "YYYY-MM-DDTHH:MM", where "T" separates the date and time components. For example: "2023-06-09T10:30:00" represents June 9th, 2023, at 10:30 AM.

  4. departureDateTimeLatest: A string representing the latest departure datetime from the origin airport for the flight search in the same format as departureDateTimeEarliest.

  5. page_number: An integer representing the specific page number of flight results to retrieve. It defaults to 1 if not provided.

From the error log, it seems like the destinationLocationCode, departureDateTimeEarliest, and departureDateTimeLatest fields are not being passed correctly to the FlightSearchSchema. Please ensure that these fields are included in the Action Input for the single_flight_search action.

Here is an example of how the Action Input should look like:

{
    "originLocationCode": "JFK",
    "destinationLocationCode": "LAX",
    "departureDateTimeEarliest": "2023-06-08T00:00:00",
    "departureDateTimeLatest": "2023-06-08T23:59:59"
}

Please try updating your Action Input and let me know if the issue persists.

Sources

About Dosu

This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

@dosubot dosubot bot added Ɑ: agent Related to agents module 🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature 🔌: google Primarily related to Google GenAI or VertexAI integrations labels Feb 11, 2024
@SiruX21
Copy link
Author

SiruX21 commented Feb 11, 2024

@dosu-bot If you look, that is exactly what is passed through,

Action Input: {
"originLocationCode": "JFK",
"destinationLocationCode": "LAX",
"departureDateTimeEarliest": "2023-06-08T00:00:00",
"departureDateTimeLatest": "2023-06-08T23:59:59"
}

by the agent AI, and the issue still persists.

Copy link

dosubot bot commented Feb 11, 2024

🤖

From the error message you provided, it seems like the FlightSearchSchema is not receiving the required fields (destinationLocationCode, departureDateTimeEarliest, departureDateTimeLatest). However, from the action input you provided, it seems like these fields are indeed being passed correctly.

This discrepancy could be due to a few reasons:

  1. Data Flow Issue: There might be an issue with how the data is being passed from the agent to the FlightSearchSchema. To debug this, you could print the data being passed right before it's sent to the FlightSearchSchema and check if it matches the action input you provided.

  2. Schema Validation Issue: There might be an issue with the FlightSearchSchema itself. You could try creating a FlightSearchSchema object directly with the action input you provided and see if it still throws a validation error.

Here's how you can do these:

# Debugging data flow
print("Data being passed to FlightSearchSchema:", val)
agent_executor.invoke(val)

# Debugging schema validation
from langchain_community.agent_toolkits.amadeus.schemas import FlightSearchSchema

try:
    flight_search = FlightSearchSchema(**{
        "originLocationCode": "JFK",
        "destinationLocationCode": "LAX",
        "departureDateTimeEarliest": "2023-06-08T00:00:00",
        "departureDateTimeLatest": "2023-06-08T23:59:59"
    })
    print("FlightSearchSchema created successfully:", flight_search)
except Exception as e:
    print("Error while creating FlightSearchSchema:", e)

If the data being passed is correct and the FlightSearchSchema is able to be created directly without any errors, then the issue might be somewhere else in the code. In that case, please provide more information about the steps leading up to the error and any other relevant code snippets.

If the data being passed is not correct, then there might be an issue with how the agent is generating the action input. In that case, you might need to debug the agent's code.

If the FlightSearchSchema is not able to be created directly, then there might be an issue with the FlightSearchSchema itself or the data being passed to it. In that case, please double-check the data and the FlightSearchSchema's requirements.

I hope this helps! Let me know if you have any other questions or if there's anything else I can do to assist you.

Sources

About Dosu

This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

@SiruX21 SiruX21 closed this as not planned Won't fix, can't repro, duplicate, stale Feb 13, 2024
@caidwang
Copy link
Contributor

@SiruX21 did you solve it? I meet the same problem. Does prompt optimize work?

baskaryan pushed a commit that referenced this issue Mar 6, 2024
Description:

This pull request addresses two key improvements to the langchain
repository:

**Fix for Crash in Flight Search Interface**:

Previously, the code would crash when encountering a failure scenario in
the flight ticket search interface. This PR resolves this issue by
implementing a fix to handle such scenarios gracefully. Now, the code
handles failures in the flight search interface without crashing,
ensuring smoother operation.

**Documentation Update for Amadeus Toolkit**:

Prior to this update, examples provided in the documentation for the
Amadeus Toolkit were unable to run correctly due to outdated
information. This PR includes an update to the documentation, ensuring
that all examples can now be executed successfully. With this update,
users can effectively utilize the Amadeus Toolkit with accurate and
functioning examples.
These changes aim to enhance the reliability and usability of the
langchain repository by addressing issues related to error handling and
ensuring that documentation remains up-to-date and actionable.

Issue: #17375

Twitter Handle: SingletonYxx
thebhulawat pushed a commit to thebhulawat/langchain that referenced this issue Mar 6, 2024
Description:

This pull request addresses two key improvements to the langchain
repository:

**Fix for Crash in Flight Search Interface**:

Previously, the code would crash when encountering a failure scenario in
the flight ticket search interface. This PR resolves this issue by
implementing a fix to handle such scenarios gracefully. Now, the code
handles failures in the flight search interface without crashing,
ensuring smoother operation.

**Documentation Update for Amadeus Toolkit**:

Prior to this update, examples provided in the documentation for the
Amadeus Toolkit were unable to run correctly due to outdated
information. This PR includes an update to the documentation, ensuring
that all examples can now be executed successfully. With this update,
users can effectively utilize the Amadeus Toolkit with accurate and
functioning examples.
These changes aim to enhance the reliability and usability of the
langchain repository by addressing issues related to error handling and
ensuring that documentation remains up-to-date and actionable.

Issue: langchain-ai#17375

Twitter Handle: SingletonYxx
@caidwang
Copy link
Contributor

caidwang commented Mar 7, 2024

Hi,@SiruX21. This problem has be solved in the latest doc. Amadeus Tool

bechbd pushed a commit to bechbd/langchain that referenced this issue Mar 29, 2024
Description:

This pull request addresses two key improvements to the langchain
repository:

**Fix for Crash in Flight Search Interface**:

Previously, the code would crash when encountering a failure scenario in
the flight ticket search interface. This PR resolves this issue by
implementing a fix to handle such scenarios gracefully. Now, the code
handles failures in the flight search interface without crashing,
ensuring smoother operation.

**Documentation Update for Amadeus Toolkit**:

Prior to this update, examples provided in the documentation for the
Amadeus Toolkit were unable to run correctly due to outdated
information. This PR includes an update to the documentation, ensuring
that all examples can now be executed successfully. With this update,
users can effectively utilize the Amadeus Toolkit with accurate and
functioning examples.
These changes aim to enhance the reliability and usability of the
langchain repository by addressing issues related to error handling and
ensuring that documentation remains up-to-date and actionable.

Issue: langchain-ai#17375

Twitter Handle: SingletonYxx
gkorland pushed a commit to FalkorDB/langchain that referenced this issue Mar 30, 2024
Description:

This pull request addresses two key improvements to the langchain
repository:

**Fix for Crash in Flight Search Interface**:

Previously, the code would crash when encountering a failure scenario in
the flight ticket search interface. This PR resolves this issue by
implementing a fix to handle such scenarios gracefully. Now, the code
handles failures in the flight search interface without crashing,
ensuring smoother operation.

**Documentation Update for Amadeus Toolkit**:

Prior to this update, examples provided in the documentation for the
Amadeus Toolkit were unable to run correctly due to outdated
information. This PR includes an update to the documentation, ensuring
that all examples can now be executed successfully. With this update,
users can effectively utilize the Amadeus Toolkit with accurate and
functioning examples.
These changes aim to enhance the reliability and usability of the
langchain repository by addressing issues related to error handling and
ensuring that documentation remains up-to-date and actionable.

Issue: langchain-ai#17375

Twitter Handle: SingletonYxx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ɑ: agent Related to agents module 🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature 🔌: google Primarily related to Google GenAI or VertexAI integrations
Projects
None yet
Development

No branches or pull requests

2 participants