{ "cells": [ { "cell_type": "code", "execution_count": null, "id": "0194652a-61b8-40bd-9455-5ace65bf754e", "metadata": {}, "outputs": [], "source": [ "from datasets import load_dataset, Dataset\n", "import pandas as pd\n", "import numpy as np\n", "from collections import Counter, defaultdict\n", "import json\n", "import matplotlib.pyplot as plt\n", "import seaborn as sns\n", "import re\n", "from tqdm import tqdm\n", "import networkx as nx\n", "from typing import Dict, List\n", "import uuid\n", "import transformers\n", "import torch\n", "from datasets import load_from_disk\n", "from tqdm import tqdm\n", "import os\n", "os.environ[\"CUDA_VISIBLE_DEVICES\"] = \"4,5\"" ] }, { "cell_type": "code", "execution_count": 2, "id": "30bfb6d4-33c8-4a70-9d6c-6ce90d4d1fe9", "metadata": {}, "outputs": [], "source": [ "d = load_dataset(\"Team-ACE/ToolACE\")" ] }, { "cell_type": "code", "execution_count": 3, "id": "1d82c5b7-0501-4293-96ed-e58f8b474b10", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Dataset({\n", " features: ['system', 'conversations'],\n", " num_rows: 11300\n", "})" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "d['train']" ] }, { "cell_type": "code", "execution_count": 6, "id": "b5da22ba-7019-403d-853f-5cd978309ab3", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'system': ['You are an expert in composing functions. You are given a question and a set of possible functions. \\nBased on the question, you will need to make one or more function/tool calls to achieve the purpose. \\nIf none of the function can be used, point it out. If the given question lacks the parameters required by the function,\\nalso point it out. You should only return the function call in tools call sections.\\nHere is a list of functions in JSON format that you can invoke:\\n[{\"name\": \"newAddress\", \"description\": \"Generates a new Ethereum address that can be used to send or receive funds. Do not lose the password! We can\\'t restore access to an address if you lose it.\", \"parameters\": {\"type\": \"dict\", \"properties\": {\"password\": {\"description\": \"The password for the new Ethereum address\", \"type\": \"string\"}}, \"required\": [\"password\"]}, \"required\": null}, {\"name\": \"Market Trends API\", \"description\": \"Get the latest market trends and relevant news for a specified country and language.\", \"parameters\": {\"type\": \"dict\", \"properties\": {\"trend_type\": {\"description\": \"Trend type.\", \"type\": \"string\", \"enum\": [\"MARKET_INDEXES\", \"MOST_ACTIVE\", \"GAINERS\", \"LOSERS\", \"CRYPTO\", \"CURRENCIES\", \"CLIMATE_LEADERS\"]}, \"country\": {\"description\": \"The country for which to get trends, specified as a 2-letter country code - see ISO 3166.\", \"type\": \"string\", \"default\": \"us\"}, \"language\": {\"description\": \"The language to use for the results, specified as a 2-letter language code - see ISO 639-1.\", \"type\": \"string\", \"default\": \"en\"}}, \"required\": [\"trend_type\"]}, \"required\": null}, {\"name\": \"Get Futures Prices\", \"description\": \"Retrieve a list of current futures prices for various financial instruments.\", \"parameters\": {\"type\": \"dict\", \"properties\": {\"instrument_type\": {\"description\": \"Type of financial instrument (e.g., commodity, currency, index)\", \"type\": \"string\"}, \"exchange\": {\"description\": \"Name of the exchange (e.g., CME, ICE, NYMEX)\", \"type\": \"string\"}, \"start_string\": {\"description\": \"Start string for the price data (YYYY-MM-DD)\", \"type\": \"string\"}, \"end_string\": {\"description\": \"End string for the price data (YYYY-MM-DD)\", \"type\": \"string\"}}, \"required\": [\"instrument_type\", \"exchange\"]}, \"required\": null}, {\"name\": \"SEC Filings\", \"description\": \"Returns a list of SEC Filings for the requested company, including filing types, strings, and documents.\", \"parameters\": {\"type\": \"dict\", \"properties\": {\"identifier\": {\"description\": \"Publicly traded company\\'s stock symbol or Central Index Key (CIK)\", \"type\": \"string\", \"default\": \"aapl\"}}, \"required\": [\"identifier\"]}, \"required\": null}, {\"name\": \"United States Away from Home Mobility API\", \"description\": \"Retrieve daily data on the percentage change in time spent away from home in the United States, providing insights into the economic impact of the COVID-19 pandemic.\", \"parameters\": {\"type\": \"dict\", \"properties\": {\"string\": {\"description\": \"The string for which to retrieve data (format: YYYY-MM-DD)\", \"type\": \"string\"}, \"state\": {\"description\": \"The state for which to retrieve data (optional, default: all states)\", \"type\": \"string\"}}, \"required\": [\"string\"]}, \"required\": null}, {\"name\": \"Calculate Sales Tax\", \"description\": \"Retrieves the sales tax rate applicable to a specific address. This API accepts address inputs to deliver up-to-string, relevant local sales tax rates instantly.\", \"parameters\": {\"type\": \"dict\", \"properties\": {\"country\": {\"description\": \"Set to one of the country codes listed in Supported Countries.\", \"type\": \"string\", \"default\": \"US\"}, \"city\": {\"description\": \"City name\", \"type\": \"string\", \"default\": \"Meridian\"}, \"zip\": {\"description\": \"Zip code\", \"type\": \"string\", \"default\": \"83646\"}, \"street\": {\"description\": \"Street address\", \"type\": \"string\", \"default\": \"936 Storey Ave\"}}, \"required\": [\"country\"]}, \"required\": null}]. \\nShould you decide to return the function call(s). \\nPut it in the format of [func1(params_name=params_value, params_name2=params_value2...), func2(params)]\\n\\nNO other text MUST be included. \\n',\n", " 'You are an expert in composing functions. You are given a question and a set of possible functions. \\nBased on the question, you will need to make one or more function/tool calls to achieve the purpose. \\nIf none of the function can be used, point it out. If the given question lacks the parameters required by the function,\\nalso point it out. You should only return the function call in tools call sections.\\nHere is a list of functions in JSON format that you can invoke:\\n[{\"name\": \"Quotes by Keywords\", \"description\": \"Returns a list of quotes containing the specified keyword.\", \"parameters\": {\"type\": \"dict\", \"properties\": {\"word\": {\"description\": \"The keyword to search for in quotes.\", \"type\": \"string\"}}, \"required\": [\"word\"]}, \"required\": null}, {\"name\": \"Get Zip Code Information\", \"description\": \"Retrieve information about a specific zip code in the United States.\", \"parameters\": {\"type\": \"dict\", \"properties\": {\"country\": {\"description\": \"The country code (default: \\'us\\')\", \"type\": \"string\"}, \"postal_code\": {\"description\": \"The zip code (default: \\'90210\\')\", \"type\": \"string\"}}, \"required\": [\"country\", \"postal_code\"]}, \"required\": null}, {\"name\": \"Weekly Hot 100 Chart\", \"description\": \"Retrieve the Billboard Hot 100 chart for a specific string.\", \"parameters\": {\"type\": \"dict\", \"properties\": {\"string\": {\"description\": \"The string for which to retrieve the chart (YYYY-MM-DD)\", \"type\": \"string\"}}, \"required\": [\"string\"]}, \"required\": null}, {\"name\": \"Get Cars Information\", \"description\": \"This API returns a list of cars information based on the provided parameters.\", \"parameters\": {\"type\": \"dict\", \"properties\": {\"model\": {\"description\": \"The model of the vehicle.\", \"type\": \"string\"}, \"make\": {\"description\": \"The manufacturer of the vehicle.\", \"type\": \"string\"}, \"year\": {\"description\": \"The model year of the vehicle.\", \"type\": \"string\"}, \"fuel_type\": {\"description\": \"The type of fuel used.\", \"type\": \"string\"}, \"drive\": {\"description\": \"The drive transmission type.\", \"type\": \"string\"}, \"transmission\": {\"description\": \"The type of transmission.\", \"type\": \"string\"}, \"cylinders\": {\"description\": \"The number of cylinders.\", \"type\": \"float\"}, \"min_city_mpg\": {\"description\": \"Minimum city fuel efficiency in miles per gallon.\", \"type\": \"float\"}, \"max_city_mpg\": {\"description\": \"Maximum city fuel efficiency in miles per gallon.\", \"type\": \"float\"}, \"min_hwy_mpg\": {\"description\": \"Minimum highway fuel efficiency in miles per gallon.\", \"type\": \"float\"}, \"max_hwy_mpg\": {\"description\": \"Maximum highway fuel efficiency in miles per gallon.\", \"type\": \"float\"}, \"min_comb_mpg\": {\"description\": \"Minimum combination (city + highway) fuel efficiency in miles per gallon.\", \"type\": \"float\"}, \"max_comb_mpg\": {\"description\": \"Maximum combination (city + highway) fuel efficiency in miles per gallon.\", \"type\": \"float\"}, \"limit\": {\"description\": \"How many results to return.\", \"type\": \"string\"}}, \"required\": []}, \"required\": null}, {\"name\": \"Lorem Ipsum Generator\", \"description\": \"Generate a specified number of words of Lorem Ipsum text\", \"parameters\": {\"type\": \"dict\", \"properties\": {\"amount\": {\"description\": \"The number of words to generate\", \"type\": \"int\"}}, \"required\": [\"amount\"]}, \"required\": null}, {\"name\": \"Crawl\", \"description\": \"Perform a Google search and return the HTML source of the results page.\", \"parameters\": {\"type\": \"dict\", \"properties\": {\"query\": {\"description\": \"The search query to perform.\", \"type\": \"string\"}}, \"required\": [\"query\"]}, \"required\": null}]. \\nShould you decide to return the function call(s). \\nPut it in the format of [func1(params_name=params_value, params_name2=params_value2...), func2(params)]\\n\\nNO other text MUST be included. \\n'],\n", " 'conversations': [[{'from': 'user',\n", " 'value': \"I'm considering investing and I'd like to know what's happening in the market right now. Could you get me the top market trends in the US?\"},\n", " {'from': 'assistant',\n", " 'value': '[Market Trends API(trend_type=\"MARKET_INDEXES\", country=\"us\")]'},\n", " {'from': 'tool',\n", " 'value': '[{\"name\": \"Market Trends API\", \"results\": {\"trends\": [{\"name\": \"S&P 500\", \"description\": \"Standard & Poor\\'s 500 Index is a market-capitalization-weighted index of the 500 largest U.S. publicly traded companies.\", \"data\": {\"current_value\": \"4172.80\", \"percentage_change\": \"+0.68%\"}}, {\"name\": \"DOW J\", \"description\": \"Dow Jones Industrial Average is a price-weighted average of 30 blue-chip stocks that are generally the leaders in their industry.\", \"data\": {\"current_value\": \"34479.60\", \"percentage_change\": \"+0.47%\"}}, {\"name\": \"NASDAQ\", \"description\": \"The NASDAQ Composite is a broad-based capitalization-weighted index of stocks in all three NASDAQ tiers: Global Select, Global Market and Capital Market.\", \"data\": {\"current_value\": \"13691.30\", \"percentage_change\": \"+0.90%\"}}]}}]'},\n", " {'from': 'assistant',\n", " 'value': \"Here are the top Market Trends in the US right now:\\n\\n1. **S&P 500**: The Standard & Poor's 500 Index is a market-capitalization-weighted index of the 500 largest U.S. publicly traded companies. Its current value is 4172.80 with a percentage change of +0.68%.\\n\\n2. **DOW J**: The Dow Jones Industrial Average is a price-weighted average of 30 blue-chip stocks that are generally the leaders in their industry. Its current value is 34479.60 with a percentage change of +0.47%.\\n\\n3. **NASDAQ**: The NASDAQ Composite is a broad-based capitalization-weighted index of stocks in all three NASDAQ tiers: Global Select, Global Market and Capital Market. Its current value is 13691.30 with a percentage change of +0.90%.\\n\\nThis information can help you make informed decisions about your investment plans.\"},\n", " {'from': 'user',\n", " 'value': 'Could you explain what SEC filings are and how they might be useful for an investor like me?'},\n", " {'from': 'assistant',\n", " 'value': \"Sure, SEC filings refer to official documents that are submitted by publicly traded companies to the U.S. Securities and Exchange Commission (SEC). These documents provide valuable information about a company's financial performance, its management team, ownership, key business operations, market competition, and future prospects. They are typically comprehensive and contain detailed information that a company is legally required to disclose to the public.\\n\\nInvestors like you can use these filings to better understand a company's true financial health and operations. Information you might glean from SEC filings includes:\\n\\n1. **Financial Statements**: Balance sheets, income statements, and cash flow statements can help you analyze the financial health and profitability of a company.\\n\\n2. **Management Discussion and Analysis (MD&A)**: This section offers management's perspective on the company's performance, including explanations of financial results, significant changes, market risk exposures, and future operations and strategy.\\n\\n3. **Risk Factors**: In the filing, companies are required to disclose potential risks of investing in their company. Insight into the risks the company is facing can help you make a more informed decision about investing.\\n\\n4. **Major Shareholders**: Companies must disclose the list of major shareholders. High ownership of shares by insiders could indicate confidence in the business, while large institutional ownership could suggest stability.\\n\\n5. **Director and Executive Compensation**: Information on executive remuneration packages can indicate how well the company’s interests are aligned with its executive team.\\n\\nSEC filings are a fundamental part of investment research and due diligence. They can provide deep insights into a company that may not be immediately obvious from simply looking at its earnings or share price. It's essential for investors to understand how to read and interpret these filings to make informed investment decisions.\"},\n", " {'from': 'user',\n", " 'value': 'So, a couple of years ago, I invested in a tech startup without doing any proper research. It seemed like a hot trend at the time, but the company went belly up within a year. I ended up losing a good chunk of money. What are your thoughts on that?'},\n", " {'from': 'assistant',\n", " 'value': \"As an assistant, I'm here to provide advice and guide you in your financial decisions. Here are my thoughts:\\n\\nInvesting in startups or any company without conducting proper research carries high risk. Although some startups have very high growth potentials and can provide excellent returns, many also fail within a few years of operation. This is especially the case in the tech industry where competition is stiff and technology changes rapidly.\\n\\nThat being said, your past experience with the tech startup is an important lesson in the necessity of conducting thorough due diligence before investing. Here are some steps you might take before future investments:\\n\\n1. **Understand the Business**: Make sure you understand the company's business model, its products or services, the market it operates in and its competition.\\n\\n2. **Financial Analysis**: Review financial statements, revenue, profitability, growth rates, debt levels, and cash flow. \\n\\n3. **Management Review**: It's important to assess the quality of the management team and their plans for the company.\\n\\n4. **Use of Tools**: Utilize tools like the SEC Filings tool to retrieve important documents to get detailed information about a company's operations, management and financials.\\n\\n5. **Risk vs Reward**: Analyze the investment's potential returns in light of the potential risk. High-risk investments should have the potential for higher returns.\\n\\nRemember, all investments carry a degree of risk. As such, it can be beneficial to diversify investments to spread risk and not put all of your money into one company or sector. It may also be helpful to seek advice from financial advisors or use trusted financial services to ensure informed decisions.\\n\\nGoing forward, employing these strategies could help reduce risk and maximize potential returns on your investments.\"},\n", " {'from': 'user',\n", " 'value': \"Could you provide me with the SEC filings for Apple? Also, I’m curious about how COVID-19 has affected people's mobility away from home in the US.\"},\n", " {'from': 'assistant',\n", " 'value': '[SEC Filings(identifier=\"AAPL\"), United States Away from Home Mobility API(string=\"2025-05-17\")]'}],\n", " [{'from': 'user',\n", " 'value': 'Could you please find me some quotes about \"inspiration\"?'},\n", " {'from': 'assistant', 'value': '[Quotes by Keywords(word=\"inspiration\")]'},\n", " {'from': 'tool',\n", " 'value': '[{\"name\": \"Quotes by Keywords\", \"results\": {\"quotes\": [{\"text\": \"The only way to achieve the impossible is to believe it is possible.\", \"author\": \"Charles Kingsleigh\"}, {\"text\": \"Don\\'t watch the clock; do what it does. Keep going.\", \"author\": \"Sam Levenson\"}, {\"text\": \"Success is not the key to happiness. Happiness is the key to success. If you love what you are doing, you will be successful.\", \"author\": \"Albert Schweitzer\"}]}}]'},\n", " {'from': 'assistant',\n", " 'value': 'Here are some inspiration quotes for you:\\n\\n1. \"The only way to achieve the impossible is to believe it is possible.\" - Charles Kingsleigh\\n2. \"Don\\'t watch the clock; do what it does. Keep going.\" - Sam Levenson\\n3. \"Success is not the key to happiness. Happiness is the key to success. If you love what you are doing, you will be successful.\" - Albert Schweitzer\\n\\nFeel free to reflect on these or let me know if you need more quotes or information on another topic!'},\n", " {'from': 'user',\n", " 'value': 'Could you summarize the meaning of the quote by Albert Schweitzer?'},\n", " {'from': 'assistant',\n", " 'value': 'The quote by Albert Schweitzer, \"Success is not the key to happiness. Happiness is the key to success. If you love what you are doing, you will be successful,\" emphasizes that true success in life comes from finding joy and fulfillment in what you do. Rather than viewing success as a source of happiness, Schweitzer suggests that happiness itself should be the foundation for achieving success. Essentially, when you engage in activities that make you happy and passionate, you\\'re more likely to excel and achieve success in those ventures.'},\n", " {'from': 'user',\n", " 'value': \"Can you dig up some juicy details about the zip code 10001? I'm doing a mail-order flamingo business plan, don't ask why.\"},\n", " {'from': 'assistant',\n", " 'value': '[Get Zip Code Information(country=\"us\", postal_code=\"10001\")]'},\n", " {'from': 'tool',\n", " 'value': '[{\"name\": \"Get Zip Code Information\", \"results\": {\"information\": \"Zip code information for 10001, USA\", \"latitude\": 40.748817, \"longitude\": -73.985428, \"city\": \"New York\", \"state\": \"NY\", \"county\": \"New York\"}}]'},\n", " {'from': 'assistant',\n", " 'value': \"Here's the detailed information about the zip code 10001, which will be helpful for your mail-order flamingo business plan:\\n\\n**Zip Code Information for 10001, USA:**\\n- **City:** New York\\n- **State:** NY (New York)\\n- **County:** New York\\n- **Latitude:** 40.748817\\n- **Longitude:** -73.985428\\n\\nThis data provides a clear overview of where the zip code is located and its associated geographic details. If you need more assistance or information on any other aspect of your business plan, feel free to ask!\"}]]}" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "d['train'][0:2]" ] }, { "cell_type": "code", "execution_count": 12, "id": "ce0b21d3-9e73-41a4-b181-bda342395243", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "dict_keys(['system', 'conversations'])" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "d['train'][123].keys()" ] }, { "cell_type": "code", "execution_count": 13, "id": "c88547cc-96e5-4054-9121-d5dcd8189fbe", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'system': 'You are an expert in composing functions. You are given a question and a set of possible functions. \\nBased on the question, you will need to make one or more function/tool calls to achieve the purpose. \\nIf none of the function can be used, point it out. If the given question lacks the parameters required by the function,\\nalso point it out. You should only return the function call in tools call sections.\\nHere is a list of functions in JSON format that you can invoke:\\n[{\"name\": \"newAddress\", \"description\": \"Generates a new Ethereum address that can be used to send or receive funds. Do not lose the password! We can\\'t restore access to an address if you lose it.\", \"parameters\": {\"type\": \"dict\", \"properties\": {\"password\": {\"description\": \"The password for the new Ethereum address\", \"type\": \"string\"}}, \"required\": [\"password\"]}, \"required\": null}, {\"name\": \"Market Trends API\", \"description\": \"Get the latest market trends and relevant news for a specified country and language.\", \"parameters\": {\"type\": \"dict\", \"properties\": {\"trend_type\": {\"description\": \"Trend type.\", \"type\": \"string\", \"enum\": [\"MARKET_INDEXES\", \"MOST_ACTIVE\", \"GAINERS\", \"LOSERS\", \"CRYPTO\", \"CURRENCIES\", \"CLIMATE_LEADERS\"]}, \"country\": {\"description\": \"The country for which to get trends, specified as a 2-letter country code - see ISO 3166.\", \"type\": \"string\", \"default\": \"us\"}, \"language\": {\"description\": \"The language to use for the results, specified as a 2-letter language code - see ISO 639-1.\", \"type\": \"string\", \"default\": \"en\"}}, \"required\": [\"trend_type\"]}, \"required\": null}, {\"name\": \"Get Futures Prices\", \"description\": \"Retrieve a list of current futures prices for various financial instruments.\", \"parameters\": {\"type\": \"dict\", \"properties\": {\"instrument_type\": {\"description\": \"Type of financial instrument (e.g., commodity, currency, index)\", \"type\": \"string\"}, \"exchange\": {\"description\": \"Name of the exchange (e.g., CME, ICE, NYMEX)\", \"type\": \"string\"}, \"start_string\": {\"description\": \"Start string for the price data (YYYY-MM-DD)\", \"type\": \"string\"}, \"end_string\": {\"description\": \"End string for the price data (YYYY-MM-DD)\", \"type\": \"string\"}}, \"required\": [\"instrument_type\", \"exchange\"]}, \"required\": null}, {\"name\": \"SEC Filings\", \"description\": \"Returns a list of SEC Filings for the requested company, including filing types, strings, and documents.\", \"parameters\": {\"type\": \"dict\", \"properties\": {\"identifier\": {\"description\": \"Publicly traded company\\'s stock symbol or Central Index Key (CIK)\", \"type\": \"string\", \"default\": \"aapl\"}}, \"required\": [\"identifier\"]}, \"required\": null}, {\"name\": \"United States Away from Home Mobility API\", \"description\": \"Retrieve daily data on the percentage change in time spent away from home in the United States, providing insights into the economic impact of the COVID-19 pandemic.\", \"parameters\": {\"type\": \"dict\", \"properties\": {\"string\": {\"description\": \"The string for which to retrieve data (format: YYYY-MM-DD)\", \"type\": \"string\"}, \"state\": {\"description\": \"The state for which to retrieve data (optional, default: all states)\", \"type\": \"string\"}}, \"required\": [\"string\"]}, \"required\": null}, {\"name\": \"Calculate Sales Tax\", \"description\": \"Retrieves the sales tax rate applicable to a specific address. This API accepts address inputs to deliver up-to-string, relevant local sales tax rates instantly.\", \"parameters\": {\"type\": \"dict\", \"properties\": {\"country\": {\"description\": \"Set to one of the country codes listed in Supported Countries.\", \"type\": \"string\", \"default\": \"US\"}, \"city\": {\"description\": \"City name\", \"type\": \"string\", \"default\": \"Meridian\"}, \"zip\": {\"description\": \"Zip code\", \"type\": \"string\", \"default\": \"83646\"}, \"street\": {\"description\": \"Street address\", \"type\": \"string\", \"default\": \"936 Storey Ave\"}}, \"required\": [\"country\"]}, \"required\": null}]. \\nShould you decide to return the function call(s). \\nPut it in the format of [func1(params_name=params_value, params_name2=params_value2...), func2(params)]\\n\\nNO other text MUST be included. \\n',\n", " 'conversations': [{'from': 'user',\n", " 'value': \"I'm considering investing and I'd like to know what's happening in the market right now. Could you get me the top market trends in the US?\"},\n", " {'from': 'assistant',\n", " 'value': '[Market Trends API(trend_type=\"MARKET_INDEXES\", country=\"us\")]'},\n", " {'from': 'tool',\n", " 'value': '[{\"name\": \"Market Trends API\", \"results\": {\"trends\": [{\"name\": \"S&P 500\", \"description\": \"Standard & Poor\\'s 500 Index is a market-capitalization-weighted index of the 500 largest U.S. publicly traded companies.\", \"data\": {\"current_value\": \"4172.80\", \"percentage_change\": \"+0.68%\"}}, {\"name\": \"DOW J\", \"description\": \"Dow Jones Industrial Average is a price-weighted average of 30 blue-chip stocks that are generally the leaders in their industry.\", \"data\": {\"current_value\": \"34479.60\", \"percentage_change\": \"+0.47%\"}}, {\"name\": \"NASDAQ\", \"description\": \"The NASDAQ Composite is a broad-based capitalization-weighted index of stocks in all three NASDAQ tiers: Global Select, Global Market and Capital Market.\", \"data\": {\"current_value\": \"13691.30\", \"percentage_change\": \"+0.90%\"}}]}}]'},\n", " {'from': 'assistant',\n", " 'value': \"Here are the top Market Trends in the US right now:\\n\\n1. **S&P 500**: The Standard & Poor's 500 Index is a market-capitalization-weighted index of the 500 largest U.S. publicly traded companies. Its current value is 4172.80 with a percentage change of +0.68%.\\n\\n2. **DOW J**: The Dow Jones Industrial Average is a price-weighted average of 30 blue-chip stocks that are generally the leaders in their industry. Its current value is 34479.60 with a percentage change of +0.47%.\\n\\n3. **NASDAQ**: The NASDAQ Composite is a broad-based capitalization-weighted index of stocks in all three NASDAQ tiers: Global Select, Global Market and Capital Market. Its current value is 13691.30 with a percentage change of +0.90%.\\n\\nThis information can help you make informed decisions about your investment plans.\"},\n", " {'from': 'user',\n", " 'value': 'Could you explain what SEC filings are and how they might be useful for an investor like me?'},\n", " {'from': 'assistant',\n", " 'value': \"Sure, SEC filings refer to official documents that are submitted by publicly traded companies to the U.S. Securities and Exchange Commission (SEC). These documents provide valuable information about a company's financial performance, its management team, ownership, key business operations, market competition, and future prospects. They are typically comprehensive and contain detailed information that a company is legally required to disclose to the public.\\n\\nInvestors like you can use these filings to better understand a company's true financial health and operations. Information you might glean from SEC filings includes:\\n\\n1. **Financial Statements**: Balance sheets, income statements, and cash flow statements can help you analyze the financial health and profitability of a company.\\n\\n2. **Management Discussion and Analysis (MD&A)**: This section offers management's perspective on the company's performance, including explanations of financial results, significant changes, market risk exposures, and future operations and strategy.\\n\\n3. **Risk Factors**: In the filing, companies are required to disclose potential risks of investing in their company. Insight into the risks the company is facing can help you make a more informed decision about investing.\\n\\n4. **Major Shareholders**: Companies must disclose the list of major shareholders. High ownership of shares by insiders could indicate confidence in the business, while large institutional ownership could suggest stability.\\n\\n5. **Director and Executive Compensation**: Information on executive remuneration packages can indicate how well the company’s interests are aligned with its executive team.\\n\\nSEC filings are a fundamental part of investment research and due diligence. They can provide deep insights into a company that may not be immediately obvious from simply looking at its earnings or share price. It's essential for investors to understand how to read and interpret these filings to make informed investment decisions.\"},\n", " {'from': 'user',\n", " 'value': 'So, a couple of years ago, I invested in a tech startup without doing any proper research. It seemed like a hot trend at the time, but the company went belly up within a year. I ended up losing a good chunk of money. What are your thoughts on that?'},\n", " {'from': 'assistant',\n", " 'value': \"As an assistant, I'm here to provide advice and guide you in your financial decisions. Here are my thoughts:\\n\\nInvesting in startups or any company without conducting proper research carries high risk. Although some startups have very high growth potentials and can provide excellent returns, many also fail within a few years of operation. This is especially the case in the tech industry where competition is stiff and technology changes rapidly.\\n\\nThat being said, your past experience with the tech startup is an important lesson in the necessity of conducting thorough due diligence before investing. Here are some steps you might take before future investments:\\n\\n1. **Understand the Business**: Make sure you understand the company's business model, its products or services, the market it operates in and its competition.\\n\\n2. **Financial Analysis**: Review financial statements, revenue, profitability, growth rates, debt levels, and cash flow. \\n\\n3. **Management Review**: It's important to assess the quality of the management team and their plans for the company.\\n\\n4. **Use of Tools**: Utilize tools like the SEC Filings tool to retrieve important documents to get detailed information about a company's operations, management and financials.\\n\\n5. **Risk vs Reward**: Analyze the investment's potential returns in light of the potential risk. High-risk investments should have the potential for higher returns.\\n\\nRemember, all investments carry a degree of risk. As such, it can be beneficial to diversify investments to spread risk and not put all of your money into one company or sector. It may also be helpful to seek advice from financial advisors or use trusted financial services to ensure informed decisions.\\n\\nGoing forward, employing these strategies could help reduce risk and maximize potential returns on your investments.\"},\n", " {'from': 'user',\n", " 'value': \"Could you provide me with the SEC filings for Apple? Also, I’m curious about how COVID-19 has affected people's mobility away from home in the US.\"},\n", " {'from': 'assistant',\n", " 'value': '[SEC Filings(identifier=\"AAPL\"), United States Away from Home Mobility API(string=\"2025-05-17\")]'}]}" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "d['train'][0]" ] }, { "cell_type": "code", "execution_count": null, "id": "bc648685-ebdd-40b1-baa8-aa7706e018ad", "metadata": {}, "outputs": [], "source": [ "def generate_unique_id():\n", " return str(uuid.uuid4())" ] }, { "cell_type": "code", "execution_count": null, "id": "deb75bc2-11aa-464f-9c30-e34cd96543ac", "metadata": {}, "outputs": [], "source": [ "def transform_dataset():\n", " # Load the dataset\n", " dataset = load_dataset(\"Team-ACE/ToolACE\")\n", " \n", " transformed_dataset = {}\n", " for split in dataset.keys():\n", " new_examples: Dict[str, Any] = {\n", " 'id': [],\n", " 'conversations': []\n", " }\n", " \n", " # Transform each example\n", " for idx, example in enumerate(dataset[split]):\n", " unique_id = str(uuid.uuid4())\n", " new_conversations = [\n", " {\n", " 'from': 'system',\n", " 'value': example['system']\n", " }\n", " ] + example['conversations']\n", " \n", " new_examples['id'].append(unique_id)\n", " new_examples['conversations'].append(new_conversations)\n", " \n", " transformed_dataset[split] = Dataset.from_dict(new_examples)\n", " \n", " print(\"\\nFirst example in transformed dataset:\")\n", " print(json.dumps({\n", " 'id': transformed_dataset['train'][0]['id'],\n", " 'conversations': transformed_dataset['train'][0]['conversations']\n", " }, indent=2))\n", " \n", " # Save transformed dataset\n", " transformed_dataset['train'].save_to_disk(\"transformed_toolace\")\n", " \n", " return transformed_dataset" ] }, { "cell_type": "code", "execution_count": null, "id": "99ffe0ef-34b6-4369-8f8e-2a7a162e39e5", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "First example in transformed dataset:\n", "{\n", " \"id\": \"565c7d3b-0f48-4097-bcc2-0602897fc23e\",\n", " \"conversations\": [\n", " {\n", " \"from\": \"system\",\n", " \"value\": \"You are an expert in composing functions. You are given a question and a set of possible functions. \\nBased on the question, you will need to make one or more function/tool calls to achieve the purpose. \\nIf none of the function can be used, point it out. If the given question lacks the parameters required by the function,\\nalso point it out. You should only return the function call in tools call sections.\\nHere is a list of functions in JSON format that you can invoke:\\n[{\\\"name\\\": \\\"newAddress\\\", \\\"description\\\": \\\"Generates a new Ethereum address that can be used to send or receive funds. Do not lose the password! We can't restore access to an address if you lose it.\\\", \\\"parameters\\\": {\\\"type\\\": \\\"dict\\\", \\\"properties\\\": {\\\"password\\\": {\\\"description\\\": \\\"The password for the new Ethereum address\\\", \\\"type\\\": \\\"string\\\"}}, \\\"required\\\": [\\\"password\\\"]}, \\\"required\\\": null}, {\\\"name\\\": \\\"Market Trends API\\\", \\\"description\\\": \\\"Get the latest market trends and relevant news for a specified country and language.\\\", \\\"parameters\\\": {\\\"type\\\": \\\"dict\\\", \\\"properties\\\": {\\\"trend_type\\\": {\\\"description\\\": \\\"Trend type.\\\", \\\"type\\\": \\\"string\\\", \\\"enum\\\": [\\\"MARKET_INDEXES\\\", \\\"MOST_ACTIVE\\\", \\\"GAINERS\\\", \\\"LOSERS\\\", \\\"CRYPTO\\\", \\\"CURRENCIES\\\", \\\"CLIMATE_LEADERS\\\"]}, \\\"country\\\": {\\\"description\\\": \\\"The country for which to get trends, specified as a 2-letter country code - see ISO 3166.\\\", \\\"type\\\": \\\"string\\\", \\\"default\\\": \\\"us\\\"}, \\\"language\\\": {\\\"description\\\": \\\"The language to use for the results, specified as a 2-letter language code - see ISO 639-1.\\\", \\\"type\\\": \\\"string\\\", \\\"default\\\": \\\"en\\\"}}, \\\"required\\\": [\\\"trend_type\\\"]}, \\\"required\\\": null}, {\\\"name\\\": \\\"Get Futures Prices\\\", \\\"description\\\": \\\"Retrieve a list of current futures prices for various financial instruments.\\\", \\\"parameters\\\": {\\\"type\\\": \\\"dict\\\", \\\"properties\\\": {\\\"instrument_type\\\": {\\\"description\\\": \\\"Type of financial instrument (e.g., commodity, currency, index)\\\", \\\"type\\\": \\\"string\\\"}, \\\"exchange\\\": {\\\"description\\\": \\\"Name of the exchange (e.g., CME, ICE, NYMEX)\\\", \\\"type\\\": \\\"string\\\"}, \\\"start_string\\\": {\\\"description\\\": \\\"Start string for the price data (YYYY-MM-DD)\\\", \\\"type\\\": \\\"string\\\"}, \\\"end_string\\\": {\\\"description\\\": \\\"End string for the price data (YYYY-MM-DD)\\\", \\\"type\\\": \\\"string\\\"}}, \\\"required\\\": [\\\"instrument_type\\\", \\\"exchange\\\"]}, \\\"required\\\": null}, {\\\"name\\\": \\\"SEC Filings\\\", \\\"description\\\": \\\"Returns a list of SEC Filings for the requested company, including filing types, strings, and documents.\\\", \\\"parameters\\\": {\\\"type\\\": \\\"dict\\\", \\\"properties\\\": {\\\"identifier\\\": {\\\"description\\\": \\\"Publicly traded company's stock symbol or Central Index Key (CIK)\\\", \\\"type\\\": \\\"string\\\", \\\"default\\\": \\\"aapl\\\"}}, \\\"required\\\": [\\\"identifier\\\"]}, \\\"required\\\": null}, {\\\"name\\\": \\\"United States Away from Home Mobility API\\\", \\\"description\\\": \\\"Retrieve daily data on the percentage change in time spent away from home in the United States, providing insights into the economic impact of the COVID-19 pandemic.\\\", \\\"parameters\\\": {\\\"type\\\": \\\"dict\\\", \\\"properties\\\": {\\\"string\\\": {\\\"description\\\": \\\"The string for which to retrieve data (format: YYYY-MM-DD)\\\", \\\"type\\\": \\\"string\\\"}, \\\"state\\\": {\\\"description\\\": \\\"The state for which to retrieve data (optional, default: all states)\\\", \\\"type\\\": \\\"string\\\"}}, \\\"required\\\": [\\\"string\\\"]}, \\\"required\\\": null}, {\\\"name\\\": \\\"Calculate Sales Tax\\\", \\\"description\\\": \\\"Retrieves the sales tax rate applicable to a specific address. This API accepts address inputs to deliver up-to-string, relevant local sales tax rates instantly.\\\", \\\"parameters\\\": {\\\"type\\\": \\\"dict\\\", \\\"properties\\\": {\\\"country\\\": {\\\"description\\\": \\\"Set to one of the country codes listed in Supported Countries.\\\", \\\"type\\\": \\\"string\\\", \\\"default\\\": \\\"US\\\"}, \\\"city\\\": {\\\"description\\\": \\\"City name\\\", \\\"type\\\": \\\"string\\\", \\\"default\\\": \\\"Meridian\\\"}, \\\"zip\\\": {\\\"description\\\": \\\"Zip code\\\", \\\"type\\\": \\\"string\\\", \\\"default\\\": \\\"83646\\\"}, \\\"street\\\": {\\\"description\\\": \\\"Street address\\\", \\\"type\\\": \\\"string\\\", \\\"default\\\": \\\"936 Storey Ave\\\"}}, \\\"required\\\": [\\\"country\\\"]}, \\\"required\\\": null}]. \\nShould you decide to return the function call(s). \\nPut it in the format of [func1(params_name=params_value, params_name2=params_value2...), func2(params)]\\n\\nNO other text MUST be included. \\n\"\n", " },\n", " {\n", " \"from\": \"user\",\n", " \"value\": \"I'm considering investing and I'd like to know what's happening in the market right now. Could you get me the top market trends in the US?\"\n", " },\n", " {\n", " \"from\": \"assistant\",\n", " \"value\": \"[Market Trends API(trend_type=\\\"MARKET_INDEXES\\\", country=\\\"us\\\")]\"\n", " },\n", " {\n", " \"from\": \"tool\",\n", " \"value\": \"[{\\\"name\\\": \\\"Market Trends API\\\", \\\"results\\\": {\\\"trends\\\": [{\\\"name\\\": \\\"S&P 500\\\", \\\"description\\\": \\\"Standard & Poor's 500 Index is a market-capitalization-weighted index of the 500 largest U.S. publicly traded companies.\\\", \\\"data\\\": {\\\"current_value\\\": \\\"4172.80\\\", \\\"percentage_change\\\": \\\"+0.68%\\\"}}, {\\\"name\\\": \\\"DOW J\\\", \\\"description\\\": \\\"Dow Jones Industrial Average is a price-weighted average of 30 blue-chip stocks that are generally the leaders in their industry.\\\", \\\"data\\\": {\\\"current_value\\\": \\\"34479.60\\\", \\\"percentage_change\\\": \\\"+0.47%\\\"}}, {\\\"name\\\": \\\"NASDAQ\\\", \\\"description\\\": \\\"The NASDAQ Composite is a broad-based capitalization-weighted index of stocks in all three NASDAQ tiers: Global Select, Global Market and Capital Market.\\\", \\\"data\\\": {\\\"current_value\\\": \\\"13691.30\\\", \\\"percentage_change\\\": \\\"+0.90%\\\"}}]}}]\"\n", " },\n", " {\n", " \"from\": \"assistant\",\n", " \"value\": \"Here are the top Market Trends in the US right now:\\n\\n1. **S&P 500**: The Standard & Poor's 500 Index is a market-capitalization-weighted index of the 500 largest U.S. publicly traded companies. Its current value is 4172.80 with a percentage change of +0.68%.\\n\\n2. **DOW J**: The Dow Jones Industrial Average is a price-weighted average of 30 blue-chip stocks that are generally the leaders in their industry. Its current value is 34479.60 with a percentage change of +0.47%.\\n\\n3. **NASDAQ**: The NASDAQ Composite is a broad-based capitalization-weighted index of stocks in all three NASDAQ tiers: Global Select, Global Market and Capital Market. Its current value is 13691.30 with a percentage change of +0.90%.\\n\\nThis information can help you make informed decisions about your investment plans.\"\n", " },\n", " {\n", " \"from\": \"user\",\n", " \"value\": \"Could you explain what SEC filings are and how they might be useful for an investor like me?\"\n", " },\n", " {\n", " \"from\": \"assistant\",\n", " \"value\": \"Sure, SEC filings refer to official documents that are submitted by publicly traded companies to the U.S. Securities and Exchange Commission (SEC). These documents provide valuable information about a company's financial performance, its management team, ownership, key business operations, market competition, and future prospects. They are typically comprehensive and contain detailed information that a company is legally required to disclose to the public.\\n\\nInvestors like you can use these filings to better understand a company's true financial health and operations. Information you might glean from SEC filings includes:\\n\\n1. **Financial Statements**: Balance sheets, income statements, and cash flow statements can help you analyze the financial health and profitability of a company.\\n\\n2. **Management Discussion and Analysis (MD&A)**: This section offers management's perspective on the company's performance, including explanations of financial results, significant changes, market risk exposures, and future operations and strategy.\\n\\n3. **Risk Factors**: In the filing, companies are required to disclose potential risks of investing in their company. Insight into the risks the company is facing can help you make a more informed decision about investing.\\n\\n4. **Major Shareholders**: Companies must disclose the list of major shareholders. High ownership of shares by insiders could indicate confidence in the business, while large institutional ownership could suggest stability.\\n\\n5. **Director and Executive Compensation**: Information on executive remuneration packages can indicate how well the company\\u2019s interests are aligned with its executive team.\\n\\nSEC filings are a fundamental part of investment research and due diligence. They can provide deep insights into a company that may not be immediately obvious from simply looking at its earnings or share price. It's essential for investors to understand how to read and interpret these filings to make informed investment decisions.\"\n", " },\n", " {\n", " \"from\": \"user\",\n", " \"value\": \"So, a couple of years ago, I invested in a tech startup without doing any proper research. It seemed like a hot trend at the time, but the company went belly up within a year. I ended up losing a good chunk of money. What are your thoughts on that?\"\n", " },\n", " {\n", " \"from\": \"assistant\",\n", " \"value\": \"As an assistant, I'm here to provide advice and guide you in your financial decisions. Here are my thoughts:\\n\\nInvesting in startups or any company without conducting proper research carries high risk. Although some startups have very high growth potentials and can provide excellent returns, many also fail within a few years of operation. This is especially the case in the tech industry where competition is stiff and technology changes rapidly.\\n\\nThat being said, your past experience with the tech startup is an important lesson in the necessity of conducting thorough due diligence before investing. Here are some steps you might take before future investments:\\n\\n1. **Understand the Business**: Make sure you understand the company's business model, its products or services, the market it operates in and its competition.\\n\\n2. **Financial Analysis**: Review financial statements, revenue, profitability, growth rates, debt levels, and cash flow. \\n\\n3. **Management Review**: It's important to assess the quality of the management team and their plans for the company.\\n\\n4. **Use of Tools**: Utilize tools like the SEC Filings tool to retrieve important documents to get detailed information about a company's operations, management and financials.\\n\\n5. **Risk vs Reward**: Analyze the investment's potential returns in light of the potential risk. High-risk investments should have the potential for higher returns.\\n\\nRemember, all investments carry a degree of risk. As such, it can be beneficial to diversify investments to spread risk and not put all of your money into one company or sector. It may also be helpful to seek advice from financial advisors or use trusted financial services to ensure informed decisions.\\n\\nGoing forward, employing these strategies could help reduce risk and maximize potential returns on your investments.\"\n", " },\n", " {\n", " \"from\": \"user\",\n", " \"value\": \"Could you provide me with the SEC filings for Apple? Also, I\\u2019m curious about how COVID-19 has affected people's mobility away from home in the US.\"\n", " },\n", " {\n", " \"from\": \"assistant\",\n", " \"value\": \"[SEC Filings(identifier=\\\"AAPL\\\"), United States Away from Home Mobility API(string=\\\"2025-05-17\\\")]\"\n", " }\n", " ]\n", "}\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "559ba9105ea2459e93e007974de43eb3", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Saving the dataset (0/1 shards): 0%| | 0/11300 [00:00