Skip to content

Commit

Permalink
Amadeus toolkit minor update (#13002)
Browse files Browse the repository at this point in the history
- update `Amadeus` toolkit with ability to switch Amadeus environments 
- update minor code explanations

---------

Co-authored-by: MinjiK <[email protected]>
  • Loading branch information
minjikarin and MinjiK authored Dec 6, 2023
1 parent b05c460 commit a1a11ff
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
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 @@ -15,7 +15,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 @@ -96,7 +96,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

0 comments on commit a1a11ff

Please sign in to comment.