{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import autogen\n", "\n", "config_list = autogen.config_list_from_json(env_or_file=\"OAI_CONFIG_LIST\")\n", "\n", "llm_config={\n", " \"request_timeout\": 600,\n", " \"seed\": 42,\n", " \"config_list\": config_list,\n", " \"temperature\": 0,\n", "}" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "assistant = autogen.AssistantAgent(\n", " name=\"assistant\",\n", " llm_config=llm_config,\n", " is_termination_msg=lambda x: True if \"TERMINATE\" in x.get(\"content\") else False,\n", ")\n", "\n", "user_proxy = autogen.UserProxyAgent(\n", " name=\"user_proxy\",\n", " human_input_mode=\"NEVER\",\n", " is_termination_msg=lambda x: True if \"TERMINATE\" in x.get(\"content\") else False,\n", " max_consecutive_auto_reply=10,\n", " code_execution_config={\n", " \"work_dir\": \"work_dir\",\n", " \"use_docker\": True,\n", " },\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "task1 = \"\"\"\n", "Give me the cheapest Vueling daily flight between Barcelona and Palma for everyday of next month.\n", "The URL to obtain it is this one:\n", "https://apiwww.vueling.com/api/FlightPrice/GetAllFlights?originCode={departure_station}&destinationCode={arrival_station}&year={year}&month={month}¤cyCode={currency_code}&monthsRange=17\n", "The 'departure_station' and 'arrival_station' parameters must be in IATA Code. Example: BCN, MAD, LCG.\" \n", "If the 'departure_station' or the 'arrival_station' is not in IATA code you must do the convertion. Example: Madrid = MAD\n", "The 'month' needs to be a number. If the 'month' given to you is not a number, then you must convert it. Example: February = 2\n", "\n", "The output of the calling call looks like this:\n", "[\n", " {\n", " \"ArrivalDate\": \"2023-11-01T00:00:00\",\n", " \"ArrivalStation\": \"CDG\",\n", " \"Availability\": 0,\n", " \"ClassOfService\": \"C\",\n", " \"Created\": \"0001-01-01T00:00:00\",\n", " \"DepartureDate\": \"2023-11-01T06:00:00\",\n", " \"DepartureStation\": \"BCN\",\n", " \"Fare\": null,\n", " \"FlightID\": \"8242\",\n", " \"Price\": 119.99,\n", " \"ProductClass\": null,\n", " \"Sort\": 0,\n", " \"Tax\": 0.0,\n", " \"IsInvalidPrice\": false\n", " }\n", "]\n", "\n", "Return the data in this format:\n", "vueling_prices = [\n", " \"2023-11-01\": 17.46,\n", " \"2023-11-02\": 19.46,\n", " ...\n", "] \n", "\"\"\"\n", "\n", "user_proxy.initiate_chat(assistant, message=task1)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "task2 = \"\"\"\n", "Give me the cheapest Ryanair daily flight between Barcelona and Palma for everyday of next month.\n", "The URL to obtain it is this one:\n", "https://services-api.ryanair.com/farfnd/3/oneWayFares/{departure_station}/{arrival_station}/cheapestPerDay?outboundMonthOfDate={year}-{month}-01\n", "The 'departure_station' and 'arrival_station' parameters must be in IATA Code. Example: BCN, MAD, LCG.\" \n", "If the 'departure_station' or the 'arrival_station' is not in IATA code you must do the convertion. Example: Madrid = MAD\n", "The 'month' and 'year' needs to be a number. If the 'month' or 'year' given to you is not a number, then you must convert it. Example: February = 2\n", "You don't need to make multiple calls for every day of the month. A single request to the first day of the month will give you the cheapest prices for the entire month.\n", "\n", "Return the data in this format:\n", "ryanair_prices = [\n", " \"2023-11-01\": 17.46,\n", " \"2023-11-02\": 19.46,\n", " ...\n", "] \n", "\"\"\"\n", "\n", "user_proxy.initiate_chat(assistant, message=task2, clear_history=False)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "task3 = \"\"\"Use this data to generate a chart comparing the cheapest daily prices between Vueling and Ryanair flights.\n", "Save the chart in a png file\n", "\"\"\"\n", "user_proxy.initiate_chat(assistant, message=task3, clear_history=False)" ] } ], "metadata": { "kernelspec": { "display_name": ".venv", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.11" } }, "nbformat": 4, "nbformat_minor": 2 }