count_tokens(s):    return len(enc.encode(s))count_tokens(yaml.dump(raw_spotify_api_spec))    80326Let's see some examples!‚ÄãStarting with GPT-4. (Some robustness iterations under way for GPT-3 family.)from langchain.llms.openai import OpenAIfrom langchain.agents.agent_toolkits.openapi import plannerllm = OpenAI(model_name="gpt-4", temperature=0.0)    /Users/jeremywelborn/src/langchain/langchain/llms/openai.py:169: UserWarning: You are trying to use a chat model. This way of initializing it is no longer supported. Instead, please use: `from langchain.chat_models import ChatOpenAI`      warnings.warn(    /Users/jeremywelborn/src/langchain/langchain/llms/openai.py:608: UserWarning: You are trying to use a chat model. This way of initializing it is no longer supported. Instead, please use: `from langchain.chat_models import ChatOpenAI`      warnings.warn(spotify_agent = planner.create_openapi_agent(spotify_api_spec, requests_wrapper, llm)user_query = (    "make me a playlist with the first song from kind of blue. call it machine blues.")spotify_agent.run(user_query)            > Entering new AgentExecutor chain...    Action: api_planner    Action Input: I need to find the right API calls to create a playlist with the first song from Kind of Blue and name it Machine Blues    Observation: 1. GET /search to search for the album "Kind of Blue"    2. GET /albums/{id}/tracks to get the tracks from the "Kind of Blue" album    3. GET /me to get the current user's information    4. POST /users/{user_id}/playlists to create a new playlist named "Machine Blues" for the current user    5. POST /playlists/{playlist_id}/tracks to add the first song from "Kind of Blue" to the "Machine Blues" playlist    Thought:I have the plan, now I need to execute the API calls.    Action: api_controller    Action Input: 1. GET /search to search for the album "Kind of Blue"    2. GET /albums/{id}/tracks to get the tracks from the "Kind of Blue" album    3. GET /me to get the current user's
We can construct agents to consume arbitrary APIs, here APIs conformant to the OpenAPI/Swagger specification.
We can construct agents to consume arbitrary APIs, here APIs conformant to the OpenAPI/Swagger specification. ->: count_tokens(s):    return len(enc.encode(s))count_tokens(yaml.dump(raw_spotify_api_spec))    80326Let's see some examples!‚ÄãStarting with GPT-4. (Some robustness iterations under way for GPT-3 family.)from langchain.llms.openai import OpenAIfrom langchain.agents.agent_toolkits.openapi import plannerllm = OpenAI(model_name="gpt-4", temperature=0.0)    /Users/jeremywelborn/src/langchain/langchain/llms/openai.py:169: UserWarning: You are trying to use a chat model. This way of initializing it is no longer supported. Instead, please use: `from langchain.chat_models import ChatOpenAI`      warnings.warn(    /Users/jeremywelborn/src/langchain/langchain/llms/openai.py:608: UserWarning: You are trying to use a chat model. This way of initializing it is no longer supported. Instead, please use: `from langchain.chat_models import ChatOpenAI`      warnings.warn(spotify_agent = planner.create_openapi_agent(spotify_api_spec, requests_wrapper, llm)user_query = (    "make me a playlist with the first song from kind of blue. call it machine blues.")spotify_agent.run(user_query)            > Entering new AgentExecutor chain...    Action: api_planner    Action Input: I need to find the right API calls to create a playlist with the first song from Kind of Blue and name it Machine Blues    Observation: 1. GET /search to search for the album "Kind of Blue"    2. GET /albums/{id}/tracks to get the tracks from the "Kind of Blue" album    3. GET /me to get the current user's information    4. POST /users/{user_id}/playlists to create a new playlist named "Machine Blues" for the current user    5. POST /playlists/{playlist_id}/tracks to add the first song from "Kind of Blue" to the "Machine Blues" playlist    Thought:I have the plan, now I need to execute the API calls.    Action: api_controller    Action Input: 1. GET /search to search for the album "Kind of Blue"    2. GET /albums/{id}/tracks to get the tracks from the "Kind of Blue" album    3. GET /me to get the current user's