Amadeus toolkit minor update (#13002)

- update `Amadeus` toolkit with ability to switch Amadeus environments 
- update minor code explanations

---------

Co-authored-by: MinjiK <minji.kim@amadeus.com>
pull/13439/head^2
MinjiK 6 months ago committed by GitHub
parent b05c46074b
commit a1a11ffd78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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/)."
]
},
{
@ -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\""
]
},
{

@ -15,7 +15,7 @@ if TYPE_CHECKING:
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)

@ -96,7 +96,7 @@ class AmadeusFlightSearch(AmadeusBaseTool):
)
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,

@ -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…
Cancel
Save