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 toolkit minor update #13002

Merged
merged 3 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions docs/docs/integrations/toolkits/amadeus.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@
"source": [
"# Amadeus\n",
"\n",
"This notebook walks you through connecting LangChain to the `Amadeus` travel information API\n",
"This notebook walks you through connecting LangChain to the `Amadeus` travel APIs.\n",
"\n",
"To use this toolkit, you will need to set up your credentials explained in the [Amadeus for developers getting started overview](https://developers.amadeus.com/get-started/get-started-with-self-service-apis-335). Once you've received a AMADEUS_CLIENT_ID and AMADEUS_CLIENT_SECRET, you can input them as environmental variables below."
"This `Amadeus` toolkit allows agents to make decision when it comes to travel, especially searching and booking trips with flights.\n",
"\n",
"To use this toolkit, you will need to have your Amadeus API keys ready, explained in the [Get started Amadeus Self-Service APIs](https://developers.amadeus.com/get-started/get-started-with-self-service-apis-335). Once you've received a AMADEUS_CLIENT_ID and AMADEUS_CLIENT_SECRET, you can input them as environmental variables below.\n",
"\n",
"Note: Amadeus Self-Service APIs offers a test enviornment with [free limited data](https://amadeus4dev.github.io/developer-guides/test-data/). This allows developers to build and test their applications before deploying them to production. To access real-time data, you will need to [move to the production environment](https://amadeus4dev.github.io/developer-guides/API-Keys/moving-to-production/)."
]
},
{
Expand Down Expand Up @@ -40,7 +44,8 @@
"\n",
"os.environ[\"AMADEUS_CLIENT_ID\"] = \"CLIENT_ID\"\n",
"os.environ[\"AMADEUS_CLIENT_SECRET\"] = \"CLIENT_SECRET\"\n",
"os.environ[\"OPENAI_API_KEY\"] = \"API_KEY\""
"os.environ[\"OPENAI_API_KEY\"] = \"API_KEY\"\n",
"# os.environ[\"AMADEUS_HOSTNAME\"] = \"production\" or \"test\""
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


class AmadeusToolkit(BaseToolkit):
"""Toolkit for interacting with Amadeus which offers APIs for travel search."""
"""Toolkit for interacting with Amadeus which offers APIs for travel."""

client: Client = Field(default_factory=authenticate)

Expand Down
2 changes: 1 addition & 1 deletion libs/langchain/langchain/tools/amadeus/flight_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def _run(
)
return [None]

# Collect all results from the API
# Collect all results from the Amadeus Flight Offers Search API
try:
response = client.shopping.flight_offers_search.get(
originLocationCode=originLocationCode,
Expand Down
6 changes: 5 additions & 1 deletion libs/langchain/langchain/tools/amadeus/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ def authenticate() -> Client:
)
return None

client = Client(client_id=client_id, client_secret=client_secret)
hostname = "test" # Default hostname
if "AMADEUS_HOSTNAME" in os.environ:
hostname = os.environ["AMADEUS_HOSTNAME"]

client = Client(client_id=client_id, client_secret=client_secret, hostname=hostname)

return client
Loading