diff --git a/Makefile b/Makefile index 24f51b4..25424ef 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: setup env install lint test test-slow test-all clean +.PHONY: setup env install lint test test-slow test-all clean update-intro update-clean-intro clear-clean-intro ENV_NAME=tapeagents PYTHON_VERSION=3.10 @@ -37,5 +37,8 @@ update-intro: cp examples/intro_clean.ipynb intro.ipynb $(CONDA) run --name ${ENV_NAME} jupyter execute --inplace intro.ipynb -clean-intro: +update-clean-intro: $(CONDA) run --name ${ENV_NAME} jupyter nbconvert intro.ipynb --output=examples/intro_clean.ipynb --to notebook --ClearOutputPreprocessor.enabled=True --ClearMetadataPreprocessor.enabled=True + +clear-clean-intro: + $(CONDA) run --name ${ENV_NAME} jupyter nbconvert --inplace examples/intro_clean.ipynb --ClearOutputPreprocessor.enabled=True --ClearMetadataPreprocessor.enabled=True diff --git a/conf/tapeagent/llm/local_llama3_70b.yaml b/conf/tapeagent/llm/local_llama3_70b.yaml index 9f53c1d..0e3c3a7 100644 --- a/conf/tapeagent/llm/local_llama3_70b.yaml +++ b/conf/tapeagent/llm/local_llama3_70b.yaml @@ -1,7 +1,7 @@ -_target_: tapeagents.llms.LLAMA +_target_: tapeagents.llms.TrainableLLM use_cache: false conf: - _target_: tapeagents.llms.LLAMAConfig + _target_: tapeagents.llms.TrainableLLMConfig base_url: http://0.0.0.0:8080 model_name: meta-llama/Meta-Llama-3-70B-Instruct context_size: 8000 diff --git a/conf/tapeagent/llm/local_llama3_8b.yaml b/conf/tapeagent/llm/local_llama3_8b.yaml index 4f6fa89..4ffab7c 100644 --- a/conf/tapeagent/llm/local_llama3_8b.yaml +++ b/conf/tapeagent/llm/local_llama3_8b.yaml @@ -1,7 +1,7 @@ -_target_: tapeagents.llms.LLAMA +_target_: tapeagents.llms.TrainableLLM use_cache: false conf: - _target_: tapeagents.llms.LLAMAConfig + _target_: tapeagents.llms.TrainableLLMConfig base_url: http://0.0.0.0:8080 model_name: meta-llama/Meta-Llama-3-8B-Instruct context_size: 8000 diff --git a/conf/tapeagent/llm/local_mixtral_8x22b.yaml b/conf/tapeagent/llm/local_mixtral_8x22b.yaml index 5158046..039bb3f 100644 --- a/conf/tapeagent/llm/local_mixtral_8x22b.yaml +++ b/conf/tapeagent/llm/local_mixtral_8x22b.yaml @@ -1,7 +1,7 @@ -_target_: tapeagents.llms.LLAMA +_target_: tapeagents.llms.TrainableLLM use_cache: false conf: - _target_: tapeagents.llms.LLAMAConfig + _target_: tapeagents.llms.TrainableLLMConfig base_url: http://0.0.0.0:8080 model_name: mistralai/Mixtral-8x22B-v0.1 context_size: 8000 diff --git a/example.env b/example.env new file mode 100644 index 0000000..4de6d37 --- /dev/null +++ b/example.env @@ -0,0 +1,8 @@ +# 1. Copy this file to your .env file that is gitignored to keep your keys safe +# 2. In your .env only, uncomment and fill the following lines with your keys + +# OPENAI_API_KEY="" # put your https://platform.openai.com/ key here +# OPENAI_ORGANIZATION="" # optional if you use your personal key + +# TOGETHER_API_KEY="" +# HF_TOKEN="" diff --git a/examples/agent.py b/examples/agent.py index 14163dd..4081b05 100644 --- a/examples/agent.py +++ b/examples/agent.py @@ -3,7 +3,7 @@ from tapeagents.agent import Agent, Node from tapeagents.core import SetNextNode, Prompt, Tape from tapeagents.dialog_tape import AssistantStep, AssistantThought, DialogTape, UserStep -from tapeagents.llms import LLAMA, LLM, LLMStream +from tapeagents.llms import TrainableLLM, LLM, LLMStream def hello_world(llm: LLM): @@ -92,7 +92,7 @@ def generate_steps(self, agent, tape: Tape, llm_stream: LLMStream): if __name__ == "__main__": - llm = LLAMA( + llm = TrainableLLM( base_url="https://api.together.xyz", model_name="meta-llama/Meta-Llama-3-70B-Instruct-Turbo", tokenizer_name="meta-llama/Meta-Llama-3-70B-Instruct", diff --git a/examples/batch_add_observations.py b/examples/batch_add_observations.py index f802e78..1280416 100644 --- a/examples/batch_add_observations.py +++ b/examples/batch_add_observations.py @@ -4,7 +4,7 @@ from tapeagents.batch import ObsLayerConfig, batch_add_observations from tapeagents.dialog_tape import AssistantStep, DialogTape, SystemStep, UserStep from tapeagents.io import save_tapes -from tapeagents.llms import LLAMA, LLM +from tapeagents.llms import TrainableLLM, LLM from .llama_user import LLAMAUserModel @@ -40,7 +40,7 @@ def try_batch_add_observations(llm: LLM): if __name__ == "__main__": try_batch_add_observations( - LLAMA( + TrainableLLM( base_url="https://api.together.xyz", model_name="meta-llama/Llama-3-8b-chat-hf", parameters=dict(temperature=0.7, max_tokens=512), diff --git a/examples/batch_main_loop.py b/examples/batch_main_loop.py index 4ab0891..3a6d81a 100644 --- a/examples/batch_main_loop.py +++ b/examples/batch_main_loop.py @@ -5,7 +5,7 @@ from tapeagents.dialog_tape import DialogTape, SystemStep, UserStep from tapeagents.environment import EmptyEnvironment from tapeagents.io import save_tapes -from tapeagents.llms import LLAMA, LLM +from tapeagents.llms import TrainableLLM, LLM from .llama_agent import LLAMAChatBot @@ -33,7 +33,7 @@ def try_batch_main_loop(llm: LLM): if __name__ == "__main__": try_batch_main_loop( - LLAMA( + TrainableLLM( base_url="https://api.together.xyz", model_name="meta-llama/Llama-3-8b-chat-hf", parameters=dict(temperature=0.7, max_tokens=512), diff --git a/examples/chat.py b/examples/chat.py index a068dc4..e0970ae 100644 --- a/examples/chat.py +++ b/examples/chat.py @@ -2,7 +2,7 @@ from tapeagents.team import TeamAgent, TeamTape from tapeagents.studio import Studio -from tapeagents.llms import LLAMA, LLM +from tapeagents.llms import TrainableLLM, LLM from tapeagents.rendering import PrettyRenderer @@ -26,7 +26,7 @@ def try_chat(llm: LLM, studio: bool): if __name__ == "__main__": - llm = LLAMA( + llm = TrainableLLM( base_url="https://api.together.xyz", model_name="meta-llama/Meta-Llama-3-70B-Instruct-Turbo", parameters=dict(temperature=0.7, max_tokens=512), diff --git a/examples/continue_tapes.py b/examples/continue_tapes.py index 9d33ed6..d2b5b37 100644 --- a/examples/continue_tapes.py +++ b/examples/continue_tapes.py @@ -4,7 +4,7 @@ from tapeagents.batch import generate_tapes from tapeagents.dialog_tape import AssistantStep, DialogTape, SystemStep, UserStep from tapeagents.environment import EmptyEnvironment -from tapeagents.llms import LLAMA, LLM +from tapeagents.llms import TrainableLLM, LLM from .llama_agent import LLAMAChatBot from .llama_user import LLAMAUserModel @@ -48,7 +48,7 @@ def try_continue_tapes(llm: LLM): if __name__ == "__main__": try_continue_tapes( - LLAMA( + TrainableLLM( base_url="https://api.together.xyz", model_name="meta-llama/Llama-3-8b-chat-hf", parameters=dict(temperature=0.7, max_tokens=512), diff --git a/examples/delegate.py b/examples/delegate.py index ff73ca6..758576f 100644 --- a/examples/delegate.py +++ b/examples/delegate.py @@ -4,7 +4,7 @@ from tapeagents.agent import Agent, AgentEvent from tapeagents.core import Action, Prompt, Tape, Thought -from tapeagents.llms import LLAMA, LLM, LLMStream +from tapeagents.llms import TrainableLLM, LLM, LLMStream logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s") @@ -86,7 +86,7 @@ def delegate(self, tape: ExampleTape) -> Agent[ExampleTape]: raise ValueError(f"Invalid state {state}") -def try_delegation(llama: LLAMA): +def try_delegation(llama: TrainableLLM): tape = ExampleTape(context=EXAMPLE_TEXT) with open("start_tape.json", "w") as f: json.dump(tape.model_dump(), f, indent=2) @@ -104,7 +104,7 @@ def try_delegation(llama: LLAMA): if __name__ == "__main__": try_delegation( - LLAMA( + TrainableLLM( base_url="https://api.together.xyz", model_name="meta-llama/Meta-Llama-3-70B-Instruct-Turbo", parameters=dict(temperature=0.7, max_tokens=512), diff --git a/examples/delegate_stack.py b/examples/delegate_stack.py index bc7c1df..2c623dc 100644 --- a/examples/delegate_stack.py +++ b/examples/delegate_stack.py @@ -14,7 +14,7 @@ Tape, Thought, ) -from tapeagents.llms import LLAMA, LLM, LLMStream +from tapeagents.llms import TrainableLLM, LLM, LLMStream from tapeagents.view import Call, Respond, TapeViewStack EXAMPLE_TEXT = """I am a text with some verbs like running, jumping, and swimming.""" @@ -224,7 +224,7 @@ def make_analyze_text_chain(llm: LLM): def main(): - llama = LLAMA( + llama = TrainableLLM( base_url="https://api.together.xyz", model_name="meta-llama/Meta-Llama-3-70B-Instruct-Turbo", tokenizer_name="meta-llama/Meta-Llama-3-70B-Instruct", diff --git a/examples/gsm8k_tuning/eval.ipynb b/examples/gsm8k_tuning/eval.ipynb index 68b9659..6b8560f 100644 --- a/examples/gsm8k_tuning/eval.ipynb +++ b/examples/gsm8k_tuning/eval.ipynb @@ -19,7 +19,7 @@ "from termcolor import colored\n", "from tqdm import tqdm\n", "\n", - "from tapeagents.llms import LLAMA\n" + "from tapeagents.llms import TrainableLLM\n" ] }, { @@ -90,7 +90,7 @@ "# run inference: vllm serve meta-llama/Meta-Llama-3.1-8B-Instruct\n", "untuned_agent = MathAgent(\n", " llms={\n", - " \"default\": LLAMA(\n", + " \"default\": TrainableLLM(\n", " base_url=\"http://localhost:8000\",\n", " model_name=\"meta-llama/Meta-Llama-3.1-8B-Instruct\",\n", " tokenizer_name=\"meta-llama/Meta-Llama-3.1-8B-Instruct\",\n", @@ -415,7 +415,7 @@ "# run inference: vllm serve gsm8k/tuning/llama31_70b_train_t02/tune1/intermediate/800/\n", "tuned_agent = MathAgent(\n", " llms={\n", - " \"default\": LLAMA(\n", + " \"default\": TrainableLLM(\n", " base_url=\"http://localhost:8000\",\n", " model_name=\"gsm8k/tuning/llama31_70b_train_t02/tune1/intermediate/800/\",\n", " tokenizer_name=\"meta-llama/Meta-Llama-3.1-8B-Instruct\",\n", @@ -731,7 +731,7 @@ "outputs": [], "source": [ "# check teacher model\n", - "big_llm = LLAMA(\n", + "big_llm = TrainableLLM(\n", " base_url=\"https://api.together.xyz\",\n", " model_name=\"meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo\",\n", " tokenizer_name=\"meta-llama/Meta-Llama-3.1-70B-Instruct\",\n", diff --git a/examples/gsm8k_tuning/finetune.ipynb b/examples/gsm8k_tuning/finetune.ipynb index 09356ec..bec9e6a 100644 --- a/examples/gsm8k_tuning/finetune.ipynb +++ b/examples/gsm8k_tuning/finetune.ipynb @@ -20,7 +20,7 @@ "\n", "from tapeagents.core import TrainingText\n", "from math_agent import ActionExecutionFailure, MathAgent, MathTape\n", - "from tapeagents.llms import LLAMA\n" + "from tapeagents.llms import TrainableLLM\n" ] }, { @@ -32,7 +32,7 @@ "# We need the agent to cut tapes into training samples\n", "agent = MathAgent(\n", " llms={\n", - " \"default\": LLAMA(\n", + " \"default\": TrainableLLM(\n", " base_url=\"https://api.together.xyz\",\n", " model_name=\"meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo\",\n", " tokenizer_name=\"meta-llama/Meta-Llama-3.1-8B-Instruct\",\n", diff --git a/examples/gsm8k_tuning/produce_tapes.ipynb b/examples/gsm8k_tuning/produce_tapes.ipynb index 4a1a9a4..053213b 100644 --- a/examples/gsm8k_tuning/produce_tapes.ipynb +++ b/examples/gsm8k_tuning/produce_tapes.ipynb @@ -20,7 +20,7 @@ "from termcolor import colored\n", "from tqdm import tqdm\n", "\n", - "from tapeagents.llms import LLAMA\n" + "from tapeagents.llms import TrainableLLM\n" ] }, { @@ -52,7 +52,7 @@ "np.random.seed(42)\n", "np.random.shuffle(samples) # type: ignore\n", "\n", - "llm = LLAMA(\n", + "llm = TrainableLLM(\n", " base_url=\"https://api.together.xyz\",\n", " model_name=\"meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo\",\n", " tokenizer_name=\"meta-llama/Meta-Llama-3.1-70B-Instruct\",\n", diff --git a/examples/intro_clean.ipynb b/examples/intro_clean.ipynb index 50d2c4d..7c760d1 100644 --- a/examples/intro_clean.ipynb +++ b/examples/intro_clean.ipynb @@ -4,7 +4,13 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Welcome to TapeAgents!\n", + "# Welcome to TapeAgents!" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ "\n", "**TapeAgents** is a framework to build, debug, serve and optimize your AI agent. It takes a holistic view of the agent lifecycle and aims to support you at all stages. The main distinguishing feature of the framework is that by design a **TapeAgent** creates its \n", "**Tape**: a compherensive semantic log of the agent's session that greatly facilitates audit, debugging, finetuning, agent optimization, etc.\n", @@ -29,7 +35,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# 0. Setup" + "# 0. Setup your TapeAgents environment" ] }, { @@ -43,35 +49,20 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "#### 0. Install conda\n", - "https://conda.io/projects/conda/en/latest/user-guide/install/index.html" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### 1. All commands assume execution from the tapeagents directory.\n", + "#### 0.1. Install conda\n", + "https://conda.io/projects/conda/en/latest/user-guide/install/index.html\n", + "\n", + "#### 0.2. All commands assume execution from the tapeagents directory.\n", "```bash\n", "cd tapeagents/\n", - "```" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### 2. Create conda environment and install `tapeagents` and its dependencies:\n", + "```\n", + "\n", + "#### 0.3. Create a conda environment named `tapeagents`, install `tapeagents` in editable mode and its dependencies:\n", "```bash\n", "make setup\n", - "```" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### 3. Set Jupyter Notebook kernel to your newly created `tapeagents` conda environment\n", + "```\n", + "\n", + "#### 0.4 Set Jupyter Notebook kernel to your newly created `tapeagents` conda environment\n", "https://code.visualstudio.com/docs/datascience/jupyter-notebooks#_create-or-open-a-jupyter-notebook" ] }, @@ -79,7 +70,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "#### 4. Set your LLM API keys and other minor things" + "#### 0.5. Set some configurations" ] }, { @@ -90,39 +81,43 @@ "source": [ "import os\n", "\n", - "# os.environ[\"OPENAI_API_KEY\"] = \"\" # put your https://platform.openai.com/ key here\n", - "# os.environ[\"OPENAI_ORGANIZATION\"] = \"\" # optional if you use your personal key\n", - "# os.environ[\"TOGETHER_API_KEY\"] = \"\" # put your https://together.ai/ key here\n", - "# os.environ[\"TAPEAGENTS_LLM_TOKEN\"] = os.environ[\"TOGETHER_API_KEY\"] # Use Together API Key for llms.LLAMA\n", - "# os.environ[\"HF_TOKEN\"] = \"\" # put your huggingface token here\n", - "\n", "os.environ[\"TRANSFORMERS_NO_ADVISORY_WARNINGS\"] = \"1\"\n", - "today = \"2024-09-17\" # fixed date for reproducible tests" + "today = \"2024-09-17\" # fixed date for reproducible tests" ] }, { - "cell_type": "code", - "execution_count": null, + "cell_type": "markdown", "metadata": {}, - "outputs": [], "source": [ - "# Login to Hugging Face Hub\n", - "if \"PYTEST_CURRENT_TEST\" not in os.environ: # skip login during tests\n", - " from huggingface_hub import login\n", - " login(token=os.environ.get(\"HF_TOKEN\"))" + "#### 0.6. Set your LLM API keys" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "#### 5. Access Hugging Face Gated Models\n", - "Make sure you have access to each model we are going to use (read more [here](https://huggingface.co/docs/hub/en/models-gated#access-gated-models-as-a-user)):\n", - "- https://huggingface.co/meta-llama/Meta-Llama-3-70B-Instruct\n", + "Set environement variable in a `.env` file at the root of `TapeAgents` repository or set them below\n", "\n", - "##### Troubleshoot\n", - "- If you receive a 401 error, it means the authentication failed.\n", - "- If you receive a 403 error, it means you are authenticated but not authorized to access the specific model.\n" + "```bash\n", + "# .env file\n", + "OPENAI_API_KEY=\"\" # put your https://platform.openai.com/ key here\n", + "# OPENAI_ORGANIZATION=\"\" # optional if you use your personal key\n", + "```" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import dotenv\n", + "\n", + "env_file = \".env\"\n", + "dotenv.load_dotenv(env_file, override=True)\n", + "\n", + "# os.environ[\"OPENAI_API_KEY\"] = \"\"\n", + "# os.environ[\"OPENAI_ORGANIZATION\"] = \"\" # optional if you use your personal key" ] }, { @@ -148,28 +143,27 @@ "outputs": [], "source": [ "from tapeagents.agent import Agent, Node\n", - "from tapeagents.core import SetNextNode, Prompt\n", - "from tapeagents.dialog_tape import AssistantStep, DialogTape, UserStep\n", + "from tapeagents.core import Prompt, SetNextNode\n", + "from tapeagents.dialog_tape import AssistantStep, UserStep, DialogTape\n", "from tapeagents.llms import LLMStream, LiteLLM\n", "from tapeagents.prompting import tape_to_messages\n", "\n", - "llm = LiteLLM(model_name=\"gpt-4o-mini-2024-07-18\")\n", + "llm = LiteLLM(model_name=\"gpt-4o-mini\")\n", "\n", "\n", - "def make_prompt(agent: Agent, tape: DialogTape) -> Prompt:\n", - " return Prompt(messages=tape_to_messages(tape))\n", + "class MainNode(Node):\n", + " def make_prompt(self, agent: Agent, tape: DialogTape) -> Prompt:\n", + " return Prompt(messages=tape_to_messages(tape))\n", "\n", + " def generate_steps(self, agent: Agent, tape: DialogTape, llm_stream: LLMStream):\n", + " \"\"\"\n", + " llm_stream contains the text of the LLM model response\n", + " \"\"\"\n", + " yield AssistantStep(content=llm_stream.get_text())\n", + " yield SetNextNode(next_node=0) # Which node to execute next, more on that later\n", "\n", - "def generate_steps(agent: Agent, tape: DialogTape, llm_stream: LLMStream):\n", - " \"\"\"\n", - " llm_stream contains the text of the LLM model response\n", - " \"\"\"\n", - " yield AssistantStep(content=llm_stream.get_text())\n", - " yield SetNextNode(next_node=0) # Which node to execute next, more on that later\n", "\n", - "\n", - "node = Node().with_prompt(make_prompt).with_generate_steps(generate_steps)\n", - "nodes = [node]\n", + "nodes = [MainNode()]\n", "agent = Agent[DialogTape].create(llm, nodes=nodes)\n", "start_tape = DialogTape(steps=[UserStep(content=\"Tell me about Vulcan in 3 sentences\")])\n", "final_tape = agent.run(start_tape).get_final_tape()\n", @@ -202,7 +196,7 @@ "# specifying different Context and Step types. In the output of this cell,\n", "# look at Union[UserStep, AssistantStep, ...]\n", "# for the list of possible step types in the DialogTape.\n", - "DialogTape\n" + "DialogTape" ] }, { @@ -235,14 +229,14 @@ "# Almost all classes in TapeAgents are Pydantic base models.\n", "# This allows easy validation, serialization and instrospection. For example,\n", "# here we are able to list all the fields in the Prompt model.\n", - "Prompt.model_fields\n" + "Prompt.model_fields" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "The LLMs in TapeAgent take `Prompt` and return an `LLMStream` object. The `LLMStream` object can be used both to fast-forward to the complete response text and to stream partial outputs step by step. " + "The LLMs in TapeAgent take `Prompt` and return an `LLMStream` object. The `LLMStream` object can be used both to fast-forward to the complete response text and to stream partial outputs step by step." ] }, { @@ -251,24 +245,18 @@ "metadata": {}, "outputs": [], "source": [ - "from tapeagents.llms import LLAMA\n", + "llm_stream = LiteLLM(model_name=\"gpt-4o-mini-2024-07-18\", stream=True)\n", "\n", - "llama = LLAMA(\n", - " base_url=\"https://api.together.xyz\",\n", - " model_name=\"meta-llama/Meta-Llama-3-70B-Instruct-Turbo\",\n", - " tokenizer_name=\"meta-llama/Meta-Llama-3-70B-Instruct\",\n", - " # you must use stream=True if you wish to have message chunks in your LLM events\n", - " stream=True,\n", - ")\n", "# Streaming\n", "prompt = Prompt(messages=[{\"role\": \"user\", \"content\": \"Write hello world in Java\"}])\n", - "for event in llama.generate(prompt):\n", + "for event in llm_stream.generate(prompt):\n", " print(event.chunk, end=\"\")\n", + "\n", "# No streaming\n", "# (note: you can not use Prompt object for more than 1 LLM call in TapeAgents)\n", "prompt = Prompt(messages=[{\"role\": \"user\", \"content\": \"Write hello world in C\"}])\n", "print(\"\\n\" + \"-\" * 30)\n", - "print(llama.generate(prompt).get_text())\n" + "print(llm_stream.generate(prompt).get_text())" ] }, { @@ -286,7 +274,7 @@ "source": [ "print((user := UserStep(content=\"hi AI!\")).llm_dict())\n", "print((assistant := AssistantStep(content=\"hello human\")).llm_dict())\n", - "print(tape_to_messages(DialogTape(steps=[user, assistant])))\n" + "print(tape_to_messages(DialogTape(steps=[user, assistant])))" ] }, { @@ -303,7 +291,13 @@ "outputs": [], "source": [ "from tapeagents.core import LLMOutput\n", + "from tapeagents.llms import TrainableLLM\n", "\n", + "trainable_llm = TrainableLLM(\n", + " base_url=\"\", # we only use the tokenizer from the model here, no need for a base_url for inference\n", + " model_name=\"microsoft/Phi-3.5-MoE-instruct\",\n", + " tokenizer_name=\"microsoft/Phi-3.5-MoE-instruct\",\n", + ")\n", "\n", "simple_tape = DialogTape(\n", " steps=[\n", @@ -311,13 +305,14 @@ " AssistantStep(content=\"Sure! Let me say bla bla bla foo foo\"),\n", " ]\n", ")\n", + "\n", "prompt = Prompt(messages=tape_to_messages(simple_tape[:1]))\n", "output = agent.make_llm_output(simple_tape, index=1)\n", - "text = llama.make_training_text(prompt=prompt, output=output)\n", + "text = trainable_llm.make_training_text(prompt=prompt, output=output)\n", "print(\"--- ALL TEXT ---\")\n", "print(text.text)\n", "print(\"--- PREDICTED CHARACTERS ---\")\n", - "print(text.output_text)\n" + "print(text.output_text)" ] }, { @@ -331,7 +326,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "A node represents an uninterruptible atom of TapeAgent's computation. When TapeAgents runs a node, it uses its two main functions: `make_prompt` to create LLM Prompt from the tape and `generate_steps` to create new steps from the LLM output. To build a node, you can replace the default implementations of these functions using `with_prompt` and `with_generate_steps` methods. Or you can subclass `Node` and override these functions. Note that `generate_steps` must be a generator, a design choice we made to make TapeAgents a streaming-friendly framework. \n", + "A node represents an uninterruptible atom of TapeAgent's computation. When TapeAgents runs a node, it uses its two main functions: `make_prompt` to create LLM Prompt from the tape and `generate_steps` to create new steps from the LLM output. To build a node, you can subclass `Node` and override these functions. Note that `generate_steps` must be a generator, a design choice we made to make TapeAgents a streaming-friendly framework. \n", "\n", "Let's see what the node from the above example can do." ] @@ -345,16 +340,16 @@ "from tapeagents.llms import LLMEvent\n", "\n", "\n", - "def make_prompt(agent, tape: DialogTape) -> Prompt:\n", - " return Prompt(messages=tape_to_messages(tape))\n", - "\n", + "class MainNode(Node):\n", + " def make_prompt(self, agent, tape: DialogTape) -> Prompt:\n", + " return Prompt(messages=tape_to_messages(tape))\n", "\n", - "def generate_steps(agent, tape, llm_stream: LLMStream):\n", - " yield AssistantStep(content=llm_stream.get_text())\n", - " yield SetNextNode(next_node=0) # Continue to the same first node\n", + " def generate_steps(self, agent, tape, llm_stream: LLMStream):\n", + " yield AssistantStep(content=llm_stream.get_text())\n", + " yield SetNextNode(next_node=0) # Continue to the same first node\n", "\n", "\n", - "node = Node().with_prompt(make_prompt).with_generate_steps(generate_steps)\n", + "node = MainNode()\n", "\n", "# Let's run \"make_prompt\" in isolation.\n", "prompt = node.make_prompt(agent=None, tape=DialogTape(steps=[UserStep(content=\"Hi, AI!\")]))\n", @@ -376,11 +371,11 @@ "start_tape = DialogTape(steps=[UserStep(content=\"Hi, AI!\")])\n", "prompt = node.make_prompt(agent, start_tape)\n", "# Step 2: construct the LLMStream from the prompt (happens inside the agent)\n", - "stream = llama.generate(prompt)\n", + "stream = llm.generate(prompt)\n", "# Step 3: generate steps that the agent will then add to the tape\n", "print(\"Produced Steps:\")\n", "for step in node.generate_steps(agent, start_tape, stream):\n", - " print(step.model_dump_json(indent=2))\n" + " print(step.model_dump_json(indent=2))" ] }, { @@ -404,25 +399,38 @@ "outputs": [], "source": [ "from tapeagents.view import TapeViewStack\n", + "from tapeagents.core import StepMetadata\n", "\n", "# The \"top\" view in the tape view stack is the view of current agent. Initially `top.next_node` is 0\".\n", "tape1 = DialogTape(steps=[UserStep(content=\"Hi, AI!\")])\n", - "print(TapeViewStack.compute(tape1).top.next_node)\n", + "next_node1 = TapeViewStack.compute(tape1).top.next_node\n", + "print(next_node1)\n", + "assert next_node1 == 0\n", + "\n", "\n", "# When the agent computes the view, it bumps up `top.next_node` every time it encounters a step with a new `prompt_id``.\n", "# The new prompt_id on the tape signals to the agent the current node has run.\n", - "tape2 = DialogTape(steps=[UserStep(content=\"Hi, AI!\"), AssistantStep(prompt_id=\"123\", content=\"AI here, how I can help?\")])\n", - "print(TapeViewStack.compute(tape2).top.next_node)\n", + "tape2 = DialogTape(\n", + " steps=[\n", + " UserStep(content=\"Hi, AI!\"),\n", + " AssistantStep(metadata=StepMetadata(prompt_id=\"123\"), content=\"AI here, how I can help?\"),\n", + " ]\n", + ")\n", + "next_node2 = TapeViewStack.compute(tape2).top.next_node\n", + "print(next_node2)\n", + "assert next_node2 == 1\n", "\n", "# The SetNextNode step on the tape changes `top.next_node` to the value of the `next_node` field in the SetNextNode step.\n", "tape3 = DialogTape(\n", " steps=[\n", " UserStep(content=\"Hi, AI!\"),\n", - " AssistantStep(prompt_id=\"123\", content=\"AI here, how I can help?\"),\n", + " AssistantStep(metadata=StepMetadata(prompt_id=\"123\"), content=\"AI here, how I can help?\"),\n", " SetNextNode(next_node=0),\n", " ]\n", ")\n", - "print(TapeViewStack.compute(tape3).top.next_node)\n" + "next_node3 = TapeViewStack.compute(tape3).top.next_node\n", + "print(next_node3)\n", + "assert next_node3 == 0" ] }, { @@ -443,7 +451,7 @@ "\n", "assert all([issubclass(step_class, Action) for step_class in [AssistantStep, ToolCalls]])\n", "assert all([issubclass(step_class, Thought) for step_class in [AssistantThought, SetNextNode, Pass]])\n", - "assert all([issubclass(step_class, Observation) for step_class in [UserStep, ToolResult]])\n" + "assert all([issubclass(step_class, Observation) for step_class in [UserStep, ToolResult]])" ] }, { @@ -484,7 +492,7 @@ "source": [ "tape_to_continue = final_tape + [UserStep(content=\"No, I mean Vulcan the company\")]\n", "continued_tape = agent.run(tape_to_continue).get_final_tape()\n", - "print(continued_tape.model_dump_json(indent=2))\n" + "print(continued_tape.model_dump_json(indent=2))" ] }, { @@ -514,7 +522,7 @@ "from tapeagents.rendering import PrettyRenderer, render_tape_with_prompts\n", "from IPython.display import HTML\n", "\n", - "HTML(render_tape_with_prompts(continued_tape, PrettyRenderer()))\n" + "HTML(render_tape_with_prompts(continued_tape, PrettyRenderer()))" ] }, { @@ -553,48 +561,42 @@ "env = ToolEnvironment([get_stock_ticker, get_stock_data])\n", "\n", "\n", - "def make_planning_prompt(agent, tape: DialogTape) -> Prompt:\n", - " guidance = \"Write a natural language plan on how to use tools help the user. Output a list of numbered items, like 1., 2., 3., etc.\"\n", - " guidance_message = {\"role\": \"user\", \"content\": guidance}\n", - " return Prompt(\n", - " messages=[system_message] + tape_to_messages(tape) + [guidance_message], tools=env.get_tool_schema_dicts()\n", - " )\n", - "\n", - "\n", - "def generate_planning_steps(agent, tape, llm_stream: LLMStream):\n", - " if content := llm_stream.get_message().content:\n", - " yield AssistantThought(content=content)\n", - " else:\n", - " raise ValueError()\n", + "class PlanNode(Node):\n", + " def make_prompt(self, agent, tape: DialogTape) -> Prompt:\n", + " guidance = \"Write a natural language plan on how to use tools help the user. Output a list of numbered items, like 1., 2., 3., etc.\"\n", + " guidance_message = {\"role\": \"user\", \"content\": guidance}\n", + " return Prompt(\n", + " messages=[system_message] + tape_to_messages(tape) + [guidance_message], tools=env.get_tool_schema_dicts()\n", + " )\n", "\n", + " def generate_steps(self, agent, tape, llm_stream: LLMStream):\n", + " if content := llm_stream.get_message().content:\n", + " yield AssistantThought(content=content)\n", + " else:\n", + " raise ValueError()\n", "\n", - "def make_prompt(agent, tape: DialogTape) -> Prompt:\n", - " guidance = \"Follow the plan you created to earlier. When you are done, respond to the user.\"\n", - " guidance_message = {\"role\": \"user\", \"content\": guidance}\n", - " return Prompt(\n", - " messages=[system_message] + tape_to_messages(tape) + [guidance_message], tools=env.get_tool_schema_dicts()\n", - " )\n", "\n", + "class ActNode(Node):\n", + " def make_prompt(self, agent, tape: DialogTape) -> Prompt:\n", + " guidance = \"Follow the plan you created to earlier. When you are done, respond to the user.\"\n", + " guidance_message = {\"role\": \"user\", \"content\": guidance}\n", + " return Prompt(\n", + " messages=[system_message] + tape_to_messages(tape) + [guidance_message], tools=env.get_tool_schema_dicts()\n", + " )\n", "\n", - "def generate_steps(agent, tape, llm_stream: LLMStream):\n", - " m = llm_stream.get_message()\n", - " if m.content:\n", - " yield AssistantStep(content=m.content)\n", - " yield SetNextNode(next_node=0)\n", - " elif m.tool_calls:\n", - " yield ToolCalls(tool_calls=m.tool_calls)\n", - " yield SetNextNode(next_node=1)\n", - " else:\n", - " raise ValueError()\n", + " def generate_steps(self, agent, tape, llm_stream: LLMStream):\n", + " m = llm_stream.get_message()\n", + " if m.content:\n", + " yield AssistantStep(content=m.content)\n", + " yield SetNextNode(next_node=0)\n", + " elif m.tool_calls:\n", + " yield ToolCalls(tool_calls=m.tool_calls)\n", + " yield SetNextNode(next_node=1)\n", + " else:\n", + " raise ValueError()\n", "\n", "\n", - "agent1 = Agent.create(\n", - " LiteLLM(model_name=\"gpt-4o\", parameters={\"temperature\": 0.1}),\n", - " nodes=[\n", - " Node().with_prompt(make_planning_prompt).with_generate_steps(generate_planning_steps),\n", - " Node().with_prompt(make_prompt).with_generate_steps(generate_steps),\n", - " ],\n", - ")\n", + "agent1 = Agent.create(LiteLLM(model_name=\"gpt-4o\", parameters={\"temperature\": 0.1}), nodes=[PlanNode(), ActNode()])\n", "\n", "print(\"Run the agent!\")\n", "final_tape1 = None\n", @@ -608,7 +610,7 @@ " print(event.observation.model_dump_json(indent=2))\n", "assert final_tape1\n", "print(\"Final tape:\")\n", - "HTML(render_tape_with_prompts(final_tape1, PrettyRenderer()))\n" + "HTML(render_tape_with_prompts(final_tape1, PrettyRenderer()))" ] }, { @@ -631,7 +633,63 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Let's try building a similar agent with an open-weights LLAMA3.1 70B models. Conveniently, [Together AI](together.ai) offers API endpoints. You can create an account and get API key with some free quota.\n", + "Let's try building a similar agent with an open-weights LLAMA3 70B models. Conveniently, [Together AI](together.ai) offers API endpoints. You can create an account and get API key with some free quota." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 3.0. Setup your LLM key" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Set more environment variables in the .env file or set them below\n", + "\n", + "dotenv.load_dotenv(env_file, override=True)\n", + "\n", + "# os.environ[\"TOGETHER_API_KEY\"] = \"\" # put your https://together.ai/ key here\n", + "# os.environ[\"HF_TOKEN\"] = \"\" # put your huggingface token here\n", + "\n", + "os.environ[\"TAPEAGENTS_LLM_TOKEN\"] = os.getenv(\"TOGETHER_API_KEY\", \"\") # Use Together API Key for llms.TrainableLLM" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Login to Hugging Face Hub\n", + "if \"PYTEST_CURRENT_TEST\" not in os.environ: # skip login during tests\n", + " from huggingface_hub import login\n", + "\n", + " login(token=os.environ.get(\"HF_TOKEN\"))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Access to Hugging Face Gated Models\n", + "Make sure you have access to each model we are going to use (read more [here](https://huggingface.co/docs/hub/en/models-gated#access-gated-models-as-a-user)):\n", + "- https://huggingface.co/meta-llama/Meta-Llama-3-70B-Instruct\n", + "\n", + "##### Troubleshoot\n", + "- If you receive a 401 error, it means the authentication failed.\n", + "- If you receive a 403 error, it means you are authenticated but not authorized to access the specific model." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 3.1. Setup your Agents\n", "\n", "We've found that LLAMA3 function-calling is not yet battle-ready. We will use the structured output approach to make it call tools instead. We are also making this agent trainable by adding `make_llm_output` methods to each node. `Node.make_llm_output` defines how a node can reconstruct the LLM completion message that would be required to make the steps from the given tape at the given index. You can think of `Node.make_llm_output` as the inverse of `Node.generate_steps`.\n", "\n", @@ -648,7 +706,7 @@ "source": [ "import json\n", "from tapeagents.core import LLMOutput\n", - "from tapeagents.llms import LLAMA\n", + "from tapeagents.llms import TrainableLLM\n", "from litellm.utils import ChatCompletionMessageToolCall\n", "from litellm.utils import Function\n", "\n", @@ -675,23 +733,72 @@ "\"\"\"\n", "\n", "\n", - "def make_planning_prompt(agent, tape: DialogTape) -> Prompt:\n", - " system_message = {\"role\": \"system\", \"content\": system_instruction}\n", - " guidance_message = {\"role\": \"user\", \"content\": agent.templates[\"planning\"]}\n", - " return Prompt(messages=[system_message] + tape_to_messages(tape) + [guidance_message])\n", + "class PlanNode(Node):\n", + " def make_prompt(self, agent, tape: DialogTape) -> Prompt:\n", + " system_message = {\"role\": \"system\", \"content\": system_instruction}\n", + " guidance_message = {\"role\": \"user\", \"content\": agent.templates[\"planning\"]}\n", + " return Prompt(messages=[system_message] + tape_to_messages(tape) + [guidance_message])\n", "\n", + " def generate_steps(self, agent, tape, llm_stream: LLMStream):\n", + " if content := getattr(llm_stream.get_message(), \"content\", None):\n", + " yield AssistantThought(content=content)\n", + " else:\n", + " raise ValueError()\n", "\n", - "def generate_planning_steps(agent, tape, llm_stream: LLMStream):\n", - " if content := getattr(llm_stream.get_message(), \"content\", None):\n", - " yield AssistantThought(content=content)\n", - " else:\n", - " raise ValueError()\n", + " def make_llm_output(self, agent, tape: DialogTape, index: int) -> LLMOutput:\n", + " if not isinstance(current := tape[index], AssistantThought):\n", + " raise ValueError()\n", + " return LLMOutput(role=\"assistant\", content=current.content)\n", "\n", "\n", - "def make_planning_llm_output(agent, tape: DialogTape, index: int) -> LLMOutput:\n", - " if not isinstance(current := tape[index], AssistantThought):\n", - " raise ValueError()\n", - " return LLMOutput(role=\"assistant\", content=current.content)\n", + "class ActNode(Node):\n", + " def make_prompt(self, agent, tape: DialogTape) -> Prompt:\n", + " system_message = {\"role\": \"system\", \"content\": system_instruction}\n", + " guidance_message = {\"role\": \"user\", \"content\": agent.templates[\"call_or_respond\"]}\n", + " messages = [system_message]\n", + " for step in tape:\n", + " if isinstance(step, (ToolCalls)):\n", + " messages.append({\"role\": \"assistant\", \"content\": _llm_message_content(step)})\n", + " elif not isinstance(step, SetNextNode):\n", + " messages.append(step_to_message(step))\n", + " messages += [guidance_message]\n", + " return Prompt(messages=messages)\n", + "\n", + " def generate_steps(self, agent, tape, llm_stream: LLMStream):\n", + " m = llm_stream.get_message()\n", + " try:\n", + " assert m.content\n", + " tool_calls = []\n", + " response = None\n", + " for line in m.content.split(\"\\n\"):\n", + " data = json.loads(line)\n", + " if data.get(\"kind\") == \"response\":\n", + " response = data[\"content\"]\n", + " elif data.get(\"kind\") == \"tool_call\":\n", + " tool_call = ChatCompletionMessageToolCall(\n", + " function=Function(name=data[\"tool_name\"], arguments=json.dumps(data[\"parameters\"])),\n", + " # tool call must be a unique string, it helps to make it something deterministic\n", + " id=f\"tool_call_{len(tool_calls)}_node_starts_at_{len(tape)}\",\n", + " )\n", + " tool_calls.append(tool_call)\n", + " else:\n", + " yield AssistantStep(content=\"Invalid LLM output: kind field must be 'response' or 'tool_call'\")\n", + " if response and tool_calls:\n", + " yield AssistantStep(content=\"Invalid LLM output: response and tool_call cannot be in the same message\")\n", + " if response:\n", + " yield AssistantStep(content=response)\n", + " yield SetNextNode(next_node=0)\n", + " if tool_calls:\n", + " yield ToolCalls(tool_calls=tool_calls)\n", + " yield SetNextNode(next_node=1)\n", + " except Exception as e:\n", + " yield AssistantStep(content=\"Invalid JSON object: \" + str(e))\n", + "\n", + " def make_llm_output(self, agent, tape: DialogTape, index: int) -> LLMOutput:\n", + " if not isinstance(step := tape[index], AssistantStep | ToolCalls):\n", + " raise ValueError()\n", + " content = _llm_message_content(step)\n", + " return LLMOutput(role=\"assistant\", content=content)\n", "\n", "\n", "def _llm_message_content(step: AssistantStep | ToolCalls):\n", @@ -716,59 +823,8 @@ " raise ValueError()\n", "\n", "\n", - "def make_prompt(agent, tape: DialogTape) -> Prompt:\n", - " system_message = {\"role\": \"system\", \"content\": system_instruction}\n", - " guidance_message = {\"role\": \"user\", \"content\": agent.templates[\"call_or_respond\"]}\n", - " messages = [system_message]\n", - " for step in tape:\n", - " if isinstance(step, (ToolCalls)):\n", - " messages.append({\"role\": \"assistant\", \"content\": _llm_message_content(step)})\n", - " elif not isinstance(step, SetNextNode):\n", - " messages.append(step_to_message(step))\n", - " messages += [guidance_message]\n", - " return Prompt(messages=messages)\n", - "\n", - "\n", - "def generate_steps(agent, tape, llm_stream: LLMStream):\n", - " m = llm_stream.get_message()\n", - " try:\n", - " assert m.content\n", - " tool_calls = []\n", - " response = None\n", - " for line in m.content.split(\"\\n\"):\n", - " data = json.loads(line)\n", - " if data.get(\"kind\") == \"response\":\n", - " response = data[\"content\"]\n", - " elif data.get(\"kind\") == \"tool_call\":\n", - " tool_call = ChatCompletionMessageToolCall(\n", - " function=Function(name=data[\"tool_name\"], arguments=json.dumps(data[\"parameters\"])),\n", - " # tool call must be a unique string, it helps to make it something deterministic\n", - " id=f\"tool_call_{len(tool_calls)}_node_starts_at_{len(tape)}\",\n", - " )\n", - " tool_calls.append(tool_call)\n", - " else:\n", - " yield AssistantStep(content=\"Invalid LLM output: kind field must be 'response' or 'tool_call'\")\n", - " if response and tool_calls:\n", - " yield AssistantStep(content=\"Invalid LLM output: response and tool_call cannot be in the same message\")\n", - " if response:\n", - " yield AssistantStep(content=response)\n", - " yield SetNextNode(next_node=0)\n", - " if tool_calls:\n", - " yield ToolCalls(tool_calls=tool_calls)\n", - " yield SetNextNode(next_node=1)\n", - " except Exception as e:\n", - " yield AssistantStep(content=\"Invalid JSON object: \" + str(e))\n", - "\n", - "\n", - "def make_llm_output(agent, tape: DialogTape, index: int) -> LLMOutput:\n", - " if not isinstance(step := tape[index], AssistantStep | ToolCalls):\n", - " raise ValueError()\n", - " content = _llm_message_content(step)\n", - " return LLMOutput(role=\"assistant\", content=content)\n", - "\n", - "\n", "agent2 = Agent.create(\n", - " LLAMA(\n", + " TrainableLLM(\n", " base_url=\"https://api.together.xyz\",\n", " model_name=\"meta-llama/Meta-Llama-3-70B-Instruct-Turbo\",\n", " tokenizer_name=\"meta-llama/Meta-Llama-3-70B-Instruct\",\n", @@ -779,15 +835,23 @@ " \"planning\": planning_guidance,\n", " \"call_or_respond\": call_or_respond_guidance,\n", " },\n", - " nodes=[\n", - " Node()\n", - " .with_prompt(make_planning_prompt)\n", - " .with_generate_steps(generate_planning_steps)\n", - " .with_llm_output(make_planning_llm_output),\n", - " Node().with_prompt(make_prompt).with_generate_steps(generate_steps).with_llm_output(make_llm_output),\n", - " ],\n", - ")\n", - "\n", + " nodes=[PlanNode(), ActNode()],\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 3.2. Run your Agent" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ "final_tape2 = None\n", "print(\"Run LLAMA agent!\")\n", "for event in main_loop(\n", @@ -802,7 +866,7 @@ " print(event.observation.model_dump_json(indent=2))\n", "assert final_tape2 is not None\n", "print(\"Final tape:\")\n", - "HTML(render_tape_with_prompts(final_tape2, PrettyRenderer()))\n" + "HTML(render_tape_with_prompts(final_tape2, PrettyRenderer()))" ] }, { @@ -825,7 +889,7 @@ " \"REMEMBER: check what tool calls you have already made. Do not do the same call again!\"\n", ")\n", "resume_from_step8 = agent2b.run(failed_tape[:8]).get_final_tape()\n", - "HTML(render_tape_with_prompts(resume_from_step8, PrettyRenderer()))\n" + "HTML(render_tape_with_prompts(resume_from_step8, PrettyRenderer()))" ] }, { @@ -839,7 +903,13 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# 4. Tape reuse and training data\n", + "# 4. Tape reuse and training data" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ "\n", "Another way to help this agent (or one with an even smaller LLM) is to finetune the LLM. And the most important step towards finetuning is making the training data!\n", "\n", @@ -873,7 +943,7 @@ "example_text = agent2.make_training_text(list(llm_calls.values())[0])\n", "print(\"From the first retrieved LLM call, the LLM will be trained to predict this text:\")\n", "print(\"---\")\n", - "print(example_text.output_text)\n" + "print(example_text.output_text)" ] }, { @@ -899,7 +969,7 @@ "outputs": [], "source": [ "reused_tape, _ = agent2.reuse(final_tape1)\n", - "HTML(render_tape_with_prompts(reused_tape, PrettyRenderer()))\n" + "HTML(render_tape_with_prompts(reused_tape, PrettyRenderer()))" ] }, { @@ -916,7 +986,7 @@ "outputs": [], "source": [ "training_data = agent2.make_training_data(final_tape1)\n", - "print(training_data[0].output_text)\n" + "print(training_data[0].output_text)" ] }, { @@ -960,13 +1030,19 @@ "\n", "browser = SimpleTextBrowser()\n", "search_agent_env = ToolEnvironment([browser.get_search_results, browser.get_page, browser.get_next_page])\n", + "\n", + "\n", "# We will use the tool choice mechanism to let the main agent call its search specialist agent.\n", "# To this end, we create a mock tool that represents calling the search agent.\n", "def call_search_agent(query: str):\n", " \"\"\"Use this tool to ask a fellow AI agent to search for information on the web.\"\"\"\n", " pass\n", + "\n", + "\n", "main_agent_env = ToolEnvironment([get_stock_ticker, get_stock_data, call_search_agent])\n", - "whole_env = ToolEnvironment([get_stock_ticker, get_stock_data, browser.get_search_results, browser.get_page, browser.get_next_page])" + "whole_env = ToolEnvironment(\n", + " [get_stock_ticker, get_stock_data, browser.get_search_results, browser.get_page, browser.get_next_page]\n", + ")" ] }, { @@ -1004,7 +1080,7 @@ "# We will print a brief summary of view stack after each step\n", "for i in range(0, len(tape)):\n", " print(f\"View stack after step {i}\")\n", - " view_stack = TapeViewStack.compute(tape[:i + 1])\n", + " view_stack = TapeViewStack.compute(tape[: i + 1])\n", " for view in view_stack.stack:\n", " step_summary = \", \".join([step.__class__.__name__ for step in view.steps])\n", " print(f\"-- {view.agent_full_name}: {step_summary}\")\n", @@ -1026,21 +1102,18 @@ "metadata": {}, "outputs": [], "source": [ - "\n", "from tapeagents.core import Respond\n", "from tapeagents.prompting import view_to_messages\n", "\n", - "search_system_instruction = (\n", - " f\"\"\"Use at most 5 tool calls to search the request info on on the web.\"\"\"\n", - ")\n", + "search_system_instruction = f\"\"\"Use at most 5 tool calls to search the request info on on the web.\"\"\"\n", "search_system_message = {\"role\": \"system\", \"content\": search_system_instruction}\n", "\n", + "\n", "class SearchAgentMainNode(Node):\n", - " \n", " def make_prompt(self, agent, tape: DialogTape) -> Prompt:\n", " view = agent.compute_view(tape)\n", " return Prompt(messages=view_to_messages(view.top, agent), tools=search_agent_env.get_tool_schema_dicts())\n", - " \n", + "\n", " def generate_steps(self, agent, tape, llm_stream: LLMStream):\n", " m = llm_stream.get_message()\n", " if m.content:\n", @@ -1052,18 +1125,16 @@ " yield SetNextNode(next_node=0)\n", " else:\n", " raise ValueError()\n", - " \n", + "\n", + "\n", "search_agent = Agent.create(\n", " name=\"search_agent\",\n", " llms=LiteLLM(model_name=\"gpt-4o\", parameters={\"temperature\": 0.1}),\n", " nodes=[SearchAgentMainNode()],\n", - ") \n", + ")\n", "# To test the subagent, we'll make a mock root agent that immediately calls \"search_agent\"\n", "call_step = Call(agent_name=\"search_agent\", content=\"What influenced Nvidia stock price in late 2022?\")\n", - "test_root_agent = Agent.create(\n", - " subagents=[search_agent],\n", - " nodes=[Node().with_fixed_steps([call_step])]\n", - ")\n", + "test_root_agent = Agent.create(subagents=[search_agent], nodes=[Node().with_fixed_steps([call_step])])\n", "start_tape = DialogTape()\n", "final_tape = None\n", "for event in main_loop(test_root_agent, start_tape, search_agent_env):\n", @@ -1103,15 +1174,15 @@ "\"\"\"\n", "system_message = {\"role\": \"system\", \"content\": system_instruction}\n", "\n", - "class PlanNode(Node):\n", "\n", + "class PlanNode(Node):\n", " def make_prompt(self, agent, tape) -> Prompt:\n", " view = agent.compute_view(tape)\n", " guidance = \"Write a natural language plan on how to use tools help the user. Output a list of numbered items, like 1., 2., 3., etc.\"\n", " guidance_message = {\"role\": \"user\", \"content\": guidance}\n", " return Prompt(\n", - " messages=[system_message] + view_to_messages(view.top, agent) + [guidance_message], \n", - " tools=main_agent_env.get_tool_schema_dicts()\n", + " messages=[system_message] + view_to_messages(view.top, agent) + [guidance_message],\n", + " tools=main_agent_env.get_tool_schema_dicts(),\n", " )\n", "\n", " def generate_steps(self, agent, dialog, llm_stream: LLMStream):\n", @@ -1120,22 +1191,22 @@ " else:\n", " raise ValueError()\n", "\n", - "class ActNode(Node):\n", "\n", + "class ActNode(Node):\n", " def make_prompt(self, agent, tape: DialogTape) -> Prompt:\n", " view = agent.compute_view(tape)\n", " guidance = \"Follow the plan you created to earlier. When you are done, respond to the user.\"\n", " guidance_message = {\"role\": \"user\", \"content\": guidance}\n", " return Prompt(\n", - " messages=[system_message] + view_to_messages(view.top, agent) + [guidance_message], \n", - " tools=main_agent_env.get_tool_schema_dicts()\n", + " messages=[system_message] + view_to_messages(view.top, agent) + [guidance_message],\n", + " tools=main_agent_env.get_tool_schema_dicts(),\n", " )\n", "\n", " def generate_steps(self, agent, dialog, llm_stream: LLMStream):\n", " m = llm_stream.get_message()\n", " if m.content:\n", - " yield AssistantStep(content=m.content)\n", " yield SetNextNode(next_node=0)\n", + " yield AssistantStep(content=m.content)\n", " elif m.tool_calls:\n", " yield SetNextNode(next_node=1)\n", " # only keep the tool calls before the call to another agent\n", @@ -1145,17 +1216,18 @@ " break\n", " else:\n", " tool_calls.append(tc)\n", - " # either produce the ToolCalls action OR call another agent \n", + " # either produce the ToolCalls action OR call another agent\n", " if tool_calls:\n", " yield ToolCalls(tool_calls=tool_calls)\n", - " else: \n", + " else:\n", " tc = m.tool_calls[0]\n", - " assert tc.function.name == \"call_search_agent\" \n", + " assert tc.function.name == \"call_search_agent\"\n", " yield Call(agent_name=\"search_agent\", content=json.loads(m.tool_calls[0].function.arguments)[\"query\"])\n", - " \n", + "\n", " else:\n", " raise ValueError()\n", "\n", + "\n", "multi_agent_analyst = Agent.create(\n", " name=\"analyst\",\n", " subagents=[search_agent.clone()],\n", @@ -1166,7 +1238,7 @@ "print(\"Run the agent!\")\n", "start_tape = DialogTape(steps=[UserStep(content=\"Tell me about Vulcan in 3 sentences\")])\n", "for event in main_loop(multi_agent_analyst, start_tape, whole_env):\n", - " # This agent runs for a while, so we will show you a fresh render every time \n", + " # This agent runs for a while, so we will show you a fresh render every time\n", " # when the environment finishes reacting with new actions\n", " if new_tape := event.agent_tape or event.env_tape:\n", " clear_output()\n", @@ -1175,7 +1247,7 @@ " # if event.env_tape:\n", " # input(\"Press Enter the run the next iteration of the main loop\")\n", " if event.status == MainLoopStatus.EXTERNAL_INPUT_NEEDED:\n", - " break " + " break" ] }, { @@ -1184,11 +1256,6 @@ "source": [ "Look at this rather long tape and note how \"analyst\" calls \"search_agent\", and how the latter then responds to \"analyst\". Congratulations, you now know how to build a multi-agent TapeAgent!" ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [] } ], "metadata": { diff --git a/examples/llama_agent.py b/examples/llama_agent.py index e87ff5d..2267435 100644 --- a/examples/llama_agent.py +++ b/examples/llama_agent.py @@ -5,7 +5,7 @@ from tapeagents.agent import Agent from tapeagents.core import LLMOutput, PartialStep, Prompt, Tape, TapeMetadata, TrainingText from tapeagents.dialog_tape import AssistantStep, DialogTape, SystemStep, UserStep -from tapeagents.llms import LLAMA, LLM, LLMStream +from tapeagents.llms import TrainableLLM, LLM, LLMStream from tapeagents.prompting import tape_to_messages @@ -104,7 +104,7 @@ def try_llama_chatbot(llm: LLM): tmpdir = tempfile.mkdtemp() os.chdir(tmpdir) try_llama_chatbot( - LLAMA( + TrainableLLM( base_url="https://api.together.xyz", model_name="meta-llama/Meta-Llama-3-70B-Instruct-Turbo", tokenizer_name="meta-llama/Meta-Llama-3-70B-Instruct", diff --git a/examples/llama_user.py b/examples/llama_user.py index bd385de..5bf3eee 100644 --- a/examples/llama_user.py +++ b/examples/llama_user.py @@ -9,7 +9,7 @@ UserModelTape, UserStep, ) -from tapeagents.llms import LLAMA, LLMStream +from tapeagents.llms import TrainableLLM, LLMStream USER_MODEL_TEMPLATE = """You will generate the next user message in the following conversation. @@ -45,7 +45,7 @@ def signature(self): return json.dumps({"model": "llama", "prompt": self.instruction}) -def try_llama_user_model(llm: LLAMA): +def try_llama_user_model(llm: TrainableLLM): tape = DialogTape( context=None, steps=[ @@ -82,7 +82,7 @@ def try_llama_user_model(llm: LLAMA): if __name__ == "__main__": try_llama_user_model( - LLAMA( + TrainableLLM( base_url="https://api.together.xyz", model_name="meta-llama/Llama-3-8b-chat-hf", parameters=dict(temperature=0.7, max_tokens=512), diff --git a/examples/studio.py b/examples/studio.py index 17819d5..10aa278 100644 --- a/examples/studio.py +++ b/examples/studio.py @@ -3,7 +3,7 @@ from tapeagents.studio import Studio from tapeagents.dialog_tape import DialogTape, SystemStep, UserStep -from tapeagents.llms import LLAMA +from tapeagents.llms import TrainableLLM from tapeagents.rendering import PrettyRenderer from .delegate_stack import EXAMPLE_TEXT, ExampleTape, make_analyze_text_chain @@ -33,7 +33,7 @@ def try_studio_with_chat(llm): if __name__ == "__main__": - llm = LLAMA( + llm = TrainableLLM( base_url="https://api.together.xyz", model_name="meta-llama/Meta-Llama-3-70B-Instruct-Turbo", parameters=dict(temperature=0.7, max_tokens=512), diff --git a/intro.ipynb b/intro.ipynb index 86e3c1a..00b7214 100644 --- a/intro.ipynb +++ b/intro.ipynb @@ -4,7 +4,13 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Welcome to TapeAgents!\n", + "# Welcome to TapeAgents!" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ "\n", "**TapeAgents** is a framework to build, debug, serve and optimize your AI agent. It takes a holistic view of the agent lifecycle and aims to support you at all stages. The main distinguishing feature of the framework is that by design a **TapeAgent** creates its \n", "**Tape**: a compherensive semantic log of the agent's session that greatly facilitates audit, debugging, finetuning, agent optimization, etc.\n", @@ -29,7 +35,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# 0. Setup" + "# 0. Setup your TapeAgents environment" ] }, { @@ -43,35 +49,20 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "#### 0. Install conda\n", - "https://conda.io/projects/conda/en/latest/user-guide/install/index.html" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### 1. All commands assume execution from the tapeagents directory.\n", + "#### 0.1. Install conda\n", + "https://conda.io/projects/conda/en/latest/user-guide/install/index.html\n", + "\n", + "#### 0.2. All commands assume execution from the tapeagents directory.\n", "```bash\n", "cd tapeagents/\n", - "```" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### 2. Create conda environment and install `tapeagents` and its dependencies:\n", + "```\n", + "\n", + "#### 0.3. Create a conda environment named `tapeagents`, install `tapeagents` in editable mode and its dependencies:\n", "```bash\n", "make setup\n", - "```" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### 3. Set Jupyter Notebook kernel to your newly created `tapeagents` conda environment\n", + "```\n", + "\n", + "#### 0.4 Set Jupyter Notebook kernel to your newly created `tapeagents` conda environment\n", "https://code.visualstudio.com/docs/datascience/jupyter-notebooks#_create-or-open-a-jupyter-notebook" ] }, @@ -79,7 +70,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "#### 4. Set your LLM API keys and other minor things" + "#### 0.5. Set some configurations" ] }, { @@ -87,24 +78,38 @@ "execution_count": 1, "metadata": { "execution": { - "iopub.execute_input": "2024-09-27T12:57:06.845655Z", - "iopub.status.busy": "2024-09-27T12:57:06.845289Z", - "iopub.status.idle": "2024-09-27T12:57:06.854220Z", - "shell.execute_reply": "2024-09-27T12:57:06.853516Z" + "iopub.execute_input": "2024-09-28T05:58:28.278567Z", + "iopub.status.busy": "2024-09-28T05:58:28.278286Z", + "iopub.status.idle": "2024-09-28T05:58:28.290143Z", + "shell.execute_reply": "2024-09-28T05:58:28.289592Z" } }, "outputs": [], "source": [ "import os\n", "\n", - "# os.environ[\"OPENAI_API_KEY\"] = \"\" # put your https://platform.openai.com/ key here\n", - "# os.environ[\"OPENAI_ORGANIZATION\"] = \"\" # optional if you use your personal key\n", - "# os.environ[\"TOGETHER_API_KEY\"] = \"\" # put your https://together.ai/ key here\n", - "# os.environ[\"TAPEAGENTS_LLM_TOKEN\"] = os.environ[\"TOGETHER_API_KEY\"] # Use Together API Key for llms.LLAMA\n", - "# os.environ[\"HF_TOKEN\"] = \"\" # put your huggingface token here\n", - "\n", "os.environ[\"TRANSFORMERS_NO_ADVISORY_WARNINGS\"] = \"1\"\n", - "today = \"2024-09-17\" # fixed date for reproducible tests" + "today = \"2024-09-17\" # fixed date for reproducible tests" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 0.6. Set your LLM API keys" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Set environement variable in a `.env` file at the root of `TapeAgents` repository or set them below\n", + "\n", + "```bash\n", + "# .env file\n", + "OPENAI_API_KEY=\"\" # put your https://platform.openai.com/ key here\n", + "# OPENAI_ORGANIZATION=\"\" # optional if you use your personal key\n", + "```" ] }, { @@ -112,46 +117,32 @@ "execution_count": 2, "metadata": { "execution": { - "iopub.execute_input": "2024-09-27T12:57:06.857050Z", - "iopub.status.busy": "2024-09-27T12:57:06.856761Z", - "iopub.status.idle": "2024-09-27T12:57:07.380636Z", - "shell.execute_reply": "2024-09-27T12:57:07.379985Z" + "iopub.execute_input": "2024-09-28T05:58:28.292989Z", + "iopub.status.busy": "2024-09-28T05:58:28.292496Z", + "iopub.status.idle": "2024-09-28T05:58:28.304698Z", + "shell.execute_reply": "2024-09-28T05:58:28.304270Z" } }, "outputs": [ { "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "001f28da24cd46e0a8c6dad91d252ed3", - "version_major": 2, - "version_minor": 0 - }, "text/plain": [ - "VBox(children=(HTML(value='
Prompt:\n", - " return Prompt(messages=tape_to_messages(tape))\n", "\n", + "class MainNode(Node):\n", + " def make_prompt(self, agent: Agent, tape: DialogTape) -> Prompt:\n", + " return Prompt(messages=tape_to_messages(tape))\n", "\n", - "def generate_steps(agent: Agent, tape: DialogTape, llm_stream: LLMStream):\n", - " \"\"\"\n", - " llm_stream contains the text of the LLM model response\n", - " \"\"\"\n", - " yield AssistantStep(content=llm_stream.get_text())\n", - " yield SetNextNode(next_node=0) # Which node to execute next, more on that later\n", + " def generate_steps(self, agent: Agent, tape: DialogTape, llm_stream: LLMStream):\n", + " \"\"\"\n", + " llm_stream contains the text of the LLM model response\n", + " \"\"\"\n", + " yield AssistantStep(content=llm_stream.get_text())\n", + " yield SetNextNode(next_node=0) # Which node to execute next, more on that later\n", "\n", "\n", - "node = Node().with_prompt(make_prompt).with_generate_steps(generate_steps)\n", - "nodes = [node]\n", + "nodes = [MainNode()]\n", "agent = Agent[DialogTape].create(llm, nodes=nodes)\n", "start_tape = DialogTape(steps=[UserStep(content=\"Tell me about Vulcan in 3 sentences\")])\n", "final_tape = agent.run(start_tape).get_final_tape()\n", @@ -287,10 +277,10 @@ "execution_count": 4, "metadata": { "execution": { - "iopub.execute_input": "2024-09-27T12:57:12.914459Z", - "iopub.status.busy": "2024-09-27T12:57:12.914169Z", - "iopub.status.idle": "2024-09-27T12:57:12.919270Z", - "shell.execute_reply": "2024-09-27T12:57:12.918620Z" + "iopub.execute_input": "2024-09-28T05:58:32.914203Z", + "iopub.status.busy": "2024-09-28T05:58:32.913973Z", + "iopub.status.idle": "2024-09-28T05:58:32.917292Z", + "shell.execute_reply": "2024-09-28T05:58:32.916773Z" } }, "outputs": [ @@ -310,7 +300,7 @@ "# specifying different Context and Step types. In the output of this cell,\n", "# look at Union[UserStep, AssistantStep, ...]\n", "# for the list of possible step types in the DialogTape.\n", - "DialogTape\n" + "DialogTape" ] }, { @@ -339,10 +329,10 @@ "execution_count": 5, "metadata": { "execution": { - "iopub.execute_input": "2024-09-27T12:57:12.922100Z", - "iopub.status.busy": "2024-09-27T12:57:12.921820Z", - "iopub.status.idle": "2024-09-27T12:57:12.926649Z", - "shell.execute_reply": "2024-09-27T12:57:12.925972Z" + "iopub.execute_input": "2024-09-28T05:58:32.919015Z", + "iopub.status.busy": "2024-09-28T05:58:32.918883Z", + "iopub.status.idle": "2024-09-28T05:58:32.921803Z", + "shell.execute_reply": "2024-09-28T05:58:32.921457Z" } }, "outputs": [ @@ -363,14 +353,14 @@ "# Almost all classes in TapeAgents are Pydantic base models.\n", "# This allows easy validation, serialization and instrospection. For example,\n", "# here we are able to list all the fields in the Prompt model.\n", - "Prompt.model_fields\n" + "Prompt.model_fields" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "The LLMs in TapeAgent take `Prompt` and return an `LLMStream` object. The `LLMStream` object can be used both to fast-forward to the complete response text and to stream partial outputs step by step. " + "The LLMs in TapeAgent take `Prompt` and return an `LLMStream` object. The `LLMStream` object can be used both to fast-forward to the complete response text and to stream partial outputs step by step." ] }, { @@ -378,10 +368,10 @@ "execution_count": 6, "metadata": { "execution": { - "iopub.execute_input": "2024-09-27T12:57:12.929372Z", - "iopub.status.busy": "2024-09-27T12:57:12.929109Z", - "iopub.status.idle": "2024-09-27T12:57:26.794429Z", - "shell.execute_reply": "2024-09-27T12:57:26.793477Z" + "iopub.execute_input": "2024-09-28T05:58:32.923397Z", + "iopub.status.busy": "2024-09-28T05:58:32.923244Z", + "iopub.status.idle": "2024-09-28T05:58:37.969735Z", + "shell.execute_reply": "2024-09-28T05:58:37.969420Z" } }, "outputs": [ @@ -389,145 +379,93 @@ "name": "stdout", "output_type": "stream", "text": [ - "Here is the classic \"Hello, World!\" program" + "Certainly! Here is a simple \"Hello, World!\"" ] }, { "name": "stdout", "output_type": "stream", "text": [ - " in Java:\n", - "```\n", - "public class HelloWorld {\n", - " public static void main(String[] args) {\n", - " System.out.println(\"Hello, World!\");\n" + " program in Java:\n", + "\n", + "```java\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ - " }\n", + "public class HelloWorld {\n", + " public static void main(String[] args) {\n", + " System.out.println(\"Hello, World!\");\n", + " }\n", "}\n", "```\n", - "Let me explain what's going on:\n", "\n", - "* `public class HelloWorld {` declares" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - " a new Java class called `HelloWorld`. The `public` access modifier means" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - " that the class can be accessed from outside the package where it's defined.\n", - "* `public static void main(String" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[] args) {` declares the `main` method, which is the entry point of the program. The `public` access modifier means that the method" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - " can be called from outside the class, and the `static` keyword means that the method can be called without" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - " creating an instance of the class. The `void` return type means that the method doesn't return" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - " any value. The `main` method takes an array of `String` arguments, which" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - " represents the command-line arguments passed to the program.\n", - "* `System.out.println(\"Hello, World!\");` prints the string \"Hello," + "### Steps to Run the Program:\n", + "\n", + "1" ] }, { "name": "stdout", "output_type": "stream", "text": [ - " World!\" to the console, followed by a newline character. `System.out` is a built-in output" + ". **Create a file**: Save the code in a file named `" ] }, { "name": "stdout", "output_type": "stream", "text": [ - " stream that writes to the console, and `println` is a method that writes a string to the output stream and" + "HelloWorld.java`.\n", + "2. **Compile the program**: Open a terminal or command prompt" ] }, { "name": "stdout", "output_type": "stream", "text": [ - " appends a newline character.\n", - "\n", - "To compile" + ", navigate to the directory where the file is saved, and run:\n", + " ```\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ - " and run this program, you'll need to save it to a file called `HelloWorld.java`, then" + " javac HelloWorld.java\n", + " ```\n", + "3. **" ] }, { "name": "stdout", "output_type": "stream", "text": [ - " compile it using the `javac` command, and finally run it using the `java` command. Here" + "Run the program**: After compiling, you can run the program with:\n", + " " ] }, { "name": "stdout", "output_type": "stream", "text": [ - " are the steps:\n", + " ```\n", + " java HelloWorld\n", + " ```\n", "\n", - "1. Save the code to a file called `HelloWorld.java`.\n", - "2. Open a terminal or" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - " command prompt and navigate to the directory where you saved the file.\n", - "3. Compile the program using the following command: `javac HelloWorld.java`\n" + "You should see the output:\n", + "``" ] }, { "name": "stdout", "output_type": "stream", "text": [ - "4. Run the program using the following command: `java HelloWorld`\n", - "\n", - "This should print \"Hello, World!\" to the console!None\n", + "`\n", + "Hello, World!\n", + "```None\n", "------------------------------\n" ] }, @@ -535,8 +473,9 @@ "name": "stdout", "output_type": "stream", "text": [ - "Here is the classic \"Hello, World!\" program in C:\n", - "```\n", + "Certainly! Here is a simple program that prints \"Hello, World!\" in C:\n", + "\n", + "```c\n", "#include \n", "\n", "int main() {\n", @@ -544,42 +483,45 @@ " return 0;\n", "}\n", "```\n", - "Let me explain what each line does:\n", "\n", - "1. `#include `: This line tells the compiler to include the `stdio.h` header file, which provides input/output functions such as `printf`.\n", - "2. `int main()`: This line declares a function called `main`, which is the entry point of the program. The `int` keyword specifies that the function returns an integer value.\n", - "3. `printf(\"Hello, World!\\n\");`: This line uses the `printf` function to print the string \"Hello, World!\" followed by a newline character (`\\n`) to the console.\n", - "4. `return 0;`: This line returns an integer value of 0 to indicate that the program has completed successfully.\n", + "### Explanation:\n", + "- `#include `: This line includes the standard input/output library, which is necessary for using the `printf` function.\n", + "- `int main()`: This defines the main function where the program execution starts.\n", + "- `printf(\"Hello, World!\\n\");`: This line prints \"Hello, World!\" to the console, followed by a new line (`\\n`).\n", + "- `return 0;`: This indicates that the program finished successfully.\n", + "\n", + "### To compile and run the program:\n", + "1. Save the code to a file named `hello.c`.\n", + "2. Open a terminal (or command prompt) and navigate to the directory where the file is saved.\n", + "3. Compile the program using a C compiler, for example, if using GCC:\n", + " ```sh\n", + " gcc hello.c -o hello\n", + " ```\n", + "4. Run the compiled program:\n", + " ```sh\n", + " ./hello\n", + " ```\n", "\n", - "To compile and run this program, you can use a C compiler such as GCC:\n", + "You should see the output:\n", "```\n", - "$ gcc hello.c -o hello\n", - "$ ./hello\n", "Hello, World!\n", - "```\n", - "This will compile the `hello.c` file and create an executable file called `hello`, which you can then run to see the output.\n" + "```\n" ] } ], "source": [ - "from tapeagents.llms import LLAMA\n", + "llm_stream = LiteLLM(model_name=\"gpt-4o-mini-2024-07-18\", stream=True)\n", "\n", - "llama = LLAMA(\n", - " base_url=\"https://api.together.xyz\",\n", - " model_name=\"meta-llama/Meta-Llama-3-70B-Instruct-Turbo\",\n", - " tokenizer_name=\"meta-llama/Meta-Llama-3-70B-Instruct\",\n", - " # you must use stream=True if you wish to have message chunks in your LLM events\n", - " stream=True,\n", - ")\n", "# Streaming\n", "prompt = Prompt(messages=[{\"role\": \"user\", \"content\": \"Write hello world in Java\"}])\n", - "for event in llama.generate(prompt):\n", + "for event in llm_stream.generate(prompt):\n", " print(event.chunk, end=\"\")\n", + "\n", "# No streaming\n", "# (note: you can not use Prompt object for more than 1 LLM call in TapeAgents)\n", "prompt = Prompt(messages=[{\"role\": \"user\", \"content\": \"Write hello world in C\"}])\n", "print(\"\\n\" + \"-\" * 30)\n", - "print(llama.generate(prompt).get_text())\n" + "print(llm_stream.generate(prompt).get_text())" ] }, { @@ -594,10 +536,10 @@ "execution_count": 7, "metadata": { "execution": { - "iopub.execute_input": "2024-09-27T12:57:26.798421Z", - "iopub.status.busy": "2024-09-27T12:57:26.798016Z", - "iopub.status.idle": "2024-09-27T12:57:26.803991Z", - "shell.execute_reply": "2024-09-27T12:57:26.803214Z" + "iopub.execute_input": "2024-09-28T05:58:37.971243Z", + "iopub.status.busy": "2024-09-28T05:58:37.971119Z", + "iopub.status.idle": "2024-09-28T05:58:37.973575Z", + "shell.execute_reply": "2024-09-28T05:58:37.973328Z" } }, "outputs": [ @@ -614,7 +556,7 @@ "source": [ "print((user := UserStep(content=\"hi AI!\")).llm_dict())\n", "print((assistant := AssistantStep(content=\"hello human\")).llm_dict())\n", - "print(tape_to_messages(DialogTape(steps=[user, assistant])))\n" + "print(tape_to_messages(DialogTape(steps=[user, assistant])))" ] }, { @@ -629,10 +571,10 @@ "execution_count": 8, "metadata": { "execution": { - "iopub.execute_input": "2024-09-27T12:57:26.807214Z", - "iopub.status.busy": "2024-09-27T12:57:26.806873Z", - "iopub.status.idle": "2024-09-27T12:57:26.813613Z", - "shell.execute_reply": "2024-09-27T12:57:26.812961Z" + "iopub.execute_input": "2024-09-28T05:58:37.974863Z", + "iopub.status.busy": "2024-09-28T05:58:37.974675Z", + "iopub.status.idle": "2024-09-28T05:58:39.404604Z", + "shell.execute_reply": "2024-09-28T05:58:39.404268Z" } }, "outputs": [ @@ -641,21 +583,27 @@ "output_type": "stream", "text": [ "--- ALL TEXT ---\n", - "<|begin_of_text|><|start_header_id|>user<|end_header_id|>\n", - "\n", - "Say bla 3 times and foo 2 times<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n", - "\n", - "Sure! Let me say bla bla bla foo foo<|eot_id|>\n", + "<|user|>\n", + "Say bla 3 times and foo 2 times<|end|>\n", + "<|endoftext|><|assistant|>\n", + "Sure! Let me say bla bla bla foo foo<|end|>\n", + "<|endoftext|>\n", "--- PREDICTED CHARACTERS ---\n", - "<|start_header_id|>assistant<|end_header_id|>\n", - "\n", - "Sure! Let me say bla bla bla foo foo<|eot_id|>\n" + "<|assistant|>\n", + "Sure! Let me say bla bla bla foo foo<|end|>\n", + "<|endoftext|>\n" ] } ], "source": [ "from tapeagents.core import LLMOutput\n", + "from tapeagents.llms import TrainableLLM\n", "\n", + "trainable_llm = TrainableLLM(\n", + " base_url=\"\", # we only use the tokenizer from the model here, no need for a base_url for inference\n", + " model_name=\"microsoft/Phi-3.5-MoE-instruct\",\n", + " tokenizer_name=\"microsoft/Phi-3.5-MoE-instruct\",\n", + ")\n", "\n", "simple_tape = DialogTape(\n", " steps=[\n", @@ -663,13 +611,14 @@ " AssistantStep(content=\"Sure! Let me say bla bla bla foo foo\"),\n", " ]\n", ")\n", + "\n", "prompt = Prompt(messages=tape_to_messages(simple_tape[:1]))\n", "output = agent.make_llm_output(simple_tape, index=1)\n", - "text = llama.make_training_text(prompt=prompt, output=output)\n", + "text = trainable_llm.make_training_text(prompt=prompt, output=output)\n", "print(\"--- ALL TEXT ---\")\n", "print(text.text)\n", "print(\"--- PREDICTED CHARACTERS ---\")\n", - "print(text.output_text)\n" + "print(text.output_text)" ] }, { @@ -683,7 +632,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "A node represents an uninterruptible atom of TapeAgent's computation. When TapeAgents runs a node, it uses its two main functions: `make_prompt` to create LLM Prompt from the tape and `generate_steps` to create new steps from the LLM output. To build a node, you can replace the default implementations of these functions using `with_prompt` and `with_generate_steps` methods. Or you can subclass `Node` and override these functions. Note that `generate_steps` must be a generator, a design choice we made to make TapeAgents a streaming-friendly framework. \n", + "A node represents an uninterruptible atom of TapeAgent's computation. When TapeAgents runs a node, it uses its two main functions: `make_prompt` to create LLM Prompt from the tape and `generate_steps` to create new steps from the LLM output. To build a node, you can subclass `Node` and override these functions. Note that `generate_steps` must be a generator, a design choice we made to make TapeAgents a streaming-friendly framework. \n", "\n", "Let's see what the node from the above example can do." ] @@ -693,10 +642,10 @@ "execution_count": 9, "metadata": { "execution": { - "iopub.execute_input": "2024-09-27T12:57:26.816715Z", - "iopub.status.busy": "2024-09-27T12:57:26.816392Z", - "iopub.status.idle": "2024-09-27T12:57:28.596210Z", - "shell.execute_reply": "2024-09-27T12:57:28.595302Z" + "iopub.execute_input": "2024-09-28T05:58:39.406260Z", + "iopub.status.busy": "2024-09-28T05:58:39.406072Z", + "iopub.status.idle": "2024-09-28T05:58:42.232598Z", + "shell.execute_reply": "2024-09-28T05:58:42.231897Z" } }, "outputs": [ @@ -705,10 +654,10 @@ "output_type": "stream", "text": [ "Raw node prompt:\n", - "id='028e3269-3d07-4725-970d-938535f5e009' tools=None messages=[{'role': 'user', 'content': 'Hi, AI!'}]\n", + "id='b0fb6cc2-5aa2-49dd-89bc-62a41b18f6c7' tools=None messages=[{'role': 'user', 'content': 'Hi, AI!'}]\n", "\n", "Steps produced by node's generator:\n", - "[AssistantStep(metadata=StepMetadata(id='dc2542d8-cacb-4125-9e42-cc3b42b9a3f8', prompt_id='', node='', agent='', other={}), content='Hello, human!', kind='assistant'), SetNextNode(metadata=StepMetadata(id='dc2542d8-cacb-4125-9e42-cc3b42b9a3f8', prompt_id='', node='', agent='', other={}), kind='set_next_node', next_node=0)]\n", + "[AssistantStep(metadata=StepMetadata(id='91442152-ddea-43a7-9630-7f18b46caa9a', prompt_id='', node='', agent='', other={}), content='Hello, human!', kind='assistant'), SetNextNode(metadata=StepMetadata(id='91442152-ddea-43a7-9630-7f18b46caa9a', prompt_id='', node='', agent='', other={}), kind='set_next_node', next_node=0)]\n", "\n", "Produced Steps:\n" ] @@ -719,18 +668,18 @@ "text": [ "{\n", " \"metadata\": {\n", - " \"id\": \"dc2542d8-cacb-4125-9e42-cc3b42b9a3f8\",\n", + " \"id\": \"91442152-ddea-43a7-9630-7f18b46caa9a\",\n", " \"prompt_id\": \"\",\n", " \"node\": \"\",\n", " \"agent\": \"\",\n", " \"other\": {}\n", " },\n", - " \"content\": \"Hi! It's nice to meet you. Is there something I can help you with, or would you like to chat?\",\n", + " \"content\": \"Hello! How can I assist you today?\",\n", " \"kind\": \"assistant\"\n", "}\n", "{\n", " \"metadata\": {\n", - " \"id\": \"dc2542d8-cacb-4125-9e42-cc3b42b9a3f8\",\n", + " \"id\": \"91442152-ddea-43a7-9630-7f18b46caa9a\",\n", " \"prompt_id\": \"\",\n", " \"node\": \"\",\n", " \"agent\": \"\",\n", @@ -746,16 +695,16 @@ "from tapeagents.llms import LLMEvent\n", "\n", "\n", - "def make_prompt(agent, tape: DialogTape) -> Prompt:\n", - " return Prompt(messages=tape_to_messages(tape))\n", - "\n", + "class MainNode(Node):\n", + " def make_prompt(self, agent, tape: DialogTape) -> Prompt:\n", + " return Prompt(messages=tape_to_messages(tape))\n", "\n", - "def generate_steps(agent, tape, llm_stream: LLMStream):\n", - " yield AssistantStep(content=llm_stream.get_text())\n", - " yield SetNextNode(next_node=0) # Continue to the same first node\n", + " def generate_steps(self, agent, tape, llm_stream: LLMStream):\n", + " yield AssistantStep(content=llm_stream.get_text())\n", + " yield SetNextNode(next_node=0) # Continue to the same first node\n", "\n", "\n", - "node = Node().with_prompt(make_prompt).with_generate_steps(generate_steps)\n", + "node = MainNode()\n", "\n", "# Let's run \"make_prompt\" in isolation.\n", "prompt = node.make_prompt(agent=None, tape=DialogTape(steps=[UserStep(content=\"Hi, AI!\")]))\n", @@ -777,11 +726,11 @@ "start_tape = DialogTape(steps=[UserStep(content=\"Hi, AI!\")])\n", "prompt = node.make_prompt(agent, start_tape)\n", "# Step 2: construct the LLMStream from the prompt (happens inside the agent)\n", - "stream = llama.generate(prompt)\n", + "stream = llm.generate(prompt)\n", "# Step 3: generate steps that the agent will then add to the tape\n", "print(\"Produced Steps:\")\n", "for step in node.generate_steps(agent, start_tape, stream):\n", - " print(step.model_dump_json(indent=2))\n" + " print(step.model_dump_json(indent=2))" ] }, { @@ -803,10 +752,10 @@ "execution_count": 10, "metadata": { "execution": { - "iopub.execute_input": "2024-09-27T12:57:28.599688Z", - "iopub.status.busy": "2024-09-27T12:57:28.599345Z", - "iopub.status.idle": "2024-09-27T12:57:28.606423Z", - "shell.execute_reply": "2024-09-27T12:57:28.605716Z" + "iopub.execute_input": "2024-09-28T05:58:42.235113Z", + "iopub.status.busy": "2024-09-28T05:58:42.234866Z", + "iopub.status.idle": "2024-09-28T05:58:42.241070Z", + "shell.execute_reply": "2024-09-28T05:58:42.240628Z" } }, "outputs": [ @@ -815,32 +764,45 @@ "output_type": "stream", "text": [ "0\n", - "0\n", + "1\n", "0\n" ] } ], "source": [ "from tapeagents.view import TapeViewStack\n", + "from tapeagents.core import StepMetadata\n", "\n", "# The \"top\" view in the tape view stack is the view of current agent. Initially `top.next_node` is 0\".\n", "tape1 = DialogTape(steps=[UserStep(content=\"Hi, AI!\")])\n", - "print(TapeViewStack.compute(tape1).top.next_node)\n", + "next_node1 = TapeViewStack.compute(tape1).top.next_node\n", + "print(next_node1)\n", + "assert next_node1 == 0\n", + "\n", "\n", "# When the agent computes the view, it bumps up `top.next_node` every time it encounters a step with a new `prompt_id``.\n", "# The new prompt_id on the tape signals to the agent the current node has run.\n", - "tape2 = DialogTape(steps=[UserStep(content=\"Hi, AI!\"), AssistantStep(prompt_id=\"123\", content=\"AI here, how I can help?\")])\n", - "print(TapeViewStack.compute(tape2).top.next_node)\n", + "tape2 = DialogTape(\n", + " steps=[\n", + " UserStep(content=\"Hi, AI!\"),\n", + " AssistantStep(metadata=StepMetadata(prompt_id=\"123\"), content=\"AI here, how I can help?\"),\n", + " ]\n", + ")\n", + "next_node2 = TapeViewStack.compute(tape2).top.next_node\n", + "print(next_node2)\n", + "assert next_node2 == 1\n", "\n", "# The SetNextNode step on the tape changes `top.next_node` to the value of the `next_node` field in the SetNextNode step.\n", "tape3 = DialogTape(\n", " steps=[\n", " UserStep(content=\"Hi, AI!\"),\n", - " AssistantStep(prompt_id=\"123\", content=\"AI here, how I can help?\"),\n", + " AssistantStep(metadata=StepMetadata(prompt_id=\"123\"), content=\"AI here, how I can help?\"),\n", " SetNextNode(next_node=0),\n", " ]\n", ")\n", - "print(TapeViewStack.compute(tape3).top.next_node)\n" + "next_node3 = TapeViewStack.compute(tape3).top.next_node\n", + "print(next_node3)\n", + "assert next_node3 == 0" ] }, { @@ -855,10 +817,10 @@ "execution_count": 11, "metadata": { "execution": { - "iopub.execute_input": "2024-09-27T12:57:28.609135Z", - "iopub.status.busy": "2024-09-27T12:57:28.608841Z", - "iopub.status.idle": "2024-09-27T12:57:28.613489Z", - "shell.execute_reply": "2024-09-27T12:57:28.612845Z" + "iopub.execute_input": "2024-09-28T05:58:42.243116Z", + "iopub.status.busy": "2024-09-28T05:58:42.242789Z", + "iopub.status.idle": "2024-09-28T05:58:42.246142Z", + "shell.execute_reply": "2024-09-28T05:58:42.245673Z" } }, "outputs": [], @@ -868,7 +830,7 @@ "\n", "assert all([issubclass(step_class, Action) for step_class in [AssistantStep, ToolCalls]])\n", "assert all([issubclass(step_class, Thought) for step_class in [AssistantThought, SetNextNode, Pass]])\n", - "assert all([issubclass(step_class, Observation) for step_class in [UserStep, ToolResult]])\n" + "assert all([issubclass(step_class, Observation) for step_class in [UserStep, ToolResult]])" ] }, { @@ -906,10 +868,10 @@ "execution_count": 12, "metadata": { "execution": { - "iopub.execute_input": "2024-09-27T12:57:28.616339Z", - "iopub.status.busy": "2024-09-27T12:57:28.616028Z", - "iopub.status.idle": "2024-09-27T12:57:31.204081Z", - "shell.execute_reply": "2024-09-27T12:57:31.203431Z" + "iopub.execute_input": "2024-09-28T05:58:42.247858Z", + "iopub.status.busy": "2024-09-28T05:58:42.247728Z", + "iopub.status.idle": "2024-09-28T05:58:43.550232Z", + "shell.execute_reply": "2024-09-28T05:58:43.549351Z" } }, "outputs": [ @@ -919,8 +881,8 @@ "text": [ "{\n", " \"metadata\": {\n", - " \"id\": \"6f112856-9ae1-466a-98e7-e51ca3819177\",\n", - " \"parent_id\": \"c440926d-3bbe-4b4d-a870-8a4642d90b75\",\n", + " \"id\": \"96e5db2a-62fd-4d62-887c-6eeb876fb88d\",\n", + " \"parent_id\": \"364c7ab1-c271-4bb9-83ee-12b2a3cdd8e0\",\n", " \"author\": \"\",\n", " \"author_tape_id\": null,\n", " \"n_added_steps\": 2,\n", @@ -931,7 +893,7 @@ " \"steps\": [\n", " {\n", " \"metadata\": {\n", - " \"id\": \"dc2542d8-cacb-4125-9e42-cc3b42b9a3f8\",\n", + " \"id\": \"91442152-ddea-43a7-9630-7f18b46caa9a\",\n", " \"prompt_id\": \"\",\n", " \"node\": \"\",\n", " \"agent\": \"\",\n", @@ -942,19 +904,19 @@ " },\n", " {\n", " \"metadata\": {\n", - " \"id\": \"dc2542d8-cacb-4125-9e42-cc3b42b9a3f8\",\n", - " \"prompt_id\": \"3b2f7f58-a41e-4b6d-b6c4-b960b2159f59\",\n", + " \"id\": \"91442152-ddea-43a7-9630-7f18b46caa9a\",\n", + " \"prompt_id\": \"927e2727-f2a3-4b3d-853c-8248a7ce9bdf\",\n", " \"node\": \"\",\n", " \"agent\": \"Agent\",\n", " \"other\": {}\n", " },\n", - " \"content\": \"Vulcan is a fictional planet in the \\\"Star Trek\\\" universe, primarily known as the homeworld of the Vulcan species, including the iconic character Spock. The planet is characterized by its harsh desert environment, advanced technology, and a culture that values logic and reason over emotions. Vulcans are known for their distinct pointed ears and rituals, such as the Kolinahr, which involves the suppression of emotion to achieve mental clarity and discipline.\",\n", + " \"content\": \"Vulcan is a fictional planet in the \\\"Star Trek\\\" universe, primarily known as the home world of the Vulcan species, including the iconic character Spock. The planet is characterized by its arid and mountainous terrain, as well as its rich cultural history emphasizing logic, peace, and emotional control, which are fundamental to Vulcan philosophy. As a prominent civilization in the Federation, Vulcan plays a crucial role in intergalactic diplomacy and exploration, showcasing advanced science and technology.\",\n", " \"kind\": \"assistant\"\n", " },\n", " {\n", " \"metadata\": {\n", - " \"id\": \"dc2542d8-cacb-4125-9e42-cc3b42b9a3f8\",\n", - " \"prompt_id\": \"3b2f7f58-a41e-4b6d-b6c4-b960b2159f59\",\n", + " \"id\": \"91442152-ddea-43a7-9630-7f18b46caa9a\",\n", + " \"prompt_id\": \"927e2727-f2a3-4b3d-853c-8248a7ce9bdf\",\n", " \"node\": \"\",\n", " \"agent\": \"Agent\",\n", " \"other\": {}\n", @@ -964,7 +926,7 @@ " },\n", " {\n", " \"metadata\": {\n", - " \"id\": \"dc2542d8-cacb-4125-9e42-cc3b42b9a3f8\",\n", + " \"id\": \"91442152-ddea-43a7-9630-7f18b46caa9a\",\n", " \"prompt_id\": \"\",\n", " \"node\": \"\",\n", " \"agent\": \"\",\n", @@ -975,19 +937,19 @@ " },\n", " {\n", " \"metadata\": {\n", - " \"id\": \"dc2542d8-cacb-4125-9e42-cc3b42b9a3f8\",\n", - " \"prompt_id\": \"0ae5c435-d2d6-4c27-a406-ee4aece9c020\",\n", + " \"id\": \"91442152-ddea-43a7-9630-7f18b46caa9a\",\n", + " \"prompt_id\": \"299d8373-3d3b-49ff-9e0f-1b4e638b01a1\",\n", " \"node\": \"\",\n", " \"agent\": \"Agent\",\n", " \"other\": {}\n", " },\n", - " \"content\": \"Vulcan Inc. is a company founded by the late Paul Allen, co-founder of Microsoft, focused on a variety of initiatives, including technology, research, and philanthropy. It operates across several sectors, including sustainability, conservation, and scientific research, with the mission of addressing some of the world’s most pressing challenges. Vulcan is known for its commitment to innovative solutions, such as the development of advanced technologies and funding for projects that promote environmental and social betterment.\",\n", + " \"content\": \"Vulcan Inc. is a company founded by Paul Allen, co-founder of Microsoft, that focuses on various initiatives in technology, science, and philanthropy. The company is involved in diverse sectors, including real estate, investments in innovative technology companies, and environmental conservation efforts, such as climate change mitigation and wildlife protection. Vulcan aims to make a positive impact on society by leveraging technology and investing in projects that promote sustainability and social good.\",\n", " \"kind\": \"assistant\"\n", " },\n", " {\n", " \"metadata\": {\n", - " \"id\": \"dc2542d8-cacb-4125-9e42-cc3b42b9a3f8\",\n", - " \"prompt_id\": \"0ae5c435-d2d6-4c27-a406-ee4aece9c020\",\n", + " \"id\": \"91442152-ddea-43a7-9630-7f18b46caa9a\",\n", + " \"prompt_id\": \"299d8373-3d3b-49ff-9e0f-1b4e638b01a1\",\n", " \"node\": \"\",\n", " \"agent\": \"Agent\",\n", " \"other\": {}\n", @@ -1003,7 +965,7 @@ "source": [ "tape_to_continue = final_tape + [UserStep(content=\"No, I mean Vulcan the company\")]\n", "continued_tape = agent.run(tape_to_continue).get_final_tape()\n", - "print(continued_tape.model_dump_json(indent=2))\n" + "print(continued_tape.model_dump_json(indent=2))" ] }, { @@ -1029,10 +991,10 @@ "execution_count": 13, "metadata": { "execution": { - "iopub.execute_input": "2024-09-27T12:57:31.206922Z", - "iopub.status.busy": "2024-09-27T12:57:31.206653Z", - "iopub.status.idle": "2024-09-27T12:57:31.704931Z", - "shell.execute_reply": "2024-09-27T12:57:31.704369Z" + "iopub.execute_input": "2024-09-28T05:58:43.553199Z", + "iopub.status.busy": "2024-09-28T05:58:43.552982Z", + "iopub.status.idle": "2024-09-28T05:58:43.726999Z", + "shell.execute_reply": "2024-09-28T05:58:43.726735Z" } }, "outputs": [ @@ -1042,21 +1004,21 @@ "

Metadata

Show / Hide
author: ''\n", "author_tape_id: null\n", "error: null\n", - "id: 6f112856-9ae1-466a-98e7-e51ca3819177\n", + "id: 96e5db2a-62fd-4d62-887c-6eeb876fb88d\n", "n_added_steps: 2\n", - "parent_id: c440926d-3bbe-4b4d-a870-8a4642d90b75\n", + "parent_id: 364c7ab1-c271-4bb9-83ee-12b2a3cdd8e0\n", "result: null\n", "

Steps

[0] User

kind: user\n",
        "\n",
        "Tell me about Vulcan in 3 sentences

[1] Assistant

kind: assistant\n",
        "\n",
-       "Vulcan is a fictional planet in the \"Star Trek\" universe, primarily known as the homeworld of the Vulcan species, including the iconic character Spock. The planet is characterized by its harsh desert environment, advanced technology, and a culture that values logic and reason over emotions. Vulcans are known for their distinct pointed ears and rituals, such as the Kolinahr, which involves the suppression of emotion to achieve mental clarity and discipline.

[2] Thought: SetNextNode

kind: set_next_node\n",
+       "Vulcan is a fictional planet in the \"Star Trek\" universe, primarily known as the home world of the Vulcan species, including the iconic character Spock. The planet is characterized by its arid and mountainous terrain, as well as its rich cultural history emphasizing logic, peace, and emotional control, which are fundamental to Vulcan philosophy. As a prominent civilization in the Federation, Vulcan plays a crucial role in intergalactic diplomacy and exploration, showcasing advanced science and technology.

[2] Thought: SetNextNode

kind: set_next_node\n",
        "next_node: 0\n",
        "

[3] User

kind: user\n",
        "\n",
        "No, I mean Vulcan the company

[4] Assistant

kind: assistant\n",
        "\n",
-       "Vulcan Inc. is a company founded by the late Paul Allen, co-founder of Microsoft, focused on a variety of initiatives, including technology, research, and philanthropy. It operates across several sectors, including sustainability, conservation, and scientific research, with the mission of addressing some of the world’s most pressing challenges. Vulcan is known for its commitment to innovative solutions, such as the development of advanced technologies and funding for projects that promote environmental and social betterment.

[5] Thought: SetNextNode

kind: set_next_node\n",
+       "Vulcan Inc. is a company founded by Paul Allen, co-founder of Microsoft, that focuses on various initiatives in technology, science, and philanthropy. The company is involved in diverse sectors, including real estate, investments in innovative technology companies, and environmental conservation efforts, such as climate change mitigation and wildlife protection. Vulcan aims to make a positive impact on society by leveraging technology and investing in projects that promote sustainability and social good.

[5] Thought: SetNextNode

kind: set_next_node\n",
        "next_node: 0\n",
        "
" ], @@ -1073,7 +1035,7 @@ "from tapeagents.rendering import PrettyRenderer, render_tape_with_prompts\n", "from IPython.display import HTML\n", "\n", - "HTML(render_tape_with_prompts(continued_tape, PrettyRenderer()))\n" + "HTML(render_tape_with_prompts(continued_tape, PrettyRenderer()))" ] }, { @@ -1095,10 +1057,10 @@ "execution_count": 14, "metadata": { "execution": { - "iopub.execute_input": "2024-09-27T12:57:31.707463Z", - "iopub.status.busy": "2024-09-27T12:57:31.707171Z", - "iopub.status.idle": "2024-09-27T12:57:47.442447Z", - "shell.execute_reply": "2024-09-27T12:57:47.441736Z" + "iopub.execute_input": "2024-09-28T05:58:43.728241Z", + "iopub.status.busy": "2024-09-28T05:58:43.728124Z", + "iopub.status.idle": "2024-09-28T05:58:48.953071Z", + "shell.execute_reply": "2024-09-28T05:58:48.952539Z" } }, "outputs": [ @@ -1115,13 +1077,13 @@ "text": [ "{\n", " \"metadata\": {\n", - " \"id\": \"dc2542d8-cacb-4125-9e42-cc3b42b9a3f8\",\n", - " \"prompt_id\": \"a1023fa2-8d0b-4790-84f9-adc966831f1a\",\n", + " \"id\": \"91442152-ddea-43a7-9630-7f18b46caa9a\",\n", + " \"prompt_id\": \"215ded85-b5e9-439a-868c-df1321da18cc\",\n", " \"node\": \"\",\n", " \"agent\": \"Agent\",\n", " \"other\": {}\n", " },\n", - " \"content\": \"1. Use the `functions.get_stock_ticker` tool to obtain the stock ticker symbol for Vulcan.\\n2. Use the `functions.get_stock_data` tool to retrieve the stock prices for Vulcan over a specified date range.\\n3. Summarize the information obtained from the stock ticker and stock data to provide a comprehensive overview of Vulcan's financials.\",\n", + " \"content\": \"To help the user learn about Vulcan's financials, I will follow these steps:\\n\\n1. Use the `get_stock_ticker` function to find the stock ticker symbol for Vulcan.\\n2. Use the `get_stock_data` function to retrieve recent stock price data for Vulcan using the obtained ticker symbol.\\n3. Summarize the financial information and stock performance of Vulcan based on the retrieved data.\\n\\nLet's start with step 1.\",\n", " \"kind\": \"assistant_thought\"\n", "}\n" ] @@ -1132,8 +1094,8 @@ "text": [ "{\n", " \"metadata\": {\n", - " \"id\": \"dc2542d8-cacb-4125-9e42-cc3b42b9a3f8\",\n", - " \"prompt_id\": \"4c715e1d-071c-402c-86d4-fa2158746fee\",\n", + " \"id\": \"91442152-ddea-43a7-9630-7f18b46caa9a\",\n", + " \"prompt_id\": \"67203041-9bbf-4494-8233-4bf26d52b27a\",\n", " \"node\": \"\",\n", " \"agent\": \"Agent\",\n", " \"other\": {}\n", @@ -1144,7 +1106,7 @@ " \"arguments\": \"{\\\"company_name\\\":\\\"Vulcan\\\"}\",\n", " \"name\": \"get_stock_ticker\"\n", " },\n", - " \"id\": \"call_S2Il5yCMNsQZyBgensfmr7dh\",\n", + " \"id\": \"call_ulmiHQvlQ2N7zZ1TJet02RJo\",\n", " \"type\": \"function\"\n", " }\n", " ],\n", @@ -1152,8 +1114,8 @@ "}\n", "{\n", " \"metadata\": {\n", - " \"id\": \"dc2542d8-cacb-4125-9e42-cc3b42b9a3f8\",\n", - " \"prompt_id\": \"4c715e1d-071c-402c-86d4-fa2158746fee\",\n", + " \"id\": \"91442152-ddea-43a7-9630-7f18b46caa9a\",\n", + " \"prompt_id\": \"67203041-9bbf-4494-8233-4bf26d52b27a\",\n", " \"node\": \"\",\n", " \"agent\": \"Agent\",\n", " \"other\": {}\n", @@ -1169,14 +1131,14 @@ "text": [ "{\n", " \"metadata\": {\n", - " \"id\": \"dc2542d8-cacb-4125-9e42-cc3b42b9a3f8\",\n", + " \"id\": \"91442152-ddea-43a7-9630-7f18b46caa9a\",\n", " \"prompt_id\": \"\",\n", " \"node\": \"\",\n", " \"agent\": \"\",\n", " \"other\": {}\n", " },\n", " \"content\": \"VMC\",\n", - " \"tool_call_id\": \"call_S2Il5yCMNsQZyBgensfmr7dh\",\n", + " \"tool_call_id\": \"call_ulmiHQvlQ2N7zZ1TJet02RJo\",\n", " \"kind\": \"tool\"\n", "}\n" ] @@ -1187,8 +1149,8 @@ "text": [ "{\n", " \"metadata\": {\n", - " \"id\": \"dc2542d8-cacb-4125-9e42-cc3b42b9a3f8\",\n", - " \"prompt_id\": \"9ff16eb9-0fd5-4a6c-936a-4fce4511a201\",\n", + " \"id\": \"91442152-ddea-43a7-9630-7f18b46caa9a\",\n", + " \"prompt_id\": \"7e1edd33-ebf9-44dc-b71c-8ef2291fecb1\",\n", " \"node\": \"\",\n", " \"agent\": \"Agent\",\n", " \"other\": {}\n", @@ -1196,10 +1158,10 @@ " \"tool_calls\": [\n", " {\n", " \"function\": {\n", - " \"arguments\": \"{\\\"symbol\\\": \\\"VMC\\\", \\\"start_date\\\": \\\"2024-01-01\\\", \\\"end_date\\\": \\\"2024-09-16\\\"}\",\n", + " \"arguments\": \"{\\\"symbol\\\":\\\"VMC\\\",\\\"start_date\\\":\\\"2024-01-01\\\",\\\"end_date\\\":\\\"2024-09-16\\\"}\",\n", " \"name\": \"get_stock_data\"\n", " },\n", - " \"id\": \"call_zXXvyYM7xrC9MDgaH44GdCbb\",\n", + " \"id\": \"call_CH708SYdZsqFf3vgKNTplOub\",\n", " \"type\": \"function\"\n", " }\n", " ],\n", @@ -1207,25 +1169,31 @@ "}\n", "{\n", " \"metadata\": {\n", - " \"id\": \"dc2542d8-cacb-4125-9e42-cc3b42b9a3f8\",\n", - " \"prompt_id\": \"9ff16eb9-0fd5-4a6c-936a-4fce4511a201\",\n", + " \"id\": \"91442152-ddea-43a7-9630-7f18b46caa9a\",\n", + " \"prompt_id\": \"7e1edd33-ebf9-44dc-b71c-8ef2291fecb1\",\n", " \"node\": \"\",\n", " \"agent\": \"Agent\",\n", " \"other\": {}\n", " },\n", " \"kind\": \"set_next_node\",\n", " \"next_node\": 1\n", - "}\n", + "}\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ "{\n", " \"metadata\": {\n", - " \"id\": \"dc2542d8-cacb-4125-9e42-cc3b42b9a3f8\",\n", + " \"id\": \"91442152-ddea-43a7-9630-7f18b46caa9a\",\n", " \"prompt_id\": \"\",\n", " \"node\": \"\",\n", " \"agent\": \"\",\n", " \"other\": {}\n", " },\n", " \"content\": \"[('2024-01-02', 223.60000610351562), ('2024-01-04', 220.67999267578125), ('2024-01-08', 224.0), ('2024-01-10', 226.11000061035156), ('2024-01-12', 223.9600067138672), ('2024-01-17', 221.25999450683594), ('2024-01-19', 226.0800018310547), ('2024-01-23', 222.8000030517578), ('2024-01-25', 223.41000366210938), ('2024-01-29', 229.3699951171875), ('2024-01-31', 226.00999450683594), ('2024-02-02', 234.44000244140625), ('2024-02-06', 231.5800018310547), ('2024-02-08', 238.44000244140625), ('2024-02-12', 240.1300048828125), ('2024-02-14', 241.10000610351562), ('2024-02-16', 255.14999389648438), ('2024-02-21', 253.42999267578125), ('2024-02-23', 257.2300109863281), ('2024-02-27', 263.55999755859375), ('2024-02-29', 265.8500061035156), ('2024-03-04', 267.8500061035156), ('2024-03-06', 267.3399963378906), ('2024-03-08', 266.70001220703125), ('2024-03-12', 269.5799865722656), ('2024-03-14', 270.7300109863281), ('2024-03-18', 269.4200134277344), ('2024-03-20', 271.739990234375), ('2024-03-22', 274.3599853515625), ('2024-03-26', 273.8699951171875), ('2024-03-28', 272.9200134277344), ('2024-04-02', 266.25), ('2024-04-04', 265.8900146484375), ('2024-04-08', 269.7200012207031), ('2024-04-10', 264.55999755859375), ('2024-04-12', 262.7799987792969), ('2024-04-16', 258.5400085449219), ('2024-04-18', 255.07000732421875), ('2024-04-22', 254.47999572753906), ('2024-04-24', 256.3999938964844), ('2024-04-26', 261.239990234375), ('2024-04-30', 257.6300048828125), ('2024-05-02', 264.4100036621094), ('2024-05-06', 266.6099853515625), ('2024-05-08', 267.92999267578125), ('2024-05-10', 272.07000732421875), ('2024-05-14', 267.75), ('2024-05-16', 260.0), ('2024-05-20', 260.2099914550781), ('2024-05-22', 260.8699951171875), ('2024-05-24', 259.25), ('2024-05-29', 251.91000366210938), ('2024-05-31', 255.77000427246094), ('2024-06-04', 250.4600067138672), ('2024-06-06', 248.5800018310547), ('2024-06-10', 247.80999755859375), ('2024-06-12', 249.1199951171875), ('2024-06-14', 252.63999938964844), ('2024-06-18', 255.61000061035156), ('2024-06-21', 247.80999755859375), ('2024-06-25', 246.14999389648438), ('2024-06-27', 247.75999450683594), ('2024-07-01', 243.72000122070312), ('2024-07-03', 243.9199981689453), ('2024-07-08', 241.97000122070312), ('2024-07-10', 247.72000122070312), ('2024-07-12', 252.50999450683594), ('2024-07-16', 262.80999755859375), ('2024-07-18', 256.0899963378906), ('2024-07-22', 260.6099853515625), ('2024-07-24', 250.50999450683594), ('2024-07-26', 261.7099914550781), ('2024-07-30', 270.0), ('2024-08-01', 271.1300048828125), ('2024-08-05', 257.42999267578125), ('2024-08-07', 241.22000122070312), ('2024-08-09', 244.33999633789062), ('2024-08-13', 243.83999633789062), ('2024-08-15', 246.57000732421875), ('2024-08-19', 244.2899932861328), ('2024-08-21', 247.83999633789062), ('2024-08-23', 254.88999938964844), ('2024-08-27', 240.41000366210938), ('2024-08-29', 241.27999877929688), ('2024-09-03', 239.02000427246094), ('2024-09-05', 232.16000366210938), ('2024-09-09', 231.8300018310547), ('2024-09-11', 232.9499969482422), ('2024-09-13', 237.47000122070312)]\",\n", - " \"tool_call_id\": \"call_zXXvyYM7xrC9MDgaH44GdCbb\",\n", + " \"tool_call_id\": \"call_CH708SYdZsqFf3vgKNTplOub\",\n", " \"kind\": \"tool\"\n", "}\n" ] @@ -1236,19 +1204,19 @@ "text": [ "{\n", " \"metadata\": {\n", - " \"id\": \"dc2542d8-cacb-4125-9e42-cc3b42b9a3f8\",\n", - " \"prompt_id\": \"d021fdef-b8fa-4431-be17-e36cdd5d22b6\",\n", + " \"id\": \"91442152-ddea-43a7-9630-7f18b46caa9a\",\n", + " \"prompt_id\": \"db4c698b-efd0-4d36-993e-e03210bf28fb\",\n", " \"node\": \"\",\n", " \"agent\": \"Agent\",\n", " \"other\": {}\n", " },\n", - " \"content\": \"Vulcan Materials Company, trading under the stock ticker symbol VMC, is a major producer of construction aggregates, primarily crushed stone, sand, and gravel. Over the course of 2024, Vulcan's stock price has shown significant fluctuations, starting at approximately $223.60 in early January and reaching highs of around $274.36 in late March, before experiencing a decline to around $237.47 by mid-September. This volatility reflects the dynamic nature of the construction materials market and the broader economic conditions impacting the industry.\",\n", + " \"content\": \"Vulcan Materials Company, trading under the ticker symbol VMC, is a major producer of construction aggregates, primarily crushed stone, sand, and gravel. Over the course of 2024, Vulcan's stock price has shown significant fluctuations, starting at approximately $223.60 in early January and reaching a high of around $274.36 in late March, before experiencing a decline to about $237.47 by mid-September. This performance reflects the company's market dynamics and the broader economic conditions impacting the construction and materials sector.\",\n", " \"kind\": \"assistant\"\n", "}\n", "{\n", " \"metadata\": {\n", - " \"id\": \"dc2542d8-cacb-4125-9e42-cc3b42b9a3f8\",\n", - " \"prompt_id\": \"d021fdef-b8fa-4431-be17-e36cdd5d22b6\",\n", + " \"id\": \"91442152-ddea-43a7-9630-7f18b46caa9a\",\n", + " \"prompt_id\": \"db4c698b-efd0-4d36-993e-e03210bf28fb\",\n", " \"node\": \"\",\n", " \"agent\": \"Agent\",\n", " \"other\": {}\n", @@ -1265,43 +1233,47 @@ "

Metadata

Show / Hide
author: ''\n", "author_tape_id: null\n", "error: null\n", - "id: d6a44106-f901-4d77-a14a-613bcbea2516\n", + "id: 51dbf27c-4bc8-4263-a3b3-84f15093f497\n", "n_added_steps: 2\n", - "parent_id: 073e9421-c83c-48f9-b24c-2205b5bcdb0e\n", + "parent_id: c0b88308-8ca7-49fe-ada6-cf9dd29937f0\n", "result: null\n", "

Steps

[0] User

kind: user\n",
        "\n",
        "Tell me about Vulcan in 3 sentences

[1] Thought: AssistantThought

kind: assistant_thought\n",
        "\n",
-       "1. Use the `functions.get_stock_ticker` tool to obtain the stock ticker symbol for Vulcan.\n",
-       "2. Use the `functions.get_stock_data` tool to retrieve the stock prices for Vulcan over a specified date range.\n",
-       "3. Summarize the information obtained from the stock ticker and stock data to provide a comprehensive overview of Vulcan's financials.

[2] Action: ToolCalls

tool_calls:\n",
+       "To help the user learn about Vulcan's financials, I will follow these steps:\n",
+       "\n",
+       "1. Use the `get_stock_ticker` function to find the stock ticker symbol for Vulcan.\n",
+       "2. Use the `get_stock_data` function to retrieve recent stock price data for Vulcan using the obtained ticker symbol.\n",
+       "3. Summarize the financial information and stock performance of Vulcan based on the retrieved data.\n",
+       "\n",
+       "Let's start with step 1.

[2] Action: ToolCalls

tool_calls:\n",
        "- function:\n",
        "    arguments: '{\"company_name\":\"Vulcan\"}'\n",
        "    name: get_stock_ticker\n",
-       "  id: call_S2Il5yCMNsQZyBgensfmr7dh\n",
+       "  id: call_ulmiHQvlQ2N7zZ1TJet02RJo\n",
        "  type: function\n",
        "kind: assistant\n",
        "

[3] Thought: SetNextNode

kind: set_next_node\n",
        "next_node: 1\n",
-       "

[4] Observation: ToolResult

tool_call_id: call_S2Il5yCMNsQZyBgensfmr7dh\n",
+       "

[4] Observation: ToolResult

tool_call_id: call_ulmiHQvlQ2N7zZ1TJet02RJo\n",
        "kind: tool\n",
        "\n",
        "VMC

[5] Action: ToolCalls

tool_calls:\n",
        "- function:\n",
-       "    arguments: '{\"symbol\": \"VMC\", \"start_date\": \"2024-01-01\", \"end_date\": \"2024-09-16\"}'\n",
+       "    arguments: '{\"symbol\":\"VMC\",\"start_date\":\"2024-01-01\",\"end_date\":\"2024-09-16\"}'\n",
        "    name: get_stock_data\n",
-       "  id: call_zXXvyYM7xrC9MDgaH44GdCbb\n",
+       "  id: call_CH708SYdZsqFf3vgKNTplOub\n",
        "  type: function\n",
        "kind: assistant\n",
        "

[6] Thought: SetNextNode

kind: set_next_node\n",
        "next_node: 1\n",
-       "

[7] Observation: ToolResult

tool_call_id: call_zXXvyYM7xrC9MDgaH44GdCbb\n",
+       "

[7] Observation: ToolResult

tool_call_id: call_CH708SYdZsqFf3vgKNTplOub\n",
        "kind: tool\n",
        "\n",
        "
3088 characters ...[('2024-01-02', 223.60000610351562), ('2024-01-04', 220.67999267578125), ('2024-01-08', 224.0), ('2024-01-10', 226.11000061035156), ('2024-01-12', 223.9600067138672), ('2024-01-17', 221.25999450683594), ('2024-01-19', 226.0800018310547), ('2024-01-23', 222.8000030517578), ('2024-01-25', 223.41000366210938), ('2024-01-29', 229.3699951171875), ('2024-01-31', 226.00999450683594), ('2024-02-02', 234.44000244140625), ('2024-02-06', 231.5800018310547), ('2024-02-08', 238.44000244140625), ('2024-02-12', 240.1300048828125), ('2024-02-14', 241.10000610351562), ('2024-02-16', 255.14999389648438), ('2024-02-21', 253.42999267578125), ('2024-02-23', 257.2300109863281), ('2024-02-27', 263.55999755859375), ('2024-02-29', 265.8500061035156), ('2024-03-04', 267.8500061035156), ('2024-03-06', 267.3399963378906), ('2024-03-08', 266.70001220703125), ('2024-03-12', 269.5799865722656), ('2024-03-14', 270.7300109863281), ('2024-03-18', 269.4200134277344), ('2024-03-20', 271.739990234375), ('2024-03-22', 274.3599853515625), ('2024-03-26', 273.8699951171875), ('2024-03-28', 272.9200134277344), ('2024-04-02', 266.25), ('2024-04-04', 265.8900146484375), ('2024-04-08', 269.7200012207031), ('2024-04-10', 264.55999755859375), ('2024-04-12', 262.7799987792969), ('2024-04-16', 258.5400085449219), ('2024-04-18', 255.07000732421875), ('2024-04-22', 254.47999572753906), ('2024-04-24', 256.3999938964844), ('2024-04-26', 261.239990234375), ('2024-04-30', 257.6300048828125), ('2024-05-02', 264.4100036621094), ('2024-05-06', 266.6099853515625), ('2024-05-08', 267.92999267578125), ('2024-05-10', 272.07000732421875), ('2024-05-14', 267.75), ('2024-05-16', 260.0), ('2024-05-20', 260.2099914550781), ('2024-05-22', 260.8699951171875), ('2024-05-24', 259.25), ('2024-05-29', 251.91000366210938), ('2024-05-31', 255.77000427246094), ('2024-06-04', 250.4600067138672), ('2024-06-06', 248.5800018310547), ('2024-06-10', 247.80999755859375), ('2024-06-12', 249.1199951171875), ('2024-06-14', 252.63999938964844), ('2024-06-18', 255.61000061035156), ('2024-06-21', 247.80999755859375), ('2024-06-25', 246.14999389648438), ('2024-06-27', 247.75999450683594), ('2024-07-01', 243.72000122070312), ('2024-07-03', 243.9199981689453), ('2024-07-08', 241.97000122070312), ('2024-07-10', 247.72000122070312), ('2024-07-12', 252.50999450683594), ('2024-07-16', 262.80999755859375), ('2024-07-18', 256.0899963378906), ('2024-07-22', 260.6099853515625), ('2024-07-24', 250.50999450683594), ('2024-07-26', 261.7099914550781), ('2024-07-30', 270.0), ('2024-08-01', 271.1300048828125), ('2024-08-05', 257.42999267578125), ('2024-08-07', 241.22000122070312), ('2024-08-09', 244.33999633789062), ('2024-08-13', 243.83999633789062), ('2024-08-15', 246.57000732421875), ('2024-08-19', 244.2899932861328), ('2024-08-21', 247.83999633789062), ('2024-08-23', 254.88999938964844), ('2024-08-27', 240.41000366210938), ('2024-08-29', 241.27999877929688), ('2024-09-03', 239.02000427246094), ('2024-09-05', 232.16000366210938), ('2024-09-09', 231.8300018310547), ('2024-09-11', 232.9499969482422), ('2024-09-13', 237.47000122070312)]

[8] Assistant

kind: assistant\n",
        "\n",
-       "Vulcan Materials Company, trading under the stock ticker symbol VMC, is a major producer of construction aggregates, primarily crushed stone, sand, and gravel. Over the course of 2024, Vulcan's stock price has shown significant fluctuations, starting at approximately $223.60 in early January and reaching highs of around $274.36 in late March, before experiencing a decline to around $237.47 by mid-September. This volatility reflects the dynamic nature of the construction materials market and the broader economic conditions impacting the industry.

[9] Thought: SetNextNode

kind: set_next_node\n",
+       "Vulcan Materials Company, trading under the ticker symbol VMC, is a major producer of construction aggregates, primarily crushed stone, sand, and gravel. Over the course of 2024, Vulcan's stock price has shown significant fluctuations, starting at approximately $223.60 in early January and reaching a high of around $274.36 in late March, before experiencing a decline to about $237.47 by mid-September. This performance reflects the company's market dynamics and the broader economic conditions impacting the construction and materials sector.

[9] Thought: SetNextNode

kind: set_next_node\n",
        "next_node: 0\n",
        "
" ], @@ -1331,48 +1303,42 @@ "env = ToolEnvironment([get_stock_ticker, get_stock_data])\n", "\n", "\n", - "def make_planning_prompt(agent, tape: DialogTape) -> Prompt:\n", - " guidance = \"Write a natural language plan on how to use tools help the user. Output a list of numbered items, like 1., 2., 3., etc.\"\n", - " guidance_message = {\"role\": \"user\", \"content\": guidance}\n", - " return Prompt(\n", - " messages=[system_message] + tape_to_messages(tape) + [guidance_message], tools=env.get_tool_schema_dicts()\n", - " )\n", - "\n", - "\n", - "def generate_planning_steps(agent, tape, llm_stream: LLMStream):\n", - " if content := llm_stream.get_message().content:\n", - " yield AssistantThought(content=content)\n", - " else:\n", - " raise ValueError()\n", + "class PlanNode(Node):\n", + " def make_prompt(self, agent, tape: DialogTape) -> Prompt:\n", + " guidance = \"Write a natural language plan on how to use tools help the user. Output a list of numbered items, like 1., 2., 3., etc.\"\n", + " guidance_message = {\"role\": \"user\", \"content\": guidance}\n", + " return Prompt(\n", + " messages=[system_message] + tape_to_messages(tape) + [guidance_message], tools=env.get_tool_schema_dicts()\n", + " )\n", "\n", + " def generate_steps(self, agent, tape, llm_stream: LLMStream):\n", + " if content := llm_stream.get_message().content:\n", + " yield AssistantThought(content=content)\n", + " else:\n", + " raise ValueError()\n", "\n", - "def make_prompt(agent, tape: DialogTape) -> Prompt:\n", - " guidance = \"Follow the plan you created to earlier. When you are done, respond to the user.\"\n", - " guidance_message = {\"role\": \"user\", \"content\": guidance}\n", - " return Prompt(\n", - " messages=[system_message] + tape_to_messages(tape) + [guidance_message], tools=env.get_tool_schema_dicts()\n", - " )\n", "\n", + "class ActNode(Node):\n", + " def make_prompt(self, agent, tape: DialogTape) -> Prompt:\n", + " guidance = \"Follow the plan you created to earlier. When you are done, respond to the user.\"\n", + " guidance_message = {\"role\": \"user\", \"content\": guidance}\n", + " return Prompt(\n", + " messages=[system_message] + tape_to_messages(tape) + [guidance_message], tools=env.get_tool_schema_dicts()\n", + " )\n", "\n", - "def generate_steps(agent, tape, llm_stream: LLMStream):\n", - " m = llm_stream.get_message()\n", - " if m.content:\n", - " yield AssistantStep(content=m.content)\n", - " yield SetNextNode(next_node=0)\n", - " elif m.tool_calls:\n", - " yield ToolCalls(tool_calls=m.tool_calls)\n", - " yield SetNextNode(next_node=1)\n", - " else:\n", - " raise ValueError()\n", + " def generate_steps(self, agent, tape, llm_stream: LLMStream):\n", + " m = llm_stream.get_message()\n", + " if m.content:\n", + " yield AssistantStep(content=m.content)\n", + " yield SetNextNode(next_node=0)\n", + " elif m.tool_calls:\n", + " yield ToolCalls(tool_calls=m.tool_calls)\n", + " yield SetNextNode(next_node=1)\n", + " else:\n", + " raise ValueError()\n", "\n", "\n", - "agent1 = Agent.create(\n", - " LiteLLM(model_name=\"gpt-4o\", parameters={\"temperature\": 0.1}),\n", - " nodes=[\n", - " Node().with_prompt(make_planning_prompt).with_generate_steps(generate_planning_steps),\n", - " Node().with_prompt(make_prompt).with_generate_steps(generate_steps),\n", - " ],\n", - ")\n", + "agent1 = Agent.create(LiteLLM(model_name=\"gpt-4o\", parameters={\"temperature\": 0.1}), nodes=[PlanNode(), ActNode()])\n", "\n", "print(\"Run the agent!\")\n", "final_tape1 = None\n", @@ -1386,7 +1352,7 @@ " print(event.observation.model_dump_json(indent=2))\n", "assert final_tape1\n", "print(\"Final tape:\")\n", - "HTML(render_tape_with_prompts(final_tape1, PrettyRenderer()))\n" + "HTML(render_tape_with_prompts(final_tape1, PrettyRenderer()))" ] }, { @@ -1409,24 +1375,48 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Let's try building a similar agent with an open-weights LLAMA3.1 70B models. Conveniently, [Together AI](together.ai) offers API endpoints. You can create an account and get API key with some free quota.\n", + "Let's try building a similar agent with an open-weights LLAMA3 70B models. Conveniently, [Together AI](together.ai) offers API endpoints. You can create an account and get API key with some free quota." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 3.0. Setup your LLM key" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-28T05:58:48.955376Z", + "iopub.status.busy": "2024-09-28T05:58:48.955161Z", + "iopub.status.idle": "2024-09-28T05:58:48.958706Z", + "shell.execute_reply": "2024-09-28T05:58:48.958356Z" + } + }, + "outputs": [], + "source": [ + "# Set more environment variables in the .env file or set them below\n", "\n", - "We've found that LLAMA3 function-calling is not yet battle-ready. We will use the structured output approach to make it call tools instead. We are also making this agent trainable by adding `make_llm_output` methods to each node. `Node.make_llm_output` defines how a node can reconstruct the LLM completion message that would be required to make the steps from the given tape at the given index. You can think of `Node.make_llm_output` as the inverse of `Node.generate_steps`.\n", + "dotenv.load_dotenv(env_file, override=True)\n", "\n", - "When you run the code below, you might see a different behavior every time. Often the LLAMA-based agent gets stuck in a loop. We will look into how TapeAgents supports you in addressing this issue by\n", - "- tuning the prompt and resuming the agent exactly where it got stuck \n", - "- producing training text from a different agent's tape " + "# os.environ[\"TOGETHER_API_KEY\"] = \"\" # put your https://together.ai/ key here\n", + "# os.environ[\"HF_TOKEN\"] = \"\" # put your huggingface token here\n", + "\n", + "os.environ[\"TAPEAGENTS_LLM_TOKEN\"] = os.getenv(\"TOGETHER_API_KEY\", \"\") # Use Together API Key for llms.TrainableLLM" ] }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 16, "metadata": { "execution": { - "iopub.execute_input": "2024-09-27T12:57:47.445906Z", - "iopub.status.busy": "2024-09-27T12:57:47.445494Z", - "iopub.status.idle": "2024-09-27T12:57:59.440883Z", - "shell.execute_reply": "2024-09-27T12:57:59.440311Z" + "iopub.execute_input": "2024-09-28T05:58:48.960418Z", + "iopub.status.busy": "2024-09-28T05:58:48.960282Z", + "iopub.status.idle": "2024-09-28T05:58:49.033340Z", + "shell.execute_reply": "2024-09-28T05:58:49.032807Z" } }, "outputs": [ @@ -1434,64 +1424,282 @@ "name": "stdout", "output_type": "stream", "text": [ - "Run LLAMA agent!\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{\n", - " \"metadata\": {\n", - " \"id\": \"dc2542d8-cacb-4125-9e42-cc3b42b9a3f8\",\n", - " \"prompt_id\": \"866fda12-27ba-4aa1-ac3c-efe14dafd9bc\",\n", - " \"node\": \"\",\n", - " \"agent\": \"Agent\",\n", - " \"other\": {}\n", - " },\n", - " \"content\": \"Here's a plan to help the user learn about Vulcan Materials using the provided tools:\\n\\n1. First, use the `get_stock_ticker` function to retrieve the stock ticker symbol for Vulcan Materials by passing \\\"Vulcan Materials\\\" as the `company_name` parameter. This will give us the stock ticker symbol, which we'll use in the next step.\\n\\n2. Once we have the stock ticker symbol, use the `get_stock_data` function to retrieve the historical stock prices for Vulcan Materials. We can pass the stock ticker symbol, a start date (e.g., 2020-01-01), and an end date (e.g., 2024-09-17) as parameters to get the stock prices for the specified date range.\\n\\n3. Analyze the retrieved stock prices to provide an overview of Vulcan Materials' stock performance over the specified period. This could include calculating the highest and lowest prices, the overall trend, and any notable events or fluctuations in the stock price.\\n\\n4. Use the analyzed data to provide a brief summary of Vulcan Materials in three sentences, including information about the company's stock performance, industry, and any other relevant details.\\n\\nLet's execute this plan!\",\n", - " \"kind\": \"assistant_thought\"\n", - "}\n" + "The token has not been saved to the git credentials helper. Pass `add_to_git_credential=True` in this function directly or `--add-to-git-credential` if using via `huggingface-cli` if you want to set the git credential as well.\n", + "Token is valid (permission: read).\n", + "Your token has been saved to /Users/jordanprince.t/.cache/huggingface/token\n", + "Login successful\n" ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{\n", - " \"metadata\": {\n", - " \"id\": \"dc2542d8-cacb-4125-9e42-cc3b42b9a3f8\",\n", - " \"prompt_id\": \"3898aee1-20fe-462e-81e2-8642b10978d7\",\n", - " \"node\": \"\",\n", - " \"agent\": \"Agent\",\n", - " \"other\": {}\n", - " },\n", - " \"tool_calls\": [\n", - " {\n", - " \"function\": {\n", - " \"arguments\": \"{\\\"company_name\\\": \\\"Vulcan Materials\\\"}\",\n", - " \"name\": \"get_stock_ticker\"\n", - " },\n", - " \"id\": \"tool_call_0_node_starts_at_2\",\n", - " \"type\": \"function\"\n", - " }\n", - " ],\n", - " \"kind\": \"assistant\"\n", - "}\n", - "{\n", - " \"metadata\": {\n", - " \"id\": \"dc2542d8-cacb-4125-9e42-cc3b42b9a3f8\",\n", - " \"prompt_id\": \"3898aee1-20fe-462e-81e2-8642b10978d7\",\n", - " \"node\": \"\",\n", - " \"agent\": \"Agent\",\n", - " \"other\": {}\n", - " },\n", - " \"kind\": \"set_next_node\",\n", - " \"next_node\": 1\n", - "}\n", + } + ], + "source": [ + "# Login to Hugging Face Hub\n", + "if \"PYTEST_CURRENT_TEST\" not in os.environ: # skip login during tests\n", + " from huggingface_hub import login\n", + "\n", + " login(token=os.environ.get(\"HF_TOKEN\"))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Access to Hugging Face Gated Models\n", + "Make sure you have access to each model we are going to use (read more [here](https://huggingface.co/docs/hub/en/models-gated#access-gated-models-as-a-user)):\n", + "- https://huggingface.co/meta-llama/Meta-Llama-3-70B-Instruct\n", + "\n", + "##### Troubleshoot\n", + "- If you receive a 401 error, it means the authentication failed.\n", + "- If you receive a 403 error, it means you are authenticated but not authorized to access the specific model." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 3.1. Setup your Agents\n", + "\n", + "We've found that LLAMA3 function-calling is not yet battle-ready. We will use the structured output approach to make it call tools instead. We are also making this agent trainable by adding `make_llm_output` methods to each node. `Node.make_llm_output` defines how a node can reconstruct the LLM completion message that would be required to make the steps from the given tape at the given index. You can think of `Node.make_llm_output` as the inverse of `Node.generate_steps`.\n", + "\n", + "When you run the code below, you might see a different behavior every time. Often the LLAMA-based agent gets stuck in a loop. We will look into how TapeAgents supports you in addressing this issue by\n", + "- tuning the prompt and resuming the agent exactly where it got stuck \n", + "- producing training text from a different agent's tape " + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-28T05:58:49.035858Z", + "iopub.status.busy": "2024-09-28T05:58:49.035632Z", + "iopub.status.idle": "2024-09-28T05:58:49.058806Z", + "shell.execute_reply": "2024-09-28T05:58:49.058465Z" + } + }, + "outputs": [], + "source": [ + "import json\n", + "from tapeagents.core import LLMOutput\n", + "from tapeagents.llms import TrainableLLM\n", + "from litellm.utils import ChatCompletionMessageToolCall\n", + "from litellm.utils import Function\n", + "\n", + "from tapeagents.prompting import step_to_message\n", + "\n", + "env = ToolEnvironment([get_stock_ticker, get_stock_data])\n", + "\n", + "system_instruction = f\"\"\"\n", + "You will help the user to learn about financials of companies.\n", + "Use as many relevant tools as possible to include more details and facts in your responses.\n", + "Today is {today}.\n", + "\n", + "You have access to the following tools: {env.get_tool_schema_dicts()}\"\"\"\n", + "\n", + "planning_guidance = \"Write a natural language plan on how to use tools help the user. Output a list of numbered items, like 1., 2., 3., etc.\"\n", + "\n", + "call_or_respond_guidance = \"\"\"\n", + "Follow the plan you created earlier. When you are done, respond to the user.\n", + "If you want to call a or several tools, output JSON like this\n", + "{\"kind\": \"tool_call\", \"tool_name\": \"...\", \"parameters\": \"... unquoted parameters json ...\"}\n", + "If you have called all the tools in the plan, respond to the user with the JSON of the form\n", + "{\"kind\": \"response\", \"content\": \"... you response ... \"}.\n", + "Output ONE JSON OBJECT ONLY PER LINE ONLY AND NOTHING ELSE.\n", + "\"\"\"\n", + "\n", + "\n", + "class PlanNode(Node):\n", + " def make_prompt(self, agent, tape: DialogTape) -> Prompt:\n", + " system_message = {\"role\": \"system\", \"content\": system_instruction}\n", + " guidance_message = {\"role\": \"user\", \"content\": agent.templates[\"planning\"]}\n", + " return Prompt(messages=[system_message] + tape_to_messages(tape) + [guidance_message])\n", + "\n", + " def generate_steps(self, agent, tape, llm_stream: LLMStream):\n", + " if content := getattr(llm_stream.get_message(), \"content\", None):\n", + " yield AssistantThought(content=content)\n", + " else:\n", + " raise ValueError()\n", + "\n", + " def make_llm_output(self, agent, tape: DialogTape, index: int) -> LLMOutput:\n", + " if not isinstance(current := tape[index], AssistantThought):\n", + " raise ValueError()\n", + " return LLMOutput(role=\"assistant\", content=current.content)\n", + "\n", + "\n", + "class ActNode(Node):\n", + " def make_prompt(self, agent, tape: DialogTape) -> Prompt:\n", + " system_message = {\"role\": \"system\", \"content\": system_instruction}\n", + " guidance_message = {\"role\": \"user\", \"content\": agent.templates[\"call_or_respond\"]}\n", + " messages = [system_message]\n", + " for step in tape:\n", + " if isinstance(step, (ToolCalls)):\n", + " messages.append({\"role\": \"assistant\", \"content\": _llm_message_content(step)})\n", + " elif not isinstance(step, SetNextNode):\n", + " messages.append(step_to_message(step))\n", + " messages += [guidance_message]\n", + " return Prompt(messages=messages)\n", + "\n", + " def generate_steps(self, agent, tape, llm_stream: LLMStream):\n", + " m = llm_stream.get_message()\n", + " try:\n", + " assert m.content\n", + " tool_calls = []\n", + " response = None\n", + " for line in m.content.split(\"\\n\"):\n", + " data = json.loads(line)\n", + " if data.get(\"kind\") == \"response\":\n", + " response = data[\"content\"]\n", + " elif data.get(\"kind\") == \"tool_call\":\n", + " tool_call = ChatCompletionMessageToolCall(\n", + " function=Function(name=data[\"tool_name\"], arguments=json.dumps(data[\"parameters\"])),\n", + " # tool call must be a unique string, it helps to make it something deterministic\n", + " id=f\"tool_call_{len(tool_calls)}_node_starts_at_{len(tape)}\",\n", + " )\n", + " tool_calls.append(tool_call)\n", + " else:\n", + " yield AssistantStep(content=\"Invalid LLM output: kind field must be 'response' or 'tool_call'\")\n", + " if response and tool_calls:\n", + " yield AssistantStep(content=\"Invalid LLM output: response and tool_call cannot be in the same message\")\n", + " if response:\n", + " yield AssistantStep(content=response)\n", + " yield SetNextNode(next_node=0)\n", + " if tool_calls:\n", + " yield ToolCalls(tool_calls=tool_calls)\n", + " yield SetNextNode(next_node=1)\n", + " except Exception as e:\n", + " yield AssistantStep(content=\"Invalid JSON object: \" + str(e))\n", + "\n", + " def make_llm_output(self, agent, tape: DialogTape, index: int) -> LLMOutput:\n", + " if not isinstance(step := tape[index], AssistantStep | ToolCalls):\n", + " raise ValueError()\n", + " content = _llm_message_content(step)\n", + " return LLMOutput(role=\"assistant\", content=content)\n", + "\n", + "\n", + "def _llm_message_content(step: AssistantStep | ToolCalls):\n", + " \"\"\"Helper function to make both the prompt and the target completion\"\"\"\n", + " match step:\n", + " case AssistantStep():\n", + " return json.dumps({\"kind\": \"response\", \"content\": step.content})\n", + " case ToolCalls():\n", + " content = \"\"\n", + " for tool_call in step.tool_calls:\n", + " if content:\n", + " content += \"\\n\"\n", + " content += json.dumps(\n", + " {\n", + " \"kind\": \"tool_call\",\n", + " \"tool_name\": tool_call.function.name,\n", + " \"parameters\": json.loads(tool_call.function.arguments),\n", + " }\n", + " )\n", + " return content\n", + " case _:\n", + " raise ValueError()\n", + "\n", + "\n", + "agent2 = Agent.create(\n", + " TrainableLLM(\n", + " base_url=\"https://api.together.xyz\",\n", + " model_name=\"meta-llama/Meta-Llama-3-70B-Instruct-Turbo\",\n", + " tokenizer_name=\"meta-llama/Meta-Llama-3-70B-Instruct\",\n", + " parameters=dict(temperature=0.01),\n", + " ),\n", + " templates={\n", + " \"system\": system_instruction,\n", + " \"planning\": planning_guidance,\n", + " \"call_or_respond\": call_or_respond_guidance,\n", + " },\n", + " nodes=[PlanNode(), ActNode()],\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 3.2. Run your Agent" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-28T05:58:49.060357Z", + "iopub.status.busy": "2024-09-28T05:58:49.060232Z", + "iopub.status.idle": "2024-09-28T05:58:56.276527Z", + "shell.execute_reply": "2024-09-28T05:58:56.276048Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Run LLAMA agent!\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ "{\n", " \"metadata\": {\n", - " \"id\": \"dc2542d8-cacb-4125-9e42-cc3b42b9a3f8\",\n", + " \"id\": \"91442152-ddea-43a7-9630-7f18b46caa9a\",\n", + " \"prompt_id\": \"012ff58e-0b57-4e95-9777-e122e9c18dd8\",\n", + " \"node\": \"\",\n", + " \"agent\": \"Agent\",\n", + " \"other\": {}\n", + " },\n", + " \"content\": \"Here's a plan to help the user learn about Vulcan Materials using the provided tools:\\n\\n1. First, I'll use the `get_stock_ticker` function to get the stock ticker symbol for Vulcan Materials. I'll input \\\"Vulcan Materials\\\" as the company name and retrieve the corresponding ticker symbol.\\n\\n2. Once I have the ticker symbol, I'll use the `get_stock_data` function to retrieve the stock prices for Vulcan Materials over a specified date range. For example, I might choose a start date of 2020-01-01 and an end date of 2024-09-17 to get a recent 4-year history of the company's stock performance.\\n\\n3. With the stock price data, I can provide the user with a brief overview of Vulcan Materials' financial performance, including any notable trends or fluctuations in the stock price over the specified period.\\n\\n4. If desired, I can also use the `get_stock_data` function to compare Vulcan Materials' stock performance to that of its industry peers or the broader market, providing a more comprehensive picture of the company's financial health.\\n\\n5. Finally, I can use the gathered data to answer any specific questions the user may have about Vulcan Materials, such as its current stock price, market capitalization, or dividend yield.\",\n", + " \"kind\": \"assistant_thought\"\n", + "}\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{\n", + " \"metadata\": {\n", + " \"id\": \"91442152-ddea-43a7-9630-7f18b46caa9a\",\n", + " \"prompt_id\": \"2be08fbd-026a-482e-a789-a82248c1fce4\",\n", + " \"node\": \"\",\n", + " \"agent\": \"Agent\",\n", + " \"other\": {}\n", + " },\n", + " \"tool_calls\": [\n", + " {\n", + " \"function\": {\n", + " \"arguments\": \"{\\\"company_name\\\": \\\"Vulcan Materials\\\"}\",\n", + " \"name\": \"get_stock_ticker\"\n", + " },\n", + " \"id\": \"tool_call_0_node_starts_at_2\",\n", + " \"type\": \"function\"\n", + " }\n", + " ],\n", + " \"kind\": \"assistant\"\n", + "}\n", + "{\n", + " \"metadata\": {\n", + " \"id\": \"91442152-ddea-43a7-9630-7f18b46caa9a\",\n", + " \"prompt_id\": \"2be08fbd-026a-482e-a789-a82248c1fce4\",\n", + " \"node\": \"\",\n", + " \"agent\": \"Agent\",\n", + " \"other\": {}\n", + " },\n", + " \"kind\": \"set_next_node\",\n", + " \"next_node\": 1\n", + "}\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{\n", + " \"metadata\": {\n", + " \"id\": \"91442152-ddea-43a7-9630-7f18b46caa9a\",\n", " \"prompt_id\": \"\",\n", " \"node\": \"\",\n", " \"agent\": \"\",\n", @@ -1509,8 +1717,8 @@ "text": [ "{\n", " \"metadata\": {\n", - " \"id\": \"dc2542d8-cacb-4125-9e42-cc3b42b9a3f8\",\n", - " \"prompt_id\": \"737fc856-3b7c-4905-a11d-a62a95e21e85\",\n", + " \"id\": \"91442152-ddea-43a7-9630-7f18b46caa9a\",\n", + " \"prompt_id\": \"d37356c4-a052-4447-b3fd-d8a76c920086\",\n", " \"node\": \"\",\n", " \"agent\": \"Agent\",\n", " \"other\": {}\n", @@ -1529,18 +1737,24 @@ "}\n", "{\n", " \"metadata\": {\n", - " \"id\": \"dc2542d8-cacb-4125-9e42-cc3b42b9a3f8\",\n", - " \"prompt_id\": \"737fc856-3b7c-4905-a11d-a62a95e21e85\",\n", + " \"id\": \"91442152-ddea-43a7-9630-7f18b46caa9a\",\n", + " \"prompt_id\": \"d37356c4-a052-4447-b3fd-d8a76c920086\",\n", " \"node\": \"\",\n", " \"agent\": \"Agent\",\n", " \"other\": {}\n", " },\n", " \"kind\": \"set_next_node\",\n", " \"next_node\": 1\n", - "}\n", + "}\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ "{\n", " \"metadata\": {\n", - " \"id\": \"dc2542d8-cacb-4125-9e42-cc3b42b9a3f8\",\n", + " \"id\": \"91442152-ddea-43a7-9630-7f18b46caa9a\",\n", " \"prompt_id\": \"\",\n", " \"node\": \"\",\n", " \"agent\": \"\",\n", @@ -1558,25 +1772,52 @@ "text": [ "{\n", " \"metadata\": {\n", - " \"id\": \"dc2542d8-cacb-4125-9e42-cc3b42b9a3f8\",\n", - " \"prompt_id\": \"54a19edf-9af3-4de3-be13-b0c1dde2c155\",\n", + " \"id\": \"91442152-ddea-43a7-9630-7f18b46caa9a\",\n", + " \"prompt_id\": \"0fe79227-607b-41dc-9559-fa9b3f01b211\",\n", " \"node\": \"\",\n", " \"agent\": \"Agent\",\n", " \"other\": {}\n", " },\n", - " \"content\": \"Vulcan Materials is a leading producer of construction materials, including aggregates, asphalt, and ready-mixed concrete. Its stock, VMC, has shown a significant increase in value over the past 4 years, with a highest price of around 273.73 on 2024-03-14 and a lowest price of around 99.21 on 2020-04-03. The company's stock has been trending upward, with some fluctuations, indicating a strong performance in the construction materials industry.\",\n", + " \"tool_calls\": [\n", + " {\n", + " \"function\": {\n", + " \"arguments\": \"{\\\"company_name\\\": \\\"Vulcan Materials\\\"}\",\n", + " \"name\": \"get_stock_ticker\"\n", + " },\n", + " \"id\": \"tool_call_0_node_starts_at_8\",\n", + " \"type\": \"function\"\n", + " }\n", + " ],\n", " \"kind\": \"assistant\"\n", "}\n", "{\n", " \"metadata\": {\n", - " \"id\": \"dc2542d8-cacb-4125-9e42-cc3b42b9a3f8\",\n", - " \"prompt_id\": \"54a19edf-9af3-4de3-be13-b0c1dde2c155\",\n", + " \"id\": \"91442152-ddea-43a7-9630-7f18b46caa9a\",\n", + " \"prompt_id\": \"0fe79227-607b-41dc-9559-fa9b3f01b211\",\n", " \"node\": \"\",\n", " \"agent\": \"Agent\",\n", " \"other\": {}\n", " },\n", " \"kind\": \"set_next_node\",\n", - " \"next_node\": 0\n", + " \"next_node\": 1\n", + "}\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{\n", + " \"metadata\": {\n", + " \"id\": \"91442152-ddea-43a7-9630-7f18b46caa9a\",\n", + " \"prompt_id\": \"\",\n", + " \"node\": \"\",\n", + " \"agent\": \"\",\n", + " \"other\": {}\n", + " },\n", + " \"content\": \"VMC\",\n", + " \"tool_call_id\": \"tool_call_0_node_starts_at_8\",\n", + " \"kind\": \"tool\"\n", "}\n", "Final tape:\n" ] @@ -1587,25 +1828,25 @@ "

Metadata

Show / Hide
author: ''\n", "author_tape_id: null\n", "error: null\n", - "id: 2696dce2-ce75-498d-aa49-c4598edd65e1\n", + "id: bf2c72c6-4e75-43c7-8685-f5209b1b92c9\n", "n_added_steps: 2\n", - "parent_id: 340468cc-5519-4f9d-92bd-2c84c34a3faf\n", + "parent_id: f9088d2e-f5c8-411c-adf2-bb0de9280f06\n", "result: null\n", "

Steps

[0] User

kind: user\n",
        "\n",
        "Tell me about Vulcan Materials in 3 sentences

[1] Thought: AssistantThought

kind: assistant_thought\n",
        "\n",
-       "
1130 characters ...Here's a plan to help the user learn about Vulcan Materials using the provided tools:\n", + "
1228 characters ...Here's a plan to help the user learn about Vulcan Materials using the provided tools:\n", "\n", - "1. First, use the `get_stock_ticker` function to retrieve the stock ticker symbol for Vulcan Materials by passing \"Vulcan Materials\" as the `company_name` parameter. This will give us the stock ticker symbol, which we'll use in the next step.\n", + "1. First, I'll use the `get_stock_ticker` function to get the stock ticker symbol for Vulcan Materials. I'll input \"Vulcan Materials\" as the company name and retrieve the corresponding ticker symbol.\n", "\n", - "2. Once we have the stock ticker symbol, use the `get_stock_data` function to retrieve the historical stock prices for Vulcan Materials. We can pass the stock ticker symbol, a start date (e.g., 2020-01-01), and an end date (e.g., 2024-09-17) as parameters to get the stock prices for the specified date range.\n", + "2. Once I have the ticker symbol, I'll use the `get_stock_data` function to retrieve the stock prices for Vulcan Materials over a specified date range. For example, I might choose a start date of 2020-01-01 and an end date of 2024-09-17 to get a recent 4-year history of the company's stock performance.\n", "\n", - "3. Analyze the retrieved stock prices to provide an overview of Vulcan Materials' stock performance over the specified period. This could include calculating the highest and lowest prices, the overall trend, and any notable events or fluctuations in the stock price.\n", + "3. With the stock price data, I can provide the user with a brief overview of Vulcan Materials' financial performance, including any notable trends or fluctuations in the stock price over the specified period.\n", "\n", - "4. Use the analyzed data to provide a brief summary of Vulcan Materials in three sentences, including information about the company's stock performance, industry, and any other relevant details.\n", + "4. If desired, I can also use the `get_stock_data` function to compare Vulcan Materials' stock performance to that of its industry peers or the broader market, providing a more comprehensive picture of the company's financial health.\n", "\n", - "Let's execute this plan!

[2] Action: ToolCalls

tool_calls:\n",
+       "5. Finally, I can use the gathered data to answer any specific questions the user may have about Vulcan Materials, such as its current stock price, market capitalization, or dividend yield.

[2] Action: ToolCalls

tool_calls:\n",
        "- function:\n",
        "    arguments: '{\"company_name\": \"Vulcan Materials\"}'\n",
        "    name: get_stock_ticker\n",
@@ -1629,164 +1870,27 @@
        "

[7] Observation: ToolResult

tool_call_id: tool_call_0_node_starts_at_5\n",
        "kind: tool\n",
        "\n",
-       "
2615 characters ...[('2020-01-02', 142.72000122070312), ('2020-01-27', 138.8800048828125), ('2020-02-19', 135.39999389648438), ('2020-03-12', 107.12000274658203), ('2020-04-03', 99.20999908447266), ('2020-04-28', 110.7699966430664), ('2020-05-20', 101.47000122070312), ('2020-06-12', 112.08999633789062), ('2020-07-07', 122.66999816894531), ('2020-07-29', 121.08000183105469), ('2020-08-20', 126.11000061035156), ('2020-09-14', 130.33999633789062), ('2020-10-06', 141.30999755859375), ('2020-10-28', 137.47999572753906), ('2020-11-19', 140.11000061035156), ('2020-12-14', 135.44000244140625), ('2021-01-07', 162.00999450683594), ('2021-02-01', 152.0), ('2021-02-24', 174.14999389648438), ('2021-03-18', 168.0500030517578), ('2021-04-12', 174.35000610351562), ('2021-05-04', 189.2100067138672), ('2021-05-26', 183.92999267578125), ('2021-06-18', 165.83999633789062), ('2021-07-13', 173.52999877929688), ('2021-08-04', 179.66000366210938), ('2021-08-26', 187.52999877929688), ('2021-09-20', 169.4199981689453), ('2021-10-12', 170.8300018310547), ('2021-11-03', 195.0), ('2021-11-26', 197.4499969482422), ('2021-12-20', 198.77999877929688), ('2022-01-12', 202.8800048828125), ('2022-02-04', 184.0399932861328), ('2022-03-01', 174.44000244140625), ('2022-03-23', 177.33999633789062), ('2022-04-14', 174.77000427246094), ('2022-05-09', 162.9499969482422), ('2022-06-01', 164.5399932861328), ('2022-06-24', 145.82000732421875), ('2022-07-19', 152.57000732421875), ('2022-08-10', 174.52000427246094), ('2022-09-01', 166.22000122070312), ('2022-09-26', 153.9499969482422), ('2022-10-18', 158.77999877929688), ('2022-11-09', 168.94000244140625), ('2022-12-02', 184.49000549316406), ('2022-12-27', 175.67999267578125), ('2023-01-20', 178.88999938964844), ('2023-02-13', 186.05999755859375), ('2023-03-08', 178.9199981689453), ('2023-03-30', 170.13999938964844), ('2023-04-24', 171.41000366210938), ('2023-05-16', 195.00999450683594), ('2023-06-08', 206.17999267578125), ('2023-07-03', 223.33999633789062), ('2023-07-26', 223.4600067138672), ('2023-08-17', 213.3300018310547), ('2023-09-11', 216.58999633789062), ('2023-10-03', 199.99000549316406), ('2023-10-25', 203.3699951171875), ('2023-11-16', 212.27000427246094), ('2023-12-11', 218.86000061035156), ('2024-01-04', 220.67999267578125), ('2024-01-29', 229.3699951171875), ('2024-02-21', 253.42999267578125), ('2024-03-14', 270.7300109863281), ('2024-04-08', 269.7200012207031), ('2024-04-30', 257.6300048828125), ('2024-05-22', 260.8699951171875), ('2024-06-14', 252.63999938964844), ('2024-07-10', 247.72000122070312), ('2024-08-01', 271.1300048828125), ('2024-08-23', 254.88999938964844)]

[8] Assistant

kind: assistant\n",
-       "\n",
-       "Vulcan Materials is a leading producer of construction materials, including aggregates, asphalt, and ready-mixed concrete. Its stock, VMC, has shown a significant increase in value over the past 4 years, with a highest price of around 273.73 on 2024-03-14 and a lowest price of around 99.21 on 2020-04-03. The company's stock has been trending upward, with some fluctuations, indicating a strong performance in the construction materials industry.

[9] Thought: SetNextNode

kind: set_next_node\n",
-       "next_node: 0\n",
+       "
2615 characters ...[('2020-01-02', 142.72000122070312), ('2020-01-27', 138.8800048828125), ('2020-02-19', 135.39999389648438), ('2020-03-12', 107.12000274658203), ('2020-04-03', 99.20999908447266), ('2020-04-28', 110.7699966430664), ('2020-05-20', 101.47000122070312), ('2020-06-12', 112.08999633789062), ('2020-07-07', 122.66999816894531), ('2020-07-29', 121.08000183105469), ('2020-08-20', 126.11000061035156), ('2020-09-14', 130.33999633789062), ('2020-10-06', 141.30999755859375), ('2020-10-28', 137.47999572753906), ('2020-11-19', 140.11000061035156), ('2020-12-14', 135.44000244140625), ('2021-01-07', 162.00999450683594), ('2021-02-01', 152.0), ('2021-02-24', 174.14999389648438), ('2021-03-18', 168.0500030517578), ('2021-04-12', 174.35000610351562), ('2021-05-04', 189.2100067138672), ('2021-05-26', 183.92999267578125), ('2021-06-18', 165.83999633789062), ('2021-07-13', 173.52999877929688), ('2021-08-04', 179.66000366210938), ('2021-08-26', 187.52999877929688), ('2021-09-20', 169.4199981689453), ('2021-10-12', 170.8300018310547), ('2021-11-03', 195.0), ('2021-11-26', 197.4499969482422), ('2021-12-20', 198.77999877929688), ('2022-01-12', 202.8800048828125), ('2022-02-04', 184.0399932861328), ('2022-03-01', 174.44000244140625), ('2022-03-23', 177.33999633789062), ('2022-04-14', 174.77000427246094), ('2022-05-09', 162.9499969482422), ('2022-06-01', 164.5399932861328), ('2022-06-24', 145.82000732421875), ('2022-07-19', 152.57000732421875), ('2022-08-10', 174.52000427246094), ('2022-09-01', 166.22000122070312), ('2022-09-26', 153.9499969482422), ('2022-10-18', 158.77999877929688), ('2022-11-09', 168.94000244140625), ('2022-12-02', 184.49000549316406), ('2022-12-27', 175.67999267578125), ('2023-01-20', 178.88999938964844), ('2023-02-13', 186.05999755859375), ('2023-03-08', 178.9199981689453), ('2023-03-30', 170.13999938964844), ('2023-04-24', 171.41000366210938), ('2023-05-16', 195.00999450683594), ('2023-06-08', 206.17999267578125), ('2023-07-03', 223.33999633789062), ('2023-07-26', 223.4600067138672), ('2023-08-17', 213.3300018310547), ('2023-09-11', 216.58999633789062), ('2023-10-03', 199.99000549316406), ('2023-10-25', 203.3699951171875), ('2023-11-16', 212.27000427246094), ('2023-12-11', 218.86000061035156), ('2024-01-04', 220.67999267578125), ('2024-01-29', 229.3699951171875), ('2024-02-21', 253.42999267578125), ('2024-03-14', 270.7300109863281), ('2024-04-08', 269.7200012207031), ('2024-04-30', 257.6300048828125), ('2024-05-22', 260.8699951171875), ('2024-06-14', 252.63999938964844), ('2024-07-10', 247.72000122070312), ('2024-08-01', 271.1300048828125), ('2024-08-23', 254.88999938964844)]

[8] Action: ToolCalls

tool_calls:\n",
+       "- function:\n",
+       "    arguments: '{\"company_name\": \"Vulcan Materials\"}'\n",
+       "    name: get_stock_ticker\n",
+       "  id: tool_call_0_node_starts_at_8\n",
+       "  type: function\n",
+       "kind: assistant\n",
+       "

[9] Thought: SetNextNode

kind: set_next_node\n",
+       "next_node: 1\n",
        "
" ], "text/plain": [ "" ] }, - "execution_count": 15, + "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "import json\n", - "from tapeagents.core import LLMOutput\n", - "from tapeagents.llms import LLAMA\n", - "from litellm.utils import ChatCompletionMessageToolCall\n", - "from litellm.utils import Function\n", - "\n", - "from tapeagents.prompting import step_to_message\n", - "\n", - "env = ToolEnvironment([get_stock_ticker, get_stock_data])\n", - "\n", - "system_instruction = f\"\"\"\n", - "You will help the user to learn about financials of companies.\n", - "Use as many relevant tools as possible to include more details and facts in your responses.\n", - "Today is {today}.\n", - "\n", - "You have access to the following tools: {env.get_tool_schema_dicts()}\"\"\"\n", - "\n", - "planning_guidance = \"Write a natural language plan on how to use tools help the user. Output a list of numbered items, like 1., 2., 3., etc.\"\n", - "\n", - "call_or_respond_guidance = \"\"\"\n", - "Follow the plan you created earlier. When you are done, respond to the user.\n", - "If you want to call a or several tools, output JSON like this\n", - "{\"kind\": \"tool_call\", \"tool_name\": \"...\", \"parameters\": \"... unquoted parameters json ...\"}\n", - "If you have called all the tools in the plan, respond to the user with the JSON of the form\n", - "{\"kind\": \"response\", \"content\": \"... you response ... \"}.\n", - "Output ONE JSON OBJECT ONLY PER LINE ONLY AND NOTHING ELSE.\n", - "\"\"\"\n", - "\n", - "\n", - "def make_planning_prompt(agent, tape: DialogTape) -> Prompt:\n", - " system_message = {\"role\": \"system\", \"content\": system_instruction}\n", - " guidance_message = {\"role\": \"user\", \"content\": agent.templates[\"planning\"]}\n", - " return Prompt(messages=[system_message] + tape_to_messages(tape) + [guidance_message])\n", - "\n", - "\n", - "def generate_planning_steps(agent, tape, llm_stream: LLMStream):\n", - " if content := getattr(llm_stream.get_message(), \"content\", None):\n", - " yield AssistantThought(content=content)\n", - " else:\n", - " raise ValueError()\n", - "\n", - "\n", - "def make_planning_llm_output(agent, tape: DialogTape, index: int) -> LLMOutput:\n", - " if not isinstance(current := tape[index], AssistantThought):\n", - " raise ValueError()\n", - " return LLMOutput(role=\"assistant\", content=current.content)\n", - "\n", - "\n", - "def _llm_message_content(step: AssistantStep | ToolCalls):\n", - " \"\"\"Helper function to make both the prompt and the target completion\"\"\"\n", - " match step:\n", - " case AssistantStep():\n", - " return json.dumps({\"kind\": \"response\", \"content\": step.content})\n", - " case ToolCalls():\n", - " content = \"\"\n", - " for tool_call in step.tool_calls:\n", - " if content:\n", - " content += \"\\n\"\n", - " content += json.dumps(\n", - " {\n", - " \"kind\": \"tool_call\",\n", - " \"tool_name\": tool_call.function.name,\n", - " \"parameters\": json.loads(tool_call.function.arguments),\n", - " }\n", - " )\n", - " return content\n", - " case _:\n", - " raise ValueError()\n", - "\n", - "\n", - "def make_prompt(agent, tape: DialogTape) -> Prompt:\n", - " system_message = {\"role\": \"system\", \"content\": system_instruction}\n", - " guidance_message = {\"role\": \"user\", \"content\": agent.templates[\"call_or_respond\"]}\n", - " messages = [system_message]\n", - " for step in tape:\n", - " if isinstance(step, (ToolCalls)):\n", - " messages.append({\"role\": \"assistant\", \"content\": _llm_message_content(step)})\n", - " elif not isinstance(step, SetNextNode):\n", - " messages.append(step_to_message(step))\n", - " messages += [guidance_message]\n", - " return Prompt(messages=messages)\n", - "\n", - "\n", - "def generate_steps(agent, tape, llm_stream: LLMStream):\n", - " m = llm_stream.get_message()\n", - " try:\n", - " assert m.content\n", - " tool_calls = []\n", - " response = None\n", - " for line in m.content.split(\"\\n\"):\n", - " data = json.loads(line)\n", - " if data.get(\"kind\") == \"response\":\n", - " response = data[\"content\"]\n", - " elif data.get(\"kind\") == \"tool_call\":\n", - " tool_call = ChatCompletionMessageToolCall(\n", - " function=Function(name=data[\"tool_name\"], arguments=json.dumps(data[\"parameters\"])),\n", - " # tool call must be a unique string, it helps to make it something deterministic\n", - " id=f\"tool_call_{len(tool_calls)}_node_starts_at_{len(tape)}\",\n", - " )\n", - " tool_calls.append(tool_call)\n", - " else:\n", - " yield AssistantStep(content=\"Invalid LLM output: kind field must be 'response' or 'tool_call'\")\n", - " if response and tool_calls:\n", - " yield AssistantStep(content=\"Invalid LLM output: response and tool_call cannot be in the same message\")\n", - " if response:\n", - " yield AssistantStep(content=response)\n", - " yield SetNextNode(next_node=0)\n", - " if tool_calls:\n", - " yield ToolCalls(tool_calls=tool_calls)\n", - " yield SetNextNode(next_node=1)\n", - " except Exception as e:\n", - " yield AssistantStep(content=\"Invalid JSON object: \" + str(e))\n", - "\n", - "\n", - "def make_llm_output(agent, tape: DialogTape, index: int) -> LLMOutput:\n", - " if not isinstance(step := tape[index], AssistantStep | ToolCalls):\n", - " raise ValueError()\n", - " content = _llm_message_content(step)\n", - " return LLMOutput(role=\"assistant\", content=content)\n", - "\n", - "\n", - "agent2 = Agent.create(\n", - " LLAMA(\n", - " base_url=\"https://api.together.xyz\",\n", - " model_name=\"meta-llama/Meta-Llama-3-70B-Instruct-Turbo\",\n", - " tokenizer_name=\"meta-llama/Meta-Llama-3-70B-Instruct\",\n", - " parameters=dict(temperature=0.01),\n", - " ),\n", - " templates={\n", - " \"system\": system_instruction,\n", - " \"planning\": planning_guidance,\n", - " \"call_or_respond\": call_or_respond_guidance,\n", - " },\n", - " nodes=[\n", - " Node()\n", - " .with_prompt(make_planning_prompt)\n", - " .with_generate_steps(generate_planning_steps)\n", - " .with_llm_output(make_planning_llm_output),\n", - " Node().with_prompt(make_prompt).with_generate_steps(generate_steps).with_llm_output(make_llm_output),\n", - " ],\n", - ")\n", - "\n", "final_tape2 = None\n", "print(\"Run LLAMA agent!\")\n", "for event in main_loop(\n", @@ -1801,7 +1905,7 @@ " print(event.observation.model_dump_json(indent=2))\n", "assert final_tape2 is not None\n", "print(\"Final tape:\")\n", - "HTML(render_tape_with_prompts(final_tape2, PrettyRenderer()))\n" + "HTML(render_tape_with_prompts(final_tape2, PrettyRenderer()))" ] }, { @@ -1813,13 +1917,13 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 19, "metadata": { "execution": { - "iopub.execute_input": "2024-09-27T12:57:59.443114Z", - "iopub.status.busy": "2024-09-27T12:57:59.442883Z", - "iopub.status.idle": "2024-09-27T12:58:03.168505Z", - "shell.execute_reply": "2024-09-27T12:58:03.167841Z" + "iopub.execute_input": "2024-09-28T05:58:56.278833Z", + "iopub.status.busy": "2024-09-28T05:58:56.278620Z", + "iopub.status.idle": "2024-09-28T05:58:58.431687Z", + "shell.execute_reply": "2024-09-28T05:58:58.431257Z" } }, "outputs": [ @@ -1829,9 +1933,9 @@ "

Metadata

Show / Hide
author: ''\n", "author_tape_id: null\n", "error: null\n", - "id: 2cbfbc44-494f-4648-afb8-ae77cd604c02\n", + "id: 7b869e78-3752-4cb2-b995-b9f1393d1860\n", "n_added_steps: 2\n", - "parent_id: a9cc2d5e-cfe8-4560-8e62-efec7f33c19a\n", + "parent_id: 1e4b20ab-3836-4eee-b71d-d9fccc5b2a48\n", "result: null\n", "

Steps

[0] User

kind: user\n",
        "\n",
@@ -1873,7 +1977,7 @@
        "\n",
        "
2615 characters ...[('2020-01-02', 142.72000122070312), ('2020-01-27', 138.8800048828125), ('2020-02-19', 135.39999389648438), ('2020-03-12', 107.12000274658203), ('2020-04-03', 99.20999908447266), ('2020-04-28', 110.7699966430664), ('2020-05-20', 101.47000122070312), ('2020-06-12', 112.08999633789062), ('2020-07-07', 122.66999816894531), ('2020-07-29', 121.08000183105469), ('2020-08-20', 126.11000061035156), ('2020-09-14', 130.33999633789062), ('2020-10-06', 141.30999755859375), ('2020-10-28', 137.47999572753906), ('2020-11-19', 140.11000061035156), ('2020-12-14', 135.44000244140625), ('2021-01-07', 162.00999450683594), ('2021-02-01', 152.0), ('2021-02-24', 174.14999389648438), ('2021-03-18', 168.0500030517578), ('2021-04-12', 174.35000610351562), ('2021-05-04', 189.2100067138672), ('2021-05-26', 183.92999267578125), ('2021-06-18', 165.83999633789062), ('2021-07-13', 173.52999877929688), ('2021-08-04', 179.66000366210938), ('2021-08-26', 187.52999877929688), ('2021-09-20', 169.4199981689453), ('2021-10-12', 170.8300018310547), ('2021-11-03', 195.0), ('2021-11-26', 197.4499969482422), ('2021-12-20', 198.77999877929688), ('2022-01-12', 202.8800048828125), ('2022-02-04', 184.0399932861328), ('2022-03-01', 174.44000244140625), ('2022-03-23', 177.33999633789062), ('2022-04-14', 174.77000427246094), ('2022-05-09', 162.9499969482422), ('2022-06-01', 164.5399932861328), ('2022-06-24', 145.82000732421875), ('2022-07-19', 152.57000732421875), ('2022-08-10', 174.52000427246094), ('2022-09-01', 166.22000122070312), ('2022-09-26', 153.9499969482422), ('2022-10-18', 158.77999877929688), ('2022-11-09', 168.94000244140625), ('2022-12-02', 184.49000549316406), ('2022-12-27', 175.67999267578125), ('2023-01-20', 178.88999938964844), ('2023-02-13', 186.05999755859375), ('2023-03-08', 178.9199981689453), ('2023-03-30', 170.13999938964844), ('2023-04-24', 171.41000366210938), ('2023-05-16', 195.00999450683594), ('2023-06-08', 206.17999267578125), ('2023-07-03', 223.33999633789062), ('2023-07-26', 223.4600067138672), ('2023-08-17', 213.3300018310547), ('2023-09-11', 216.58999633789062), ('2023-10-03', 199.99000549316406), ('2023-10-25', 203.3699951171875), ('2023-11-16', 212.27000427246094), ('2023-12-11', 218.86000061035156), ('2024-01-04', 220.67999267578125), ('2024-01-29', 229.3699951171875), ('2024-02-21', 253.42999267578125), ('2024-03-14', 270.7300109863281), ('2024-04-08', 269.7200012207031), ('2024-04-30', 257.6300048828125), ('2024-05-22', 260.8699951171875), ('2024-06-14', 252.63999938964844), ('2024-07-10', 247.72000122070312), ('2024-08-01', 271.1300048828125), ('2024-08-23', 254.88999938964844)]

[8] Assistant

kind: assistant\n",
        "\n",
-       "Vulcan Materials is a leading producer of construction materials, including crushed stone, sand, and gravel. Its stock ticker symbol is VMC. The company's stock price has fluctuated over the past 4 years, with a highest price of around 273 (in 2024) and a lowest price of around 99 (in 2020). Currently, the stock price is around 255. The company's market capitalization is approximately 17 billion USD, and it is a major player in the construction materials industry. Its main competitors include Martin Marietta Materials, Eagle Materials, and Cemex. 

[9] Thought: SetNextNode

kind: set_next_node\n",
+       "Vulcan Materials, a leading American company, is a major producer of construction materials, primarily focused on aggregates, asphalt, and ready-mixed concrete. The company's ticker symbol is VMC. From 2020-01-01 to 2024-09-17, the stock price ranged from 99.21 to 271.13, with an average price of 169.45. The stock has shown an overall increasing trend over the specified period, with some fluctuations.

[9] Thought: SetNextNode

kind: set_next_node\n",
        "next_node: 0\n",
        "
" ], @@ -1881,7 +1985,7 @@ "" ] }, - "execution_count": 16, + "execution_count": 19, "metadata": {}, "output_type": "execute_result" } @@ -1894,7 +1998,7 @@ " \"REMEMBER: check what tool calls you have already made. Do not do the same call again!\"\n", ")\n", "resume_from_step8 = agent2b.run(failed_tape[:8]).get_final_tape()\n", - "HTML(render_tape_with_prompts(resume_from_step8, PrettyRenderer()))\n" + "HTML(render_tape_with_prompts(resume_from_step8, PrettyRenderer()))" ] }, { @@ -1908,7 +2012,13 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# 4. Tape reuse and training data\n", + "# 4. Tape reuse and training data" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ "\n", "Another way to help this agent (or one with an even smaller LLM) is to finetune the LLM. And the most important step towards finetuning is making the training data!\n", "\n", @@ -1930,13 +2040,13 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 20, "metadata": { "execution": { - "iopub.execute_input": "2024-09-27T12:58:03.171569Z", - "iopub.status.busy": "2024-09-27T12:58:03.171108Z", - "iopub.status.idle": "2024-09-27T12:58:03.181498Z", - "shell.execute_reply": "2024-09-27T12:58:03.180595Z" + "iopub.execute_input": "2024-09-28T05:58:58.433419Z", + "iopub.status.busy": "2024-09-28T05:58:58.433262Z", + "iopub.status.idle": "2024-09-28T05:58:58.438661Z", + "shell.execute_reply": "2024-09-28T05:58:58.438358Z" } }, "outputs": [ @@ -1951,15 +2061,15 @@ "\n", "Here's a plan to help the user learn about Vulcan Materials using the provided tools:\n", "\n", - "1. First, use the `get_stock_ticker` function to retrieve the stock ticker symbol for Vulcan Materials by passing \"Vulcan Materials\" as the `company_name` parameter. This will give us the stock ticker symbol, which we'll use in the next step.\n", + "1. First, I'll use the `get_stock_ticker` function to get the stock ticker symbol for Vulcan Materials. I'll input \"Vulcan Materials\" as the company name and retrieve the corresponding ticker symbol.\n", "\n", - "2. Once we have the stock ticker symbol, use the `get_stock_data` function to retrieve the historical stock prices for Vulcan Materials. We can pass the stock ticker symbol, a start date (e.g., 2020-01-01), and an end date (e.g., 2024-09-17) as parameters to get the stock prices for the specified date range.\n", + "2. Once I have the ticker symbol, I'll use the `get_stock_data` function to retrieve the stock prices for Vulcan Materials over a specified date range. For example, I might choose a start date of 2020-01-01 and an end date of 2024-09-17 to get a recent 4-year history of the company's stock performance.\n", "\n", - "3. Analyze the retrieved stock prices to provide an overview of Vulcan Materials' stock performance over the specified period. This could include calculating the highest and lowest prices, the overall trend, and any notable events or fluctuations in the stock price.\n", + "3. With the stock price data, I can provide the user with a brief overview of Vulcan Materials' financial performance, including any notable trends or fluctuations in the stock price over the specified period.\n", "\n", - "4. Use the analyzed data to provide a brief summary of Vulcan Materials in three sentences, including information about the company's stock performance, industry, and any other relevant details.\n", + "4. If desired, I can also use the `get_stock_data` function to compare Vulcan Materials' stock performance to that of its industry peers or the broader market, providing a more comprehensive picture of the company's financial health.\n", "\n", - "Let's execute this plan!<|eot_id|>\n" + "5. Finally, I can use the gathered data to answer any specific questions the user may have about Vulcan Materials, such as its current stock price, market capitalization, or dividend yield.<|eot_id|>\n" ] } ], @@ -1972,7 +2082,7 @@ "example_text = agent2.make_training_text(list(llm_calls.values())[0])\n", "print(\"From the first retrieved LLM call, the LLM will be trained to predict this text:\")\n", "print(\"---\")\n", - "print(example_text.output_text)\n" + "print(example_text.output_text)" ] }, { @@ -1993,13 +2103,13 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 21, "metadata": { "execution": { - "iopub.execute_input": "2024-09-27T12:58:03.184194Z", - "iopub.status.busy": "2024-09-27T12:58:03.183904Z", - "iopub.status.idle": "2024-09-27T12:58:03.211049Z", - "shell.execute_reply": "2024-09-27T12:58:03.210323Z" + "iopub.execute_input": "2024-09-28T05:58:58.440386Z", + "iopub.status.busy": "2024-09-28T05:58:58.440138Z", + "iopub.status.idle": "2024-09-28T05:58:58.456350Z", + "shell.execute_reply": "2024-09-28T05:58:58.456048Z" } }, "outputs": [ @@ -2009,7 +2119,7 @@ "

Metadata

Show / Hide
author: null\n", "author_tape_id: null\n", "error: null\n", - "id: bae0e45a-8665-4c8d-89b6-51b92c086628\n", + "id: 6e2ba87b-6d06-4632-9860-f7e3dcd6b5ce\n", "n_added_steps: 0\n", "parent_id: null\n", "result: null\n", @@ -2017,9 +2127,13 @@ "\n", "Tell me about Vulcan in 3 sentences

[1] Thought: AssistantThought

kind: assistant_thought\n",
        "\n",
-       "1. Use the `functions.get_stock_ticker` tool to obtain the stock ticker symbol for Vulcan.\n",
-       "2. Use the `functions.get_stock_data` tool to retrieve the stock prices for Vulcan over a specified date range.\n",
-       "3. Summarize the information obtained from the stock ticker and stock data to provide a comprehensive overview of Vulcan's financials.

[2] Action: ToolCalls

tool_calls:\n",
+       "To help the user learn about Vulcan's financials, I will follow these steps:\n",
+       "\n",
+       "1. Use the `get_stock_ticker` function to find the stock ticker symbol for Vulcan.\n",
+       "2. Use the `get_stock_data` function to retrieve recent stock price data for Vulcan using the obtained ticker symbol.\n",
+       "3. Summarize the financial information and stock performance of Vulcan based on the retrieved data.\n",
+       "\n",
+       "Let's start with step 1.

[2] Action: ToolCalls

tool_calls:\n",
        "- function:\n",
        "    arguments: '{\"company_name\": \"Vulcan\"}'\n",
        "    name: get_stock_ticker\n",
@@ -2028,7 +2142,7 @@
        "kind: assistant\n",
        "

[3] Thought: SetNextNode

kind: set_next_node\n",
        "next_node: 1\n",
-       "

[4] Observation: ToolResult

tool_call_id: call_S2Il5yCMNsQZyBgensfmr7dh\n",
+       "

[4] Observation: ToolResult

tool_call_id: call_ulmiHQvlQ2N7zZ1TJet02RJo\n",
        "kind: tool\n",
        "\n",
        "VMC

[5] Action: ToolCalls

tool_calls:\n",
@@ -2040,12 +2154,12 @@
        "kind: assistant\n",
        "

[6] Thought: SetNextNode

kind: set_next_node\n",
        "next_node: 1\n",
-       "

[7] Observation: ToolResult

tool_call_id: call_zXXvyYM7xrC9MDgaH44GdCbb\n",
+       "

[7] Observation: ToolResult

tool_call_id: call_CH708SYdZsqFf3vgKNTplOub\n",
        "kind: tool\n",
        "\n",
        "
3088 characters ...[('2024-01-02', 223.60000610351562), ('2024-01-04', 220.67999267578125), ('2024-01-08', 224.0), ('2024-01-10', 226.11000061035156), ('2024-01-12', 223.9600067138672), ('2024-01-17', 221.25999450683594), ('2024-01-19', 226.0800018310547), ('2024-01-23', 222.8000030517578), ('2024-01-25', 223.41000366210938), ('2024-01-29', 229.3699951171875), ('2024-01-31', 226.00999450683594), ('2024-02-02', 234.44000244140625), ('2024-02-06', 231.5800018310547), ('2024-02-08', 238.44000244140625), ('2024-02-12', 240.1300048828125), ('2024-02-14', 241.10000610351562), ('2024-02-16', 255.14999389648438), ('2024-02-21', 253.42999267578125), ('2024-02-23', 257.2300109863281), ('2024-02-27', 263.55999755859375), ('2024-02-29', 265.8500061035156), ('2024-03-04', 267.8500061035156), ('2024-03-06', 267.3399963378906), ('2024-03-08', 266.70001220703125), ('2024-03-12', 269.5799865722656), ('2024-03-14', 270.7300109863281), ('2024-03-18', 269.4200134277344), ('2024-03-20', 271.739990234375), ('2024-03-22', 274.3599853515625), ('2024-03-26', 273.8699951171875), ('2024-03-28', 272.9200134277344), ('2024-04-02', 266.25), ('2024-04-04', 265.8900146484375), ('2024-04-08', 269.7200012207031), ('2024-04-10', 264.55999755859375), ('2024-04-12', 262.7799987792969), ('2024-04-16', 258.5400085449219), ('2024-04-18', 255.07000732421875), ('2024-04-22', 254.47999572753906), ('2024-04-24', 256.3999938964844), ('2024-04-26', 261.239990234375), ('2024-04-30', 257.6300048828125), ('2024-05-02', 264.4100036621094), ('2024-05-06', 266.6099853515625), ('2024-05-08', 267.92999267578125), ('2024-05-10', 272.07000732421875), ('2024-05-14', 267.75), ('2024-05-16', 260.0), ('2024-05-20', 260.2099914550781), ('2024-05-22', 260.8699951171875), ('2024-05-24', 259.25), ('2024-05-29', 251.91000366210938), ('2024-05-31', 255.77000427246094), ('2024-06-04', 250.4600067138672), ('2024-06-06', 248.5800018310547), ('2024-06-10', 247.80999755859375), ('2024-06-12', 249.1199951171875), ('2024-06-14', 252.63999938964844), ('2024-06-18', 255.61000061035156), ('2024-06-21', 247.80999755859375), ('2024-06-25', 246.14999389648438), ('2024-06-27', 247.75999450683594), ('2024-07-01', 243.72000122070312), ('2024-07-03', 243.9199981689453), ('2024-07-08', 241.97000122070312), ('2024-07-10', 247.72000122070312), ('2024-07-12', 252.50999450683594), ('2024-07-16', 262.80999755859375), ('2024-07-18', 256.0899963378906), ('2024-07-22', 260.6099853515625), ('2024-07-24', 250.50999450683594), ('2024-07-26', 261.7099914550781), ('2024-07-30', 270.0), ('2024-08-01', 271.1300048828125), ('2024-08-05', 257.42999267578125), ('2024-08-07', 241.22000122070312), ('2024-08-09', 244.33999633789062), ('2024-08-13', 243.83999633789062), ('2024-08-15', 246.57000732421875), ('2024-08-19', 244.2899932861328), ('2024-08-21', 247.83999633789062), ('2024-08-23', 254.88999938964844), ('2024-08-27', 240.41000366210938), ('2024-08-29', 241.27999877929688), ('2024-09-03', 239.02000427246094), ('2024-09-05', 232.16000366210938), ('2024-09-09', 231.8300018310547), ('2024-09-11', 232.9499969482422), ('2024-09-13', 237.47000122070312)]

[8] Assistant

kind: assistant\n",
        "\n",
-       "Vulcan Materials Company, trading under the stock ticker symbol VMC, is a major producer of construction aggregates, primarily crushed stone, sand, and gravel. Over the course of 2024, Vulcan's stock price has shown significant fluctuations, starting at approximately $223.60 in early January and reaching highs of around $274.36 in late March, before experiencing a decline to around $237.47 by mid-September. This volatility reflects the dynamic nature of the construction materials market and the broader economic conditions impacting the industry.

[9] Thought: SetNextNode

kind: set_next_node\n",
+       "Vulcan Materials Company, trading under the ticker symbol VMC, is a major producer of construction aggregates, primarily crushed stone, sand, and gravel. Over the course of 2024, Vulcan's stock price has shown significant fluctuations, starting at approximately $223.60 in early January and reaching a high of around $274.36 in late March, before experiencing a decline to about $237.47 by mid-September. This performance reflects the company's market dynamics and the broader economic conditions impacting the construction and materials sector.

[9] Thought: SetNextNode

kind: set_next_node\n",
        "next_node: 0\n",
        "
" ], @@ -2053,14 +2167,14 @@ "" ] }, - "execution_count": 18, + "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "reused_tape, _ = agent2.reuse(final_tape1)\n", - "HTML(render_tape_with_prompts(reused_tape, PrettyRenderer()))\n" + "HTML(render_tape_with_prompts(reused_tape, PrettyRenderer()))" ] }, { @@ -2072,13 +2186,13 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 22, "metadata": { "execution": { - "iopub.execute_input": "2024-09-27T12:58:03.213960Z", - "iopub.status.busy": "2024-09-27T12:58:03.213657Z", - "iopub.status.idle": "2024-09-27T12:58:03.230856Z", - "shell.execute_reply": "2024-09-27T12:58:03.230133Z" + "iopub.execute_input": "2024-09-28T05:58:58.457643Z", + "iopub.status.busy": "2024-09-28T05:58:58.457538Z", + "iopub.status.idle": "2024-09-28T05:58:58.466102Z", + "shell.execute_reply": "2024-09-28T05:58:58.465863Z" } }, "outputs": [ @@ -2088,15 +2202,19 @@ "text": [ "<|start_header_id|>assistant<|end_header_id|>\n", "\n", - "1. Use the `functions.get_stock_ticker` tool to obtain the stock ticker symbol for Vulcan.\n", - "2. Use the `functions.get_stock_data` tool to retrieve the stock prices for Vulcan over a specified date range.\n", - "3. Summarize the information obtained from the stock ticker and stock data to provide a comprehensive overview of Vulcan's financials.<|eot_id|>\n" + "To help the user learn about Vulcan's financials, I will follow these steps:\n", + "\n", + "1. Use the `get_stock_ticker` function to find the stock ticker symbol for Vulcan.\n", + "2. Use the `get_stock_data` function to retrieve recent stock price data for Vulcan using the obtained ticker symbol.\n", + "3. Summarize the financial information and stock performance of Vulcan based on the retrieved data.\n", + "\n", + "Let's start with step 1.<|eot_id|>\n" ] } ], "source": [ "training_data = agent2.make_training_data(final_tape1)\n", - "print(training_data[0].output_text)\n" + "print(training_data[0].output_text)" ] }, { @@ -2132,13 +2250,13 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 23, "metadata": { "execution": { - "iopub.execute_input": "2024-09-27T12:58:03.234842Z", - "iopub.status.busy": "2024-09-27T12:58:03.234473Z", - "iopub.status.idle": "2024-09-27T12:58:03.282332Z", - "shell.execute_reply": "2024-09-27T12:58:03.279621Z" + "iopub.execute_input": "2024-09-28T05:58:58.467436Z", + "iopub.status.busy": "2024-09-28T05:58:58.467322Z", + "iopub.status.idle": "2024-09-28T05:58:58.477422Z", + "shell.execute_reply": "2024-09-28T05:58:58.477179Z" } }, "outputs": [], @@ -2147,13 +2265,19 @@ "\n", "browser = SimpleTextBrowser()\n", "search_agent_env = ToolEnvironment([browser.get_search_results, browser.get_page, browser.get_next_page])\n", + "\n", + "\n", "# We will use the tool choice mechanism to let the main agent call its search specialist agent.\n", "# To this end, we create a mock tool that represents calling the search agent.\n", "def call_search_agent(query: str):\n", " \"\"\"Use this tool to ask a fellow AI agent to search for information on the web.\"\"\"\n", " pass\n", + "\n", + "\n", "main_agent_env = ToolEnvironment([get_stock_ticker, get_stock_data, call_search_agent])\n", - "whole_env = ToolEnvironment([get_stock_ticker, get_stock_data, browser.get_search_results, browser.get_page, browser.get_next_page])" + "whole_env = ToolEnvironment(\n", + " [get_stock_ticker, get_stock_data, browser.get_search_results, browser.get_page, browser.get_next_page]\n", + ")" ] }, { @@ -2174,13 +2298,13 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 24, "metadata": { "execution": { - "iopub.execute_input": "2024-09-27T12:58:03.288761Z", - "iopub.status.busy": "2024-09-27T12:58:03.288396Z", - "iopub.status.idle": "2024-09-27T12:58:03.298024Z", - "shell.execute_reply": "2024-09-27T12:58:03.297075Z" + "iopub.execute_input": "2024-09-28T05:58:58.478537Z", + "iopub.status.busy": "2024-09-28T05:58:58.478443Z", + "iopub.status.idle": "2024-09-28T05:58:58.481118Z", + "shell.execute_reply": "2024-09-28T05:58:58.480906Z" } }, "outputs": [ @@ -2215,7 +2339,7 @@ "# We will print a brief summary of view stack after each step\n", "for i in range(0, len(tape)):\n", " print(f\"View stack after step {i}\")\n", - " view_stack = TapeViewStack.compute(tape[:i + 1])\n", + " view_stack = TapeViewStack.compute(tape[: i + 1])\n", " for view in view_stack.stack:\n", " step_summary = \", \".join([step.__class__.__name__ for step in view.steps])\n", " print(f\"-- {view.agent_full_name}: {step_summary}\")\n", @@ -2233,13 +2357,13 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 25, "metadata": { "execution": { - "iopub.execute_input": "2024-09-27T12:58:03.301833Z", - "iopub.status.busy": "2024-09-27T12:58:03.301484Z", - "iopub.status.idle": "2024-09-27T12:58:10.443839Z", - "shell.execute_reply": "2024-09-27T12:58:10.443044Z" + "iopub.execute_input": "2024-09-28T05:58:58.482288Z", + "iopub.status.busy": "2024-09-28T05:58:58.482159Z", + "iopub.status.idle": "2024-09-28T05:59:06.315624Z", + "shell.execute_reply": "2024-09-28T05:59:06.315130Z" } }, "outputs": [ @@ -2249,7 +2373,7 @@ "

Metadata

Show / Hide
author: null\n", "author_tape_id: null\n", "error: null\n", - "id: 8501b6aa-1ffc-427d-aa47-dd4d73ab762b\n", + "id: c16a2fd7-fb64-4279-8800-87935c7e40ab\n", "n_added_steps: 1\n", "parent_id: null\n", "result: null\n", @@ -2258,72 +2382,83 @@ "\n", "What influenced Nvidia stock price in late 2022?

[1] Action: ToolCalls

tool_calls:\n",
        "- function:\n",
-       "    arguments: '{\"query\":\"Nvidia stock price influences late 2022\",\"max_results\":5}'\n",
+       "    arguments: '{\"query\":\"Nvidia stock price influence late 2022\",\"max_results\":5}'\n",
        "    name: get_search_results\n",
-       "  id: call_k4qIFQb9HacZq05adLWiZ73O\n",
+       "  id: call_Z2hMQ3l4lXLdWoIRL3L8ZCoq\n",
        "  type: function\n",
        "kind: assistant\n",
        "

[2] Thought: SetNextNode

kind: set_next_node\n",
        "next_node: 0\n",
-       "

[3] Observation: ToolResult

tool_call_id: call_k4qIFQb9HacZq05adLWiZ73O\n",
+       "

[3] Observation: ToolResult

tool_call_id: call_Z2hMQ3l4lXLdWoIRL3L8ZCoq\n",
        "kind: tool\n",
        "\n",
-       "
1835 characters ...[{'title': 'Is Nvidia Stock Recession-Proof? The Answer Might ...', 'url': 'https://www.theglobeandmail.com/investing/markets/stocks/NVDA/pressreleases/28539286/is-nvidia-stock-recession-proof-the-answer-might-surprise-you/', 'content': \"Sep 14, 2024 — Nvidia is sensitive to the economy's direction, and fears of a recession have threatened the stock in recent months as the unemployment rate is rising and\\xa0...\"}, {'title': 'NVIDIA Corporation - Stock Info - Historical Price Lookup', 'url': 'https://investor.nvidia.com/stock-info/historical-price-lookup/default.aspx', 'content': 'Stock quote & chart, historical price lookup, investment calculator, fundamentals, analyst coverage, financial info, financial reports, SEC filings, quarterly\\xa0...'}, {'title': 'Is Nvidia Stock In A Bubble Or Is It Justified By AI Growth?', 'url': 'https://www.forbes.com/sites/garthfriesen/2024/06/23/is-nvidia-stock-in-a-bubble-or-justified-by-ai-growth/', 'content': 'Jun 23, 2024 — Nvidia is no exception. Its shares fell by 66% at one point in 2022 and have had four drawdowns of approximately 15% or more in the last year\\xa0...'}, {'title': 'Has Nvidia Stock Peaked? These Words From the CEO ...', 'url': 'https://www.theglobeandmail.com/investing/markets/stocks/GS/pressreleases/28610682/has-nvidia-stock-peaked-these-words-from-the-ceo-may-suggest-whats-next/', 'content': 'Sep 18, 2024 — The combination of rising competition, decelerating revenue and margin trends, and the immense (and unrealistic) expectations that Nvidia will\\xa0...'}, {'title': 'How Does Nvidia Stock Influence the Market?', 'url': 'https://b2broker.com/news/how-does-nvidia-stock-influence-the-market/', 'content': \"Jul 10, 2024 — Nvidia's economic influence can shift the entire market sideways as an increasing buying pressure drives the stock price higher.\"}]

[4] Action: ToolCalls

tool_calls:\n",
+       "
1780 characters ...[{'title': 'Nvidia Stock Eyes All-Time High Amid Rebound', 'url': 'https://www.investors.com/research/nvda-stock-is-nvidia-a-buy-2/', 'content': '7 hours ago — It reported three quarters of declining year-over-year sales and four quarters of tapering earnings in late 2022 and early 2023. But then\\xa0...'}, {'title': 'NVIDIA Corporation - Stock Info - Historical Price Lookup', 'url': 'https://investor.nvidia.com/stock-info/historical-price-lookup/default.aspx', 'content': 'Stock quote & chart, historical price lookup, investment calculator, fundamentals, analyst coverage, financial info, financial reports, SEC filings, quarterly\\xa0...'}, {'title': \"Nvidia's stock chart shows how bulls are using the recent ...\", 'url': 'https://www.morningstar.com/news/marketwatch/20240927301/nvidias-stock-chart-shows-how-bulls-are-using-the-recent-pause-to-get-refreshed', 'content': '4 hours ago — A check of history shows that the late 2018 downtrend that followed a three-year rally took the stock down 56%, and the late-2021 to late-2022\\xa0...'}, {'title': \"What's going on with Nvidia stock and the booming AI ...\", 'url': 'https://www.techtarget.com/whatis/feature/Whats-going-on-with-Nvidia-stock-and-the-booming-AI-market', 'content': \"Sep 4, 2024 — Nvidia's market value surpassed $3 trillion in 2024, fueled by the generative AI boom, rebounding tech sector and 154% stock growth in 2024.\"}, {'title': 'Nvidia Stock Price at 52-Week Low After US Restricts ...', 'url': 'https://www.globaldata.com/data-insights/technology--media-and-telecom/nvidia-stock-price-at-52-week-low-after-us-restricts-sales-to-china/', 'content': 'The share price of Nvidia hit a 52-week low after the US restricted sales to China; In 2022, China accounted for over 27% of the total sales\\xa0...'}]

[4] Action: ToolCalls

tool_calls:\n",
+       "- function:\n",
+       "    arguments: '{\"url\": \"https://www.investors.com/research/nvda-stock-is-nvidia-a-buy-2/\"}'\n",
+       "    name: get_page\n",
+       "  id: call_FxVcG8Z7DxKjh46mq5WBoi9V\n",
+       "  type: function\n",
+       "- function:\n",
+       "    arguments: '{\"url\": \"https://www.morningstar.com/news/marketwatch/20240927301/nvidias-stock-chart-shows-how-bulls-are-using-the-recent-pause-to-get-refreshed\"}'\n",
+       "    name: get_page\n",
+       "  id: call_tSXwVXXt8mKkQyz647tX9FD9\n",
+       "  type: function\n",
        "- function:\n",
-       "    arguments: '{\"url\":\"https://www.forbes.com/sites/garthfriesen/2024/06/23/is-nvidia-stock-in-a-bubble-or-justified-by-ai-growth/\"}'\n",
+       "    arguments: '{\"url\": \"https://www.globaldata.com/data-insights/technology--media-and-telecom/nvidia-stock-price-at-52-week-low-after-us-restricts-sales-to-china/\"}'\n",
        "    name: get_page\n",
-       "  id: call_21mbAUAtF9nOrbfliwcrE1af\n",
+       "  id: call_IQs92nhMwXLwUhq9SFNTS285\n",
        "  type: function\n",
        "kind: assistant\n",
        "

[5] Thought: SetNextNode

kind: set_next_node\n",
        "next_node: 0\n",
-       "

[6] Observation: ToolResult

tool_call_id: call_21mbAUAtF9nOrbfliwcrE1af\n",
+       "

[6] Observation: ToolResult

tool_call_id: call_FxVcG8Z7DxKjh46mq5WBoi9V\n",
        "kind: tool\n",
        "\n",
-       "
17406 characters ...('Title: Is Nvidia Stock In A Bubble Or Is It Justified By AI Growth?\\n=======================\\n[Subscribe To Newsletters](https://account.forbes.com/newsletters)BETAThis is a BETA experience. You may opt\\\\-out by\\xa0clicking here### More From Forbes\\n\\nSep 24, 2024,07:15am EDT[The Best Investment Opportunity In The Coming Decade? Women’s Sports](https://www.forbes.com/sites/robertdaugherty/2024/09/24/best-investment-opportunity-in-the-coming-decade--womens-sports/)Sep 23, 2024,11:14am EDT[China Market Update: PBOC Cuts With More To Come, Buybacks Roll On](https://www.forbes.com/sites/brendanahern/2024/09/23/china-market-update-pboc-cuts-with-more-to-come-buybacks-roll-on/)Sep 23, 2024,09:00am EDT[What Is The Dow Jones Industrial Average, Really?](https://www.forbes.com/sites/johndorfman/2024/09/23/what-is-the-dow-jones-industrial-average-really/)Sep 23, 2024,08:53am EDT[Will The New U.K. Government Kill Off The London Stock Market?](https://www.forbes.com/sites/investor/2024/09/23/will-the-new-uk-government-kill-off-the-london-stock-market/)Sep 22, 2024,03:48pm EDT[The Nasdaq 100’s 4 Big A’s: Alphabet, Amazon, Apple, Advanced Micro](https://www.forbes.com/sites/johnnavin/2024/09/22/the-nasdaq-100s-4-big-as-alphabet-amazon-apple-advanced-micro/)Sep 21, 2024,08:00am EDT[No End In Sight For Swiss Watch Industry Downturn](https://www.forbes.com/sites/garthfriesen/2024/09/21/no-end-in-sight-for-swiss-watch-industry-downturn/)Sep 21, 2024,06:30am EDT[Market Lessons: 20 Companies With Dazzling Growth In Revenue Per Share](https://www.forbes.com/sites/baldwin/2024/09/21/market-lessons-20-companies-with-dazzling-growth-in-revenue-per-share/)Sep 20, 2024,07:29pm EDT[Retailers Expect To ‘Eat’ Latest Tariff Hikes, Not Raise Prices](https://www.forbes.com/sites/gregpetro/2024/09/20/retailers-expect-to-eat-latest-tariff-hikes-not-raise-prices/)[Edit Story](https://bertie.forbes.com/#/compose?id=6678679658783406879ec635)[Forbes](https://www.forbes.com/)[Money](https://www.forbes.com/money/)[Investing](https://www.forbes.com/investing/)[Editors\\' Pick](https://www.forbes.com/editors-picks)Is Nvidia Stock In A Bubble Or Is It Justified By AI Growth?\\n============================================================\\n\\n[Garth Friesen](https://www.forbes.com/sites/garthfriesen/ \"https://www.forbes.com/sites/garthfriesen/\")ContributorOpinions expressed by Forbes Contributors are their own.Specialist in global markets, economics and alternative investments.[Following](https://account.forbes.com/following \"https://account.forbes.com/following\")Jun 23, 2024,04:06pm EDTUpdated Jun 24, 2024, 01:29pm EDT* Share to Facebook\\n* Share to Twitter\\n* Share to Linkedin\\n\\nAFP PHOTO (Photo credit should read NOEL CELIS/AFP via Getty Images)\\n\\nAFP via Getty Images\\n\\nNvidia shares dropped nearly 7% over a two\\\\-day span, sparking concerns that the meteoric rise of the artificial intelligence market leader\\'s stock price may have peaked. Nvidia briefly surpassed Microsoft and Apple midweek to become the world\\'s most valuable company but slipped back to third place by Friday\\'s close. Investors are now debating whether to take profits on NVDA and the broader AI sector or stick with the theme that has driven most of this year\\'s S\\\\&P 500 gains.\\n\\nFirst, the recent 7% dip should be taken into context. Nvidia shares are still up 156% year to date, and last week\\'s dip is relatively minor and barely shows up on a long\\\\-term chart. Investors should expect dramatic and painful drawdowns from companies that have moved so far so fast. Nvidia is no exception. Its shares fell by 66% at one point in 2022 and have had four drawdowns of approximately 15% or more in the last year alone.\\n\\nNVDA stock price\\n\\nGarth Friesen\\n\\nStill, several concerns are causing investors to reevaluate their faith in the Nvidia rally. Gaining the status as the world\\'s most valuable company when the overall economy appears to be losing momentum is one obvious worry. The extreme [domination of large\\\\-cap technology stocks](https://www.forbes.com/sites/garthfriesen/2024/06/17/microsoft-nvidia-and-apples-index-dominance-reaches-alarming-level/ \"https://www.forbes.com/sites/garthfriesen/2024/06/17/microsoft-nvidia-and-apples-index-dominance-reaches-alarming-level/\") at the index level is another. Also, the significant outperformance of AI\\\\-related stocks in the last month relative to the rest of the market has once again prompted talk of bubble\\\\-like price action. These concerns provide an opportunity to pause and look at Nvidia from a larger perspective. Is a bubble forming, or is the share price appreciation warranted?\\n\\nThere are some standard definitions of a stock or stock market bubble, primarily using history is a guide. Typical characteristics are rapid and substantial price increases that outpace reasonable valuations; widespread investor enthusiasm and speculation, often accompanied by a fear of missing out and speculative behavior; and a belief in new paradigms, technologies, or economic conditions that create excitement about future growth prospects.\\n\\nMORE FROMFORBES ADVISOR[### Best High\\\\-Yield Savings Accounts Of 2024](https://www.forbes.com/advisor/banking/savings/best-high-yield-savings-accounts/?utm_source=forbes&utm_medium=recirc&utm_campaign=tiger-sept23 \"https://www.forbes.com/advisor/banking/savings/best-high-yield-savings-accounts/?utm_source=forbes&utm_medium=recirc&utm_campaign=tiger-sept23\")[ByKevin PayneContributor](https://www.forbes.com/advisor/author/kevin-payne/ \"https://www.forbes.com/advisor/author/kevin-payne/\")[### Best 5% Interest Savings Accounts of 2024](https://www.forbes.com/advisor/banking/savings/best-5-percent-interest-savings-accounts/?utm_source=forbes&utm_medium=recirc&utm_campaign=tiger-sept23 \"https://www.forbes.com/advisor/banking/savings/best-5-percent-interest-savings-accounts/?utm_source=forbes&utm_medium=recirc&utm_campaign=tiger-sept23\")[ByCassidy HortonContributor](https://www.forbes.com/advisor/author/cassidy-horton \"https://www.forbes.com/advisor/author/cassidy-horton\")\\nRapid And Substantial Price Appreciation\\n----------------------------------------\\n\\nNvidia and other AI stocks have rocketed higher in the last 18 months. Nvidia has soared nearly 800% since the start of 2023 and other tech giants like Meta (\\\\+297%), Amazon (\\\\+120%) and Microsoft (\\\\+88%) have done the same. However, the near\\\\-parabolic rise is not without fundamental support. Nvidia continues to exceed analysts\\' expectations of earnings and profit growth and boasts an estimated market share of 80% in specialized chips needed for most AI applications. The other technology leaders are also delivering earnings growth above what many thought possible.\\n\\nSpecifically, [Nvidia’s financial results for the first quarter](https://nvidianews.nvidia.com/news/nvidia-announces-financial-results-for-first-quarter-fiscal-2025 \"https://nvidianews.nvidia.com/news/nvidia-announces-financial-results-for-first-quarter-fiscal-2025\") of fiscal year 2025 showed revenue growth of 262% compared to a year ago. Data center growth was even more impressive, climbing 427% from last year. With gross margins of 78%, profits are following suit. Clearly, there is more to Nvidia than pure speculation.\\n\\n1\\\\-year forward P/E multiple for Nvidia and and Nasdaq 100\\n\\nGarth Friesen; Bloomberg LP\\n\\nFrom a valuation perspective, Nvidia is not cheap. According to *Bloomberg* data, NVDA’s one\\\\-year forward price\\\\-to\\\\-earnings ratio is 47x, compared to 35\\\\.9x for the Philadelphia Stock Exchange Semiconductor Index, 29x for the NASDAQ 100 Index, 22\\\\.6x for the S\\\\&P 500, and 17\\\\.8x for the equal\\\\-weight S\\\\&P 500 Index. Yes, Nvidia is expensive relative to the broader market, but that is to be expected given the rapid growth in revenue and earnings. Investors are willing to pay up for growth, and Nvidia is delivering. Applying traditional valuation metrics to fast\\\\-growing companies in relatively new industries is often futile. But are the current multiples too extreme?\\n\\nBy comparison, during the [peak of the dot\\\\-com bubble in 2000](https://www.nasdaq.com/articles/are-tech-stocks-in-a-bubble \"https://www.nasdaq.com/articles/are-tech-stocks-in-a-bubble\"), Nasdaq 100 stocks traded at an absurd trailing P/E of 200, more than six times today\\'s level. Cisco, a poster child of the dot\\\\-com era, was valued at a multiple of more than 150 times forward earnings when the stock hit its peak in March 2000\\\\. In this context, neither Nvidia nor the broader market are near the valuation levels seen during the internet bubble. However, Nvidia’s recent earnings and sales multiple expansion suggests a disconnect between the share price and performance of the underlying business. AI stocks have spiked, and valuations have stretched, but at least some fundamental support is behind the craze.\\n\\nIf rating its rapid price appreciation bubble on a scale of 1 to 10, the score is likely a seven.\\n\\nWidespread Investor Enthusiasm And Speculation\\n----------------------------------------------\\n\\nAnother potential sign of a bubble is extreme euphoria and speculation surrounding a stock or a theme.\\n\\nThe options market is one place to look for excessive sentiment. Stocks or sectors where call option volatility is trading higher than put option volatility is often a sign that investors expect significant upside from existing levels. Currently, 1\\\\-month and 3\\\\-month call options have roughly the same level of implied volatility as put options. This is consistent with market pricing over the last year. Call options were more expensive last March around the earnings report. Today, there does not appear to be extreme bullishness in the options market.\\n\\nStill, everyone is watching the AI boom. Public company mentions of AI in earnings calls are at a record high. Roughly [40% of S\\\\&P 500 discussed AI](https://sherwood.news/business/number-of-s-and-p-500-companies-mentioning-ai-hits-record/ \"https://sherwood.news/business/number-of-s-and-p-500-companies-mentioning-ai-hits-record/\") on their earnings calls this past quarter — up from 1% five years ago, according to data from FactSet. Most of these companies cite AI as a potential productivity booster rather than an additional source of revenue, and many are making substantial investments in the technology. There is widespread enthusiasm about AI, but it should not be considered speculation since productivity improvements have already been established.\\n\\nA potentially worrisome sign would be a rush of new companies tapping the public markets to raise money for anything related to AI, similar to the internet bubble where investors scrambled to buy anything with \".com\" in the name. According to Bloomberg, total initial public offerings are running at about $16 billion in proceeds raised year\\\\-to\\\\-date versus about $20 billion for all of 2023\\\\. In terms of deal count, there have been [88 IPOs through mid\\\\-June 2024](https://stockanalysis.com/ipos/statistics/ \"https://stockanalysis.com/ipos/statistics/\"), compared to 154 in 2023\\\\. The record was set in 2021 with 1035 IPOs. If there was an AI startup bubble, it peaked in 2021\\\\.\\n\\nIf rating the level of speculation in Nvidia to past bubbles on a scale of 1 to 10, the score is probably a six.\\n\\nBelief In New Paradigms\\n-----------------------\\n\\nAI is not the first technology to induce predictions of a materially altered future. Crypto was supposed to be the future of finance, and 3\\\\-D printing was expected to revolutionize manufacturing. Neither crypto nor 3\\\\-D printing has lived up to the initial hype. AI may fall into the same category, but there are reasons to believe it will indeed have a material impact on economics and society.\\n\\nBig technology firms and dozens of large corporations are making huge investments in the space. Hundreds of billions of dollars are flowing into Nvidia\\'s chips and AI\\\\-related infrastructure, such as data centers and the electrical grid. These investments are already paying off in direct AI revenue and [enhanced productivity](https://www.goldmansachs.com/intelligence/pages/AI-is-showing-very-positive-signs-of-boosting-gdp.html \"https://www.goldmansachs.com/intelligence/pages/AI-is-showing-very-positive-signs-of-boosting-gdp.html\").\\n\\nAccording to a [recent PwC report](https://www.pwc.com/gx/en/issues/data-and-analytics/publications/artificial-intelligence-study.html \"https://www.pwc.com/gx/en/issues/data-and-analytics/publications/artificial-intelligence-study.html\"), AI is predicted to increase productivity, raise growth domestic product growth, contribute to scientific discovery, and improve the healthcare system. The study predicts AI has the potential to contribute 14%, or $15\\\\.7 trillion, to the global economy by 2030\\\\. These are lofty predictions and very well may materialize. However, the fact that these studies are becoming more prevalent indicates belief that a new paradigm has formed.\\n\\nA number of changing circumstances could quickly alter the impact of this new paradigm. Shifts in global trade policy, emerging new technologies and competitors, a markdown in global growth expectations, or geopolitical shocks are just a few examples. AI could have a significant impact on many aspects of society, but it is possible that the return on investment will fail to materialize. Regardless of the outcome, investors are betting on, and talking about, a “new future.”\\n\\nWhen comparing the level of belief in a new paradigm to past bubbles on a scale of 1 to 10, the score would likely be an eight.\\n\\nNvidia Is Not In A Bubble But It Is Not Without Risk\\n----------------------------------------------------\\n\\nNvidia has become larger than the respective stock markets of Germany, France, and the U.K. Nvidia and other companies directly benefiting from AI are now at valuation levels that offer little room for error, and they must continue surpassing expectations and maintaining their market leadership to justify their current price.\\n\\nIs there a risk of another drawdown similar in magnitude to the ones we have witnessed over the last year? Absolutely. But is there a bubble\\\\-bursting crash in all AI\\\\-related stocks around the corner? Likely not. According to standard definitions of a bubble, Nvidia does not appear to be in the late stages of a one: valuations are high, but not at extreme levels; enthusiasm about AI is widespread, but not without fundamental support; and AI has already started to deliver on some of the lofty expectations in terms of new applications and overall productivity, validating predictions of a new paradigm.\\n\\nFollow me on\\xa0[Twitter](https://www.twitter.com/Garth_Friesen)\\xa0or\\xa0[LinkedIn](https://www.linkedin.com/in/garthfriesen).\\xa0Check out\\xa0my\\xa0[website](https://www.garthfriesen.com).\\xa0[![Garth Friesen](https://blogs-images.forbes.com/garthfriesen/files/2017/08/Garth-Friesen_avatar_1503528310-400x400.jpg)](https://www.forbes.com/sites/garthfriesen/ \"Photo of Garth Friesen\")[Garth Friesen](https://www.forbes.com/sites/garthfriesen/ \"https://www.forbes.com/sites/garthfriesen/\")[Following](https://account.forbes.com/following \"https://account.forbes.com/following\")* [Editorial Standards](https://www.forbes.com/sites/forbesstaff/article/forbes-editorial-values-and-standards/)\\n* [Forbes Accolades](https://www.forbes.com/accolades/)\\n\\n### Join The Conversation\\n\\nComments\\xa0One Community. Many Voices.\\xa0Create a free account to share your thoughts.\\n\\nRead our community guidelines\\xa0 here.![](https://static-cdn.spot.im/assets/community-guidelines/community-guidelines-symbol.svg)Forbes Community Guidelines\\n---------------------------\\n\\nOur community is about connecting people through open and thoughtful conversations. We want our readers to share their views and exchange ideas and facts in a safe space.\\n\\nIn order to do so, please follow the posting rules in our site\\'s\\xa0[Terms of Service.](https://www.forbes.com/terms-and-conditions)\\xa0 We\\'ve summarized some of those key rules below. Simply put, keep it civil.\\n\\nYour post will be rejected if we notice that it seems to contain:\\n\\n* False or intentionally out\\\\-of\\\\-context or misleading information\\n* Spam\\n* Insults, profanity, incoherent, obscene or inflammatory language or threats of any kind\\n* Attacks on the identity of other commenters or the article\\'s author\\n* Content that otherwise violates our site\\'s\\xa0[terms.](https://www.forbes.com/terms-and-conditions)\\n\\nUser accounts will be blocked if we notice or believe that users are engaged in:\\n\\n* Continuous attempts to re\\\\-post comments that have been previously moderated/rejected\\n* Racist, sexist, homophobic or other discriminatory comments\\n* Attempts or tactics that put the site security at risk\\n* Actions that otherwise violate our site\\'s\\xa0[terms.](https://www.forbes.com/terms-and-conditions)\\n\\nSo, how can you be a power user?\\n\\n* Stay on topic and share your insights\\n* Feel free to be clear and thoughtful to get your point across\\n* ‘Like’ or ‘Dislike’ to show your point of view.\\n* Protect your community.\\n* Use the report tool to alert us when someone breaks the rules.\\n\\nThanks for reading our community guidelines. Please read the full list of posting rules found in our site\\'s\\xa0[Terms of Service.](https://www.forbes.com/terms-and-conditions)', 1, 1)

[7] search_agent responds to Agent

kind: respond\n",
-       "copy_output: false\n",
+       "
32986 characters ...('Title: Nvidia Stock Eyes All-Time High Amid Rebound; Is Nvidia A Buy Now?Investor\\'s Business Daily\\n=======================\\n![](https://www.queryly.com/images/whitesearchicon.png)\\n\\n* [Market Trend](https://research.investors.com/markettrend.aspx)\\n\\t+ [Market Trend](https://research.investors.com/markettrend.aspx)\\n\\t\\t- [The Big Picture](https://www.investors.com/category/market-trend/the-big-picture/)\\n\\t\\t- [Stock Market Data](https://www.investors.com/research/stock-market-data-dow-jones-sp-500-nasdaq-spdr-etfs/)\\n\\t\\t- [Stock Market Today](https://www.investors.com/news/stock-market-today-stock-market-news/)\\n\\t\\t- [New? Start Here](https://get.investors.com/getting-started/?src=A00332A&intcode=EditorialTests_GettingStarted_MarketTrend)\\n\\t\\t- [ETF Market Strategy](https://www.investors.com/market-trend/ibds-etf-market-strategy/ibds-etf-market-strategy/)\\n\\t\\t- [IBD Digital: 2 Months for $20](https://get.investors.com/ibd/?intcode=gnvb%7Cgnvb%7Cevgr%7C2021%7C08%7Cibdd%7Cna%7C%7C115458&src=AKCAGE)\\n\\t\\t- [Psychological Indicators](https://research.investors.com/psychological-market-indicators/)\\n* [Stock Lists](https://www.investors.com/stock-lists/stocks-to-watch-top-rated-ipos-big-caps-and-growth-stocks/)\\n\\t+ [Stock Lists](https://www.investors.com/stock-lists/stocks-to-watch-top-rated-ipos-big-caps-and-growth-stocks/)\\n\\t\\t- [**IBD 50**](https://research.investors.com/stock-lists/ibd-50/)\\n\\t\\t- [My Stock Lists](https://myibd.investors.com/my-ibd/portfolio.aspx)\\n\\t\\t- [Stocks Near A Buy Zone](https://www.investors.com/category/stock-lists/stocks-near-a-buy-zone/)\\n\\t\\t- [IBD ETF Indexes](https://www.investors.com/ibd-indexes/ibd-etf-indexes-ibd-50-etf-leaders-breakout-stocks-etf-ffty-ldrs-bout/)\\n\\t\\t- [**IBD Sector Leaders**](https://research.investors.com/stock-lists/sector-leaders)\\n\\t\\t- [Stock Lists Update](https://www.investors.com/stock-lists/best-growth-stocks-buy-watch-ibd-stock-lists/)\\n\\t\\t- [Relative Strength at New High](https://research.investors.com/stock-lists/relative-strength-at-new-high/)\\n\\t\\t- [IBD Data Tables](https://www.investors.com/ibd-data-tables/)\\n\\t\\t- [**IBD Big Cap 20**](https://research.investors.com/stock-lists/big-cap-20/)\\n\\t\\t- [Stocks On The Move](https://research.investors.com/stocksonthemove.aspx)\\n\\t\\t- [Rising Profit Estimates](https://research.investors.com/stock-lists/rising-profit-estimates/)\\n\\t\\t- [IBD Digital: 2 Months for $20](https://get.investors.com/ibd/?intcode=gnvb%7Cgnvb%7Cevgr%7C2021%7C08%7Cibdd%7Cna%7C%7C115458&src=AKCAGE)\\n\\t\\t- [**IBD Long\\\\-Term Leaders**](https://www.investors.com/research/best-stocks-to-buy-now-long-term-stocks-ibd-long-term-leaders-list/)\\n\\t\\t- [New Highs](https://research.investors.com/stock-lists/new-highs/)\\n\\t\\t- [Stocks Funds Are Buying](https://research.investors.com/stock-lists/stocks-that-funds-are-buying/)\\n\\t\\t- [New? Start Here](https://shop.investors.com/offer/splashresponsive.aspx?id=gettingstarted&src=A00332A&intcode=EditorialTests_GettingStarted_StockLists)\\n\\t\\t- [**IPO Leaders**](https://research.investors.com/stock-lists/ipo-leaders/)\\n\\t\\t- [Stock Spotlight](https://research.investors.com/stock-lists/stock-spotlight/)\\n\\t\\t- [Your Weekly Review](https://research.investors.com/stock-lists/your-weekly-review/)\\n* [Research](https://research.investors.com)\\n\\t+ [Stock Research](https://research.investors.com)\\n\\t\\t- [IBD Stock Checkup](https://research.investors.com/stock-checkup/)\\n\\t\\t- [Investing Action Plan](https://www.investors.com/category/research/investing-action-plan/)\\n\\t\\t- [The Income Investor](https://www.investors.com/category/research/the-income-investor/)\\n\\t\\t- [Stock Of The Day](https://www.investors.com/research/ibd-stock-of-the-day/)\\n\\t\\t- [Earnings Preview](https://www.investors.com/category/research/earnings-preview/)\\n\\t\\t- [IBD Stock Analysis](https://www.investors.com/category/research/ibd-stock-analysis/)\\n\\t\\t- [Screen Of The Day](https://www.investors.com/research/best-stocks-to-buy-watch-ibd-screen-of-the-day/)\\n\\t\\t- [Earnings Calendar](https://www.investors.com/research/earnings-calendar-analyst-estimates-stocks-to-watch/)\\n\\t\\t- [Industry Snapshot](https://www.investors.com/category/research/industry-snapshot/)\\n\\t\\t- [IBD Charts](https://research.investors.com/stock-charts/nasdaq-nasdaq-composite-0ndqc.htm?cht=pvc&type=daily)\\n\\t\\t- [Industry Themes](https://www.investors.com/category/research/ibd-industry-themes/)\\n\\t\\t- [IBD 50 Stocks To Watch](https://www.investors.com/research/ibd-50-growth-stocks-to-watch/)\\n\\t\\t- [Stock Screener](https://ibdstockscreener.investors.com)\\n\\t\\t- [The New America](https://www.investors.com/category/research/the-new-america/)\\n\\t\\t- [IBD Data Stories](https://www.investors.com/ibd-data-stories/build-your-investing-watch-list-with-stock-ratings-buy-zones-earnings/)\\n\\t\\t- [Swing Trading](https://www.investors.com/category/research/swing-trading/)\\n\\t\\t- [Best ETFs](https://www.investors.com/etfs-and-funds/etfs/best-etfs-exchange-traded-funds/)\\n\\t\\t- [IBD Digital: 2 Months for $20](https://get.investors.com/ibd/?intcode=gnvb%7Cgnvb%7Cevgr%7C2021%7C08%7Cibdd%7Cna%7C%7C115458&src=AKCAGE)\\n\\t\\t- [Options](https://www.investors.com/category/research/options/)\\n\\t\\t- [Best Mutual Funds](https://www.investors.com/etfs-and-funds/mutual-funds/best-mutual-funds-news-performance-reports-investing-ideas/)\\n\\t+ [Premium Investing Tools](https://research.investors.com)\\n\\t\\t- [MarketSurge](https://marketsurge.investors.com/)\\n\\t\\t- [IBD Live](https://research.investors.com/ibdlive)\\n\\t\\t- [Leaderboard](https://leaderboard.investors.com/)\\n\\t\\t- [SwingTrader](https://swingtrader.investors.com)\\n\\t\\t- [MarketDiem](https://get.investors.com/marketdiem/?intcode=lgnv%7Clgnv%7Cprdmcst%7C2022%7C10%7Cmkdm%7Cna%7C%7C832881&src=A00653)\\n* [NEWS](https://www.investors.com/tag/all-news-and-stock-ideas/)\\n\\t+ [NEWS](https://www.investors.com/tag/all-news-and-stock-ideas/)\\n\\t\\t- [*e*IBD](https://research.investors.com/eIBD)\\n\\t\\t- [Cryptocurrency](https://www.investors.com/news/cryptocurrency-prices-news/)\\n\\t\\t- [Technology](https://www.investors.com/technology/)\\n\\t\\t- [Retirement](https://www.investors.com/category/etfs-and-funds/retirement/)\\n\\t\\t- [Magnificent Seven Stocks](https://www.investors.com/research/magnificent-seven-stocks-latest-news-market-cap-weighting/)\\n\\t\\t- [Management](https://www.investors.com/management/)\\n\\t\\t- [Personal Finance](https://www.investors.com/category/etfs-and-funds/personal-finance/)\\n\\t\\t- [Industry News Pages](https://www.investors.com/news/industry-news-and-stocks-to-watch/)\\n\\t\\t- [Special Reports](https://www.investors.com/special-reports/)\\n\\t+ [ECONOMY](https://www.investors.com/economic-news-president-job-approval/)\\n\\t\\t- [Economic Calendar](https://research.investors.com/economic-calendar/)\\n\\t\\t- [IBD Digital: 2 Months for $20](https://get.investors.com/ibd/?intcode=gnvb%7Cgnvb%7Cevgr%7C2021%7C08%7Cibdd%7Cna%7C%7C115458&src=AKCAGE)\\n\\t\\t- [Economic News](https://www.investors.com/category/news/economy/)\\n* [Videos](https://www.investors.com/ibd-videos/)\\n\\t+ [VIDEOS \\\\& PODCASTS](https://www.investors.com/ibd-videos/)\\n\\t\\t- [IBD Live](https://research.investors.com/ibdlive)\\n\\t\\t- [Investing With IBD Podcast](https://www.investors.com/podcast)\\n\\t\\t- [How To Invest Videos](https://www.investors.com/ibd-videos/category/how-to-invest-videos)\\n\\t\\t- [Growth Stories Podcast](https://get.investors.com/growth-stories-podcast/)\\n\\t\\t- [Options Videos](https://www.investors.com/ibd-videos/category/options-ibd-videos?archive=1)\\n\\t\\t- [Online Courses](https://get.investors.com/online-courses/?src=A00272A)\\n\\t\\t- [Webinars](https://www.investors.com/ibd-videos/category/webinars)\\n\\t\\t- [IBD Digital: 2 Months for $20](https://get.investors.com/ibd/?intcode=gnvb%7Cgnvb%7Cevgr%7C2021%7C08%7Cibdd%7Cna%7C%7C115458&src=AKCAGE)\\n* [Learn](https://www.investors.com/how-to-invest/how-to-invest-rules-for-when-buy-and-sell-stocks-in-bull-and-bear-markets/)\\n\\t+ [How To Invest](https://www.investors.com/how-to-invest/how-to-invest-rules-for-when-buy-and-sell-stocks-in-bull-and-bear-markets/)\\n\\t\\t- [How To Invest In Stocks](https://www.investors.com/how-to-invest/how-to-invest-in-stocks-investing-for-beginners/)\\n\\t\\t- [When To Sell Stocks](https://www.investors.com/how-to-invest/when-to-sell-stocks/)\\n\\t\\t- [3 Keys To Stock Investing](https://www.investors.com/how-to-invest/stock-investing-how-to-make-money-in-stock-3-key-factors/)\\n\\t\\t- [Short Selling](https://www.investors.com/category/research/the-short-side/)\\n\\t\\t- [Stock Market Timing](https://www.investors.com/how-to-invest/stock-market-timing-how-to-invest-in-stocks-tracking-bull-markets-bear-markets-stock-market-trends/)\\n\\t\\t- [Swing Trading](https://www.investors.com/research/swing-trading/swing-trading-strategies/)\\n\\t\\t- [Tracking Stock Market Trends](https://www.investors.com/how-to-invest/how-to-handle-changing-stock-market-trends/)\\n\\t\\t- [What Is Crypto](https://www.investors.com/how-to-invest/cryptocurrency-what-is-crypto/)\\n\\t\\t- [How To Read Stock Charts](https://www.investors.com/how-to-invest/how-to-read-stock-charts-understanding-technical-analysis/)\\n\\t\\t- [Premium Online Courses](https://get.investors.com/online-courses/?src=A00272A)\\n\\t\\t- [How To Buy Stocks](https://www.investors.com/how-to-invest/how-to-buy-stocks-using-stock-lists-stock-ratings-stock-screener/)\\n\\t+ Educational Resources\\n\\t\\t- [New To IBD](https://get.investors.com/getting-started/)\\n\\t\\t- [Online Investing Courses](https://get.investors.com/online-courses/?src=APA1BQ)\\n\\t\\t- [Investor\\'s Corner](https://www.investors.com/category/how-to-invest/investors-corner/)\\n\\t\\t- [12 Days Of Learning](https://get.investors.com/ibd/12-days-of-learning/)\\n\\t\\t- [Investing With IBD Podcast](https://www.investors.com/podcast)\\n\\t\\t- [Investing Infographics](https://get.investors.com/infographics/)\\n\\t\\t- [Events \\\\& Webinars](https://get.investors.com/events/)\\n\\t\\t- [Chart School](https://workshops.investors.com/)\\n\\t\\t- [**IBD Moneyworks**](https://get.investors.com/moneyworks/)\\n* [MarketSurge](https://marketsurge.investors.com/?intcode=lgnv%7Clgnv%7CMarketSmith%7C2023%7C06%7Cmsp%7Cna%7C%7C725068&src=A00653)\\n* [IBD Live](https://research.investors.com/ibdlive?id=IBD-Live&src=A00582A)\\n* [Leaderboard](https://leaderboard.investors.com)\\n* [SwingTrader](https://swingtrader.investors.com)\\n* [MarketDiem](https://get.investors.com/marketdiem/?intcode=lgnv%7Clgnv%7Cprdmcst%7C2022%7C10%7Cmkdm%7Cna%7C%7C832881&src=A00653)\\n* [Store](https://get.investors.com/?src=APA1BQ)\\n\\n**BREAKING: [Core PCE Inflation Tame, Keeps Big Fed Rate Cut In Play](https://www.investors.com/news/economy/fed-inflation-report-core-price-index-tame-big-rate-cut-sp-500/)**\\n\\n[![Election Season Offer](https://www.investors.com/wp-content/uploads/2024/09/bc-election2024-alt-750x80-1.png)](https://get.investors.com/ibd/ibd-digital-2-for-12/?src=A00627&utm_source=i.com&utm_medium=NHPBroad&utm_campaign=ELECTION+2024&utm_id=ELECTION24)\\n\\n[![Investor\\'s Business Daily](https://www.investors.com/wp-content/themes/ibd/dist/images/ibd-logo.svg)](https://www.investors.com)\\n\\n Shopping Cart\\n\\n Your cart is currently empty.\\n Visit the [IBD Store](https://shop.investors.com) to get started.\\n\\n![](https://www.queryly.com/images/whitesearchicon.png)\\n\\n* [Market Trend](https://research.investors.com/markettrend.aspx)\\n\\t+ [Market Trend](https://research.investors.com/markettrend.aspx)\\n\\t\\t- [The Big Picture](https://www.investors.com/category/market-trend/the-big-picture/)\\n\\t\\t- [Stock Market Data](https://www.investors.com/research/stock-market-data-dow-jones-sp-500-nasdaq-spdr-etfs/)\\n\\t\\t- [Stock Market Today](https://www.investors.com/news/stock-market-today-stock-market-news/)\\n\\t\\t- [New? Start Here](https://get.investors.com/getting-started/?src=A00332A&intcode=EditorialTests_GettingStarted_MarketTrend)\\n\\t\\t- [ETF Market Strategy](https://www.investors.com/market-trend/ibds-etf-market-strategy/ibds-etf-market-strategy/)\\n\\t\\t- [IBD Digital: 2 Months for $20](https://get.investors.com/ibd/?intcode=gnvb%7Cgnvb%7Cevgr%7C2021%7C08%7Cibdd%7Cna%7C%7C115458&src=AKCAGE)\\n\\t\\t- [Psychological Indicators](https://research.investors.com/psychological-market-indicators/)\\n* [Stock Lists](https://www.investors.com/stock-lists/stocks-to-watch-top-rated-ipos-big-caps-and-growth-stocks/)\\n\\t+ [Stock Lists](https://www.investors.com/stock-lists/stocks-to-watch-top-rated-ipos-big-caps-and-growth-stocks/)\\n\\t\\t- [**IBD 50**](https://research.investors.com/stock-lists/ibd-50/)\\n\\t\\t- [My Stock Lists](https://myibd.investors.com/my-ibd/portfolio.aspx)\\n\\t\\t- [Stocks Near A Buy Zone](https://www.investors.com/category/stock-lists/stocks-near-a-buy-zone/)\\n\\t\\t- [IBD ETF Indexes](https://www.investors.com/ibd-indexes/ibd-etf-indexes-ibd-50-etf-leaders-breakout-stocks-etf-ffty-ldrs-bout/)\\n\\t\\t- [**IBD Sector Leaders**](https://research.investors.com/stock-lists/sector-leaders)\\n\\t\\t- [Stock Lists Update](https://www.investors.com/stock-lists/best-growth-stocks-buy-watch-ibd-stock-lists/)\\n\\t\\t- [Relative Strength at New High](https://research.investors.com/stock-lists/relative-strength-at-new-high/)\\n\\t\\t- [IBD Data Tables](https://www.investors.com/ibd-data-tables/)\\n\\t\\t- [**IBD Big Cap 20**](https://research.investors.com/stock-lists/big-cap-20/)\\n\\t\\t- [Stocks On The Move](https://research.investors.com/stocksonthemove.aspx)\\n\\t\\t- [Rising Profit Estimates](https://research.investors.com/stock-lists/rising-profit-estimates/)\\n\\t\\t- [IBD Digital: 2 Months for $20](https://get.investors.com/ibd/?intcode=gnvb%7Cgnvb%7Cevgr%7C2021%7C08%7Cibdd%7Cna%7C%7C115458&src=AKCAGE)\\n\\t\\t- [**IBD Long\\\\-Term Leaders**](https://www.investors.com/research/best-stocks-to-buy-now-long-term-stocks-ibd-long-term-leaders-list/)\\n\\t\\t- [New Highs](https://research.investors.com/stock-lists/new-highs/)\\n\\t\\t- [Stocks Funds Are Buying](https://research.investors.com/stock-lists/stocks-that-funds-are-buying/)\\n\\t\\t- [New? Start Here](https://shop.investors.com/offer/splashresponsive.aspx?id=gettingstarted&src=A00332A&intcode=EditorialTests_GettingStarted_StockLists)\\n\\t\\t- [**IPO Leaders**](https://research.investors.com/stock-lists/ipo-leaders/)\\n\\t\\t- [Stock Spotlight](https://research.investors.com/stock-lists/stock-spotlight/)\\n\\t\\t- [Your Weekly Review](https://research.investors.com/stock-lists/your-weekly-review/)\\n* [Research](https://research.investors.com)\\n\\t+ [Stock Research](https://research.investors.com)\\n\\t\\t- [IBD Stock Checkup](https://research.investors.com/stock-checkup/)\\n\\t\\t- [Investing Action Plan](https://www.investors.com/category/research/investing-action-plan/)\\n\\t\\t- [The Income Investor](https://www.investors.com/category/research/the-income-investor/)\\n\\t\\t- [Stock Of The Day](https://www.investors.com/research/ibd-stock-of-the-day/)\\n\\t\\t- [Earnings Preview](https://www.investors.com/category/research/earnings-preview/)\\n\\t\\t- [IBD Stock Analysis](https://www.investors.com/category/research/ibd-stock-analysis/)\\n\\t\\t- [Screen Of The Day](https://www.investors.com/research/best-stocks-to-buy-watch-ibd-screen-of-the-day/)\\n\\t\\t- [Earnings Calendar](https://www.investors.com/research/earnings-calendar-analyst-estimates-stocks-to-watch/)\\n\\t\\t- [Industry Snapshot](https://www.investors.com/category/research/industry-snapshot/)\\n\\t\\t- [IBD Charts](https://research.investors.com/stock-charts/nasdaq-nasdaq-composite-0ndqc.htm?cht=pvc&type=daily)\\n\\t\\t- [Industry Themes](https://www.investors.com/category/research/ibd-industry-themes/)\\n\\t\\t- [IBD 50 Stocks To Watch](https://www.investors.com/research/ibd-50-growth-stocks-to-watch/)\\n\\t\\t- [Stock Screener](https://ibdstockscreener.investors.com)\\n\\t\\t- [The New America](https://www.investors.com/category/research/the-new-america/)\\n\\t\\t- [IBD Data Stories](https://www.investors.com/ibd-data-stories/build-your-investing-watch-list-with-stock-ratings-buy-zones-earnings/)\\n\\t\\t- [Swing Trading](https://www.investors.com/category/research/swing-trading/)\\n\\t\\t- [Best ETFs](https://www.investors.com/etfs-and-funds/etfs/best-etfs-exchange-traded-funds/)\\n\\t\\t- [IBD Digital: 2 Months for $20](https://get.investors.com/ibd/?intcode=gnvb%7Cgnvb%7Cevgr%7C2021%7C08%7Cibdd%7Cna%7C%7C115458&src=AKCAGE)\\n\\t\\t- [Options](https://www.investors.com/category/research/options/)\\n\\t\\t- [Best Mutual Funds](https://www.investors.com/etfs-and-funds/mutual-funds/best-mutual-funds-news-performance-reports-investing-ideas/)\\n\\t+ [Premium Investing Tools](https://research.investors.com)\\n\\t\\t- [MarketSurge](https://marketsurge.investors.com/)\\n\\t\\t- [IBD Live](https://research.investors.com/ibdlive)\\n\\t\\t- [Leaderboard](https://leaderboard.investors.com/)\\n\\t\\t- [SwingTrader](https://swingtrader.investors.com)\\n\\t\\t- [MarketDiem](https://get.investors.com/marketdiem/?intcode=lgnv%7Clgnv%7Cprdmcst%7C2022%7C10%7Cmkdm%7Cna%7C%7C832881&src=A00653)\\n* [NEWS](https://www.investors.com/tag/all-news-and-stock-ideas/)\\n\\t+ [NEWS](https://www.investors.com/tag/all-news-and-stock-ideas/)\\n\\t\\t- [*e*IBD](https://research.investors.com/eIBD)\\n\\t\\t- [Cryptocurrency](https://www.investors.com/news/cryptocurrency-prices-news/)\\n\\t\\t- [Technology](https://www.investors.com/technology/)\\n\\t\\t- [Retirement](https://www.investors.com/category/etfs-and-funds/retirement/)\\n\\t\\t- [Magnificent Seven Stocks](https://www.investors.com/research/magnificent-seven-stocks-latest-news-market-cap-weighting/)\\n\\t\\t- [Management](https://www.investors.com/management/)\\n\\t\\t- [Personal Finance](https://www.investors.com/category/etfs-and-funds/personal-finance/)\\n\\t\\t- [Industry News Pages](https://www.investors.com/news/industry-news-and-stocks-to-watch/)\\n\\t\\t- [Special Reports](https://www.investors.com/special-reports/)\\n\\t+ [ECONOMY](https://www.investors.com/economic-news-president-job-approval/)\\n\\t\\t- [Economic Calendar](https://research.investors.com/economic-calendar/)\\n\\t\\t- [IBD Digital: 2 Months for $20](https://get.investors.com/ibd/?intcode=gnvb%7Cgnvb%7Cevgr%7C2021%7C08%7Cibdd%7Cna%7C%7C115458&src=AKCAGE)\\n\\t\\t- [Economic News](https://www.investors.com/category/news/economy/)\\n* [Videos](https://www.investors.com/ibd-videos/)\\n\\t+ [VIDEOS \\\\& PODCASTS](https://www.investors.com/ibd-videos/)\\n\\t\\t- [IBD Live](https://research.investors.com/ibdlive)\\n\\t\\t- [Investing With IBD Podcast](https://www.investors.com/podcast)\\n\\t\\t- [How To Invest Videos](https://www.investors.com/ibd-videos/category/how-to-invest-videos)\\n\\t\\t- [Growth Stories Podcast](https://get.investors.com/growth-stories-podcast/)\\n\\t\\t- [Options Videos](https://www.investors.com/ibd-videos/category/options-ibd-videos?archive=1)\\n\\t\\t- [Online Courses](https://get.investors.com/online-courses/?src=A00272A)\\n\\t\\t- [Webinars](https://www.investors.com/ibd-videos/category/webinars)\\n\\t\\t- [IBD Digital: 2 Months for $20](https://get.investors.com/ibd/?intcode=gnvb%7Cgnvb%7Cevgr%7C2021%7C08%7Cibdd%7Cna%7C%7C115458&src=AKCAGE)\\n* [Learn](https://www.investors.com/how-to-invest/how-to-invest-rules-for-when-buy-and-sell-stocks-in-bull-and-bear-markets/)\\n\\t+ [How To Invest](https://www.investors.com/how-to-invest/how-to-invest-rules-for-when-buy-and-sell-stocks-in-bull-and-bear-markets/)\\n\\t\\t- [How To Invest In Stocks](https://www.investors.com/how-to-invest/how-to-invest-in-stocks-investing-for-beginners/)\\n\\t\\t- [When To Sell Stocks](https://www.investors.com/how-to-invest/when-to-sell-stocks/)\\n\\t\\t- [3 Keys To Stock Investing](https://www.investors.com/how-to-invest/stock-investing-how-to-make-money-in-stock-3-key-factors/)\\n\\t\\t- [Short Selling](https://www.investors.com/category/research/the-short-side/)\\n\\t\\t- [Stock Market Timing](https://www.investors.com/how-to-invest/stock-market-timing-how-to-invest-in-stocks-tracking-bull-markets-bear-markets-stock-market-trends/)\\n\\t\\t- [Swing Trading](https://www.investors.com/research/swing-trading/swing-trading-strategies/)\\n\\t\\t- [Tracking Stock Market Trends](https://www.investors.com/how-to-invest/how-to-handle-changing-stock-market-trends/)\\n\\t\\t- [What Is Crypto](https://www.investors.com/how-to-invest/cryptocurrency-what-is-crypto/)\\n\\t\\t- [How To Read Stock Charts](https://www.investors.com/how-to-invest/how-to-read-stock-charts-understanding-technical-analysis/)\\n\\t\\t- [Premium Online Courses](https://get.investors.com/online-courses/?src=A00272A)\\n\\t\\t- [How To Buy Stocks](https://www.investors.com/how-to-invest/how-to-buy-stocks-using-stock-lists-stock-ratings-stock-screener/)\\n\\t+ Educational Resources\\n\\t\\t- [New To IBD](https://get.investors.com/getting-started/)\\n\\t\\t- [Online Investing Courses](https://get.investors.com/online-courses/?src=APA1BQ)\\n\\t\\t- [Investor\\'s Corner](https://www.investors.com/category/how-to-invest/investors-corner/)\\n\\t\\t- [12 Days Of Learning](https://get.investors.com/ibd/12-days-of-learning/)\\n\\t\\t- [Investing With IBD Podcast](https://www.investors.com/podcast)\\n\\t\\t- [Investing Infographics](https://get.investors.com/infographics/)\\n\\t\\t- [Events \\\\& Webinars](https://get.investors.com/events/)\\n\\t\\t- [Chart School](https://workshops.investors.com/)\\n\\t\\t- [**IBD Moneyworks**](https://get.investors.com/moneyworks/)\\n* [MarketSurge](https://marketsurge.investors.com/?intcode=lgnv%7Clgnv%7CMarketSmith%7C2023%7C06%7Cmsp%7Cna%7C%7C725068&src=A00653)\\n* [IBD Live](https://research.investors.com/ibdlive?id=IBD-Live&src=A00582A)\\n* [Leaderboard](https://leaderboard.investors.com)\\n* [SwingTrader](https://swingtrader.investors.com)\\n* [MarketDiem](https://get.investors.com/marketdiem/?intcode=lgnv%7Clgnv%7Cprdmcst%7C2022%7C10%7Cmkdm%7Cna%7C%7C832881&src=A00653)\\n* [Store](https://get.investors.com/?src=APA1BQ)\\n* Shopping CartYour cart is currently empty.\\n Visit the [IBD Store](https://shop.investors.com) to get started.\\n*\\n\\nHi\\n\\n[MY IBD](https://myibd.investors.com)\\n[SIGN OUT](https://myibd.investors.com/logout.aspx)\\n\\n+ [My Products](#)\\n+ [My Favorites](#)\\n+ [My Stock Lists](#)\\n\\n[Edit Favorites](https://myibd.investors.com/edit-favorites/)\\n\\n* [Sign In](https://myibd.investors.com/secure/signin.aspx?eurl=) or [Subscribe](https://get.investors.com/ibd/?intcode=hpsubbutton%7Chpsubbutton%7Cna%7Cna%7Cna%7Cna%7Cna%7C%7C144112&src=A00544)\\n\\n---\\n\\n* [Research](https://www.investors.com/category/research/)\\n\\n Nvidia Eyes All\\\\-Time High Amid Rebound, AI Demand; Is Nvidia A Buy Now?\\n========================================================================\\n\\n[![Facebook](/wp-content/themes/ibd/dist/images/share-icons/facebook.png)](https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.investors.com%2Fresearch%2Fnvda-stock-is-nvidia-a-buy-2%2F&linkname=Nvidia%20Eyes%20All-Time%20High%20Amid%20Rebound%2C%20AI%20Demand%3B%20Is%20Nvidia%20A%20Buy%20Now%3F \"Facebook\")[![X](/wp-content/themes/ibd/dist/images/share-icons/x.png)](https://www.addtoany.com/add_to/x?linkurl=https%3A%2F%2Fwww.investors.com%2Fresearch%2Fnvda-stock-is-nvidia-a-buy-2%2F&linkname=Nvidia%20Eyes%20All-Time%20High%20Amid%20Rebound%2C%20AI%20Demand%3B%20Is%20Nvidia%20A%20Buy%20Now%3F \"X\")[![LinkedIn](/wp-content/themes/ibd/dist/images/share-icons/linkedin.png)](https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.investors.com%2Fresearch%2Fnvda-stock-is-nvidia-a-buy-2%2F&linkname=Nvidia%20Eyes%20All-Time%20High%20Amid%20Rebound%2C%20AI%20Demand%3B%20Is%20Nvidia%20A%20Buy%20Now%3F \"LinkedIn\")[![Share](/wp-content/themes/ibd/dist/images/share-icons/email.png)](https://www.addtoany.com/share) [Licensing](https://www.ibdlicensing.com)\\n\\n* [VIDYA RAMAKRISHNAN](https://www.investors.com/author/ramakrishnanv/ \"Posts by VIDYA RAMAKRISHNAN\")\\n* 09:57 AM ET 09/27/2024\\n\\nWhen a stock pulls back, it is [best not to panic](https://www.investors.com/how-to-invest/how-to-invest-in-stocks-investing-for-beginners/). **Nvidia** ([NVDA](https://research.investors.com/quote.aspx?symbol=NVDA))\\xa0traded slightly lower early Friday after a strong rebound earlier this week. That is normal action. [Volume](https://www.investors.com/how-to-invest/investors-corner/stock-chart-analysis-study-volume-in-bases/) was lighter and suggested that the stock is just taking a breather after its recent run.\\n\\n↑\\nX\\n\\n[How Nvidia Is Injecting AI Into The Health Care Industry](https://www.investors.com/ibd-videos/videos/nvidia-injecting-ai-health-care-industry)\\n\\n[See All Videos](https://www.investors.com/ibd-videos)\\n\\nNOW PLAYING\\nHow Nvidia Is Injecting AI Into The Health Care Industry\\n\\nNvidia stock has cleared multiple [trendline](https://www.investors.com/how-to-invest/investors-corner/looking-for-an-earlier-entry-in-a-stock-learn-how-to-do-this/?refcode=BBB-04262022-2-B-9:04:2022:2Q:NewsLetter:Email:BBB-04262022:na:na:na:na:26:10:2:B:9&j=1566189&sfmc_sub=172274927&l=222_HTML&u=20328680&mid=100016628&jb=1) entries this week. In just over one week, the stock has gone from being 3% below to 6% above its [50\\\\-day moving average.](https://www.investors.com/how-to-invest/investors-corner/what-is-the-50-day-moving-average-when-to-buy-or-sell-growth-stocks/)\\n\\nShares are just 13% below their split\\\\-adjusted all\\\\-time high of 140\\\\.76 after a weekly gain of 7% as of Thursday\\'s closing price.\\n\\nNvidia stock has also rejoined the $3 trillion market cap club after memory chip maker **Micron** ([MU](https://research.investors.com/quote.aspx?symbol=MU)) reported results and cited robust AI demand. The news boosted the chip sector.\\n\\nBut should you be [buying Nvidia stock now](https://www.investors.com/ibd-university/how-to-buy/common-patterns-1/)?\\n\\n [Timing your stock purchases](https://www.investors.com/how-to-invest/investors-corner/stock-market-investing-ibd-methodology/) can surely improve gains. Yet even with an obvious market leader like Nvidia, it\\'s not easy to tell whether you should [buy or sell the stock now](https://www.investors.com/how-to-invest/how-to-buy-stocks-using-stock-lists-stock-ratings-stock-screener/). [Chart signals](https://www.investors.com/how-to-invest/how-to-read-stock-charts-understanding-technical-analysis/) and checking [several technical measures](https://www.investors.com/how-to-invest/how-to-buy-stocks-using-stock-lists-stock-ratings-stock-screener/) can help investors assess [whether Nvidia stock is a buy now](https://www.investors.com/how-to-invest/how-to-buy-stocks-using-stock-lists-stock-ratings-stock-screener/).\\n\\nAI\\'s Total Addressable Market\\n-----------------------------\\n\\nOn Wednesday, shares rose after consulting firm Bain said the total addressable market for artificial intelligence hardware and software will grow 40% to 55% for [at least next three years](https://www.marketwatch.com/articles/nvidia-stock-price-ai-chip-demand-95760797?mod=search_headline). Demand for Nvidia\\'s next generation graphic processing units GB200 is expected to reach 3 million in 2026 vs. 1\\\\.5 million for its H100 units in 2023\\\\.\\n\\nShares are recovering from last week\\'s minor fall. According to [Barron\\'s](https://www.barrons.com/articles/nvidia-stock-price-top-performers-d0484c61?siteid=yhoof2), Nvidia last week lost its place as the best performing S\\\\&P 500 stock so far this year. **Vistra** ([VST](https://research.investors.com/quote.aspx?symbol=VST)) had gained 190% year to date as of Monday\\'s closing price, whereas Nvidia was up 135%. Also on Tuesday, analysts at Melius Research gave the stock a price target of 165 with a buy rating as the company ramps up its Blackwell chip production in the fourth quarter.\\n\\nNvidia stock rose Monday after news that China e\\\\-commerce behemoth **Alibaba** ([BABA](https://research.investors.com/quote.aspx?symbol=BABA)) will collaborate with Nvidia to improve autonomous driving technology for Chinese EV manufacturers, several of which are rivals to **Tesla** ([TSLA](https://research.investors.com/quote.aspx?symbol=TSLA)). Alibaba\\'s portfolio of large\\\\-language models are now integrated with Nvidia\\'s drive platform for autonomous vehicles.\\n\\nWhite House Meeting\\n-------------------\\n\\nEarlier this month, shares climbed above the 50\\\\-day moving average amid news that Nvidia and OpenAI chief executive officers, Jensen Huang and Sam Altman, met officials at the White House to discuss AI infrastructure spending. According to [reports](https://www.yahoo.com/news/openai-nvidia-executives-discuss-ai-232621359.html?fr=yhssrp_catchall), **Alphabet** ([GOOGL](https://research.investors.com/quote.aspx?symbol=GOOGL)), **Amazon.com** ([AMZN](https://research.investors.com/quote.aspx?symbol=AMZN)) and **Microsoft** ([MSFT](https://research.investors.com/quote.aspx?symbol=MSFT)) executives were also present. The White House announced an interagency task force to accelerate permissions for setting up data centers.\\n\\nHowever, news that companies may be diversifying and looking for other chips besides Nvidia\\'s likely weighed on Nvidia stock. According to [Barron\\'s](https://www.barrons.com/articles/nvidia-stock-price-buy-sell-d10180d0?siteid=yhoof2), Saudi oil behemoth Aramco is planning on using chips made by a startup Groq to offer \"AI computing power to local companies.\"\\n\\nThe news followed [Huang remarks](https://www.marketwatch.com/story/nvidia-ceo-jensen-huang-addresses-the-big-question-on-investors-minds-3699b564?&mod=article_inline) that the return on investment for artificial intelligence infrastructure plays like Nvidia remained strong since \"infrastructure players like ourselves and all the cloud service providers put the infrastructure in the cloud, so that developers could use these machines to train the models, fine\\\\-tune the models, guardrail the models, and so forth.\"\\n\\nAnalysts at Bernstein said that after its phenomenal growth, sustainability is the main question Nvidia faces, but the \"[time to worry is clearly not now](https://www.marketwatch.com/story/nvidias-stock-set-to-extend-gains-the-time-to-worry-is-clearly-not-now-9425d38d).\"\\n\\nOn Sept. 3, Nvidia fell sharply below the [50\\\\-day moving average](https://www.investors.com/how-to-invest/investors-corner/what-is-the-50-day-moving-average-when-to-buy-or-sell-growth-stocks/) and saw its largest one\\\\-day market cap loss for any U.S. company, according to Dow Jones Markets Data.\\n\\nEarnings From AI Giants\\n-----------------------\\n\\nResults from other AI leaders have influenced the stock. **Oracle** ([ORCL](https://research.investors.com/quote.aspx?symbol=ORCL)) results showed strong demand for AI chips. According to the Chairman and Chief Technology Officer Larry Ellison, Oracle is building a data center with \"[acres of Nvidia GPU clusters for training large language scale AI models](https://www.investors.com/news/technology/oracle-stock-orcl-q1-report-cloudworld-ai-cloud/).\"\\n\\nEarlier, results from**Broadcom** ([AVGO](https://research.investors.com/quote.aspx?symbol=AVGO)) weighed on Nvidia stock. Broadcom\\'s [sales and earnings beat estimates](https://www.investors.com/news/technology/avgo-stock-broadcom-earnings-fiscal-q3-2024/) but its sales outlook disappointed. Broadcom\\'s outlook has implications for demand for AI chips.\\n\\n\\xa0Shares also came under pressure amid news that the Department of Justice was investigating antitrust regulations concerning the artificial intelligence chip company.\\xa0According to reports, [the DOJ originally sent questionnaires to the company](https://www.reuters.com/legal/nvidia-hit-with-subpoena-us-justice-department-bloomberg-news-reports-2024-09-03/). But it has now sent subpoenas.\\n\\nShares fell 6\\\\.4% after earnings on Aug. 28 even though Nvidia beat analyst estimates.\\n\\nNvidia\\'s Second\\\\-Quarter Results\\n--------------------------------\\n\\nIn August, Nvidia reported earnings that beat Wall Street views. Sales of $30\\\\.04 billion were higher than $28\\\\.7 billion analysts expected and came in 122% ahead of the year\\\\-earlier quarter. Earnings also came in above views of 65 cents at 68 cents per share and were 152% higher than the prior year. The artificial intelligence chip leader also guided higher for the current quarter with [sales of $32\\\\.5 billion vs. views of $31\\\\.7 billion](https://www.investors.com/news/technology/nvidia-stock-fiscal-q2-2025-earnings-nvda-stock/).\\n\\nEarnings have moved Nvidia stock in 2023 and 2024 and that is shining proof of why [fundamental performance](https://www.investors.com/how-to-invest/investors-corner/stock-market-investing-ibd-methodology/) is one of the pillars of the Investor\\'s Business Daily methodology. In 2023, Nvidia had a huge 239% run.\\n\\nAfter losing 5\\\\.3% in July, the stock gained 2% in August. It is trading 4% higher so far this month and is up\\xa0 150% so far this year.\\n\\nFundamentals make up just one of four IBD pillars of investing — the others are a stock\\'s technical strength, which indicates the stock\\'s performance vs. other stocks, the [market direction](https://www.investors.com/news/stock-market-today-stock-market-news/)', 1, 2)

[7] Observation: ToolResult

tool_call_id: call_tSXwVXXt8mKkQyz647tX9FD9\n",
+       "kind: tool\n",
        "\n",
-       "
1892 characters ...In late 2022, several factors influenced Nvidia's stock price:\n", + "
12762 characters ...('Title: Nvidia\\'s stock chart shows how bulls are using the recent pause to get refreshed | Morningstar\\n=======================\\nMorningstar brands and products\\n\\n Company\\n\\n [![Morningstar](/assets/img/morningstar.d826858.svg)](/)\\n\\n * [Portfolio](/tools/portfolio)\\n* Tools\\n * Sections\\n* Markets\\n* [Funds](/funds)\\n* [ETFs](/topics/etfs)\\n* [Stocks](/stocks)\\n* [Bonds](/bonds)\\n * Investing Ideas\\n\\n * [Home](/)\\n * Tools\\n\\t+ [Portfolio](/tools/portfolio)\\n\\t+ [Watchlists](/tools/watchlists)\\n\\t+ [Screener](/tools/screener)\\n\\t+ [Chart](/tools/chart)\\n\\t+ [Rating Changes](/tools/rating-changes)\\n * Sections\\n* Markets\\n* [Funds](/funds)\\n* [ETFs](/topics/etfs)\\n* [Stocks](/stocks)\\n* [Bonds](/bonds)\\n * Investing Ideas\\n * [Help](/help-center)\\n* [What’s New](/whats-new)\\n * Products for Investors\\n* [All Products and Services](/business)\\n [MarketWatch](/news/marketwatch) Nvidia\\'s stock chart shows how bulls are using the recent pause to get refreshed\\n================================================================================\\n\\n ![](/assets/img/marketwatch.dad5abb.png)\\n Provided by\\n Dow Jones Sep 27, 2024 5:52pm\\n By Tomi Kilgore\\n\\n Stock is building a multi\\\\-month \\'pennant\\' chart pattern, which often lead to continuations of previous trend\\n\\n Nvidia Corp.\\'s stock has been in a holding pattern the past few months, leading some on Wall Street to wonder if the nearly two\\\\-year\\\\-long torrid rally, fueled by the artificial intelligence boom, has ended.\\n\\n But bulls don\\'t need to worry just yet, and may even have reason to feel cheerful. Because that holding pattern is looking a lot like a \"pennant,\" which many Wall Street chart watchers see as a sign suggesting the previous uptrend will eventually reassert itself.\\n\\n Nvidia\\'s stock (NVDA) fell 3% in afternoon trading, to pull back from a three\\\\-month\\\\-long descending trendline. It was essentially trading where it was in early June.\\n\\n The semiconductor maker and AI play\\'s stock has lost 11\\\\.2% since it closed at a record $135\\\\.58 on June 18, at which time it had posted a year\\\\-to\\\\-date gain of 173\\\\.8%. But the stock has also rallied 21\\\\.7% since it closed at a 21/2 \\\\-month low of $98\\\\.91 on Aug. 7, and has been following an ascending trendline for the past several months.\\n\\n The chart below, is what a pennant continuation pattern looks like:\\n\\n Like BTIG technical analyst Jonathan Krinsky said, while the stock\\'s gains this week was \"rejected\" at the downtrend line, the recent trading pattern looks like \"the pause that refreshes.\"\\n\\n So while there could still be some volatility in the stock, while the trending resistance and support lines continue to converge, pennants tend to be resolved in the direction of the previous trend, which was up.\\n\\n The support line currently extends to about $104\\\\.75, while the resistance line would extend to about $125\\\\.80 on Monday.\\n\\n Don\\'t miss: Nvidia investors don\\'t need to worry \\\\- unless the stock falls below these prices.\\n\\n Also read: Nvidia investors just got a $1 trillion reason to be even more bullish.\\n\\n What happens after the uptrend resumes is up for some debate, as there are different ways to calculate a \"measured move\" continuation.\\n\\n Some will take the widest part of the pennant, then add it to the breakout point to get an upside target. For Nvidia, that would mean the $46\\\\.83 rally from the May 9 closing low to the record high would be added to the point where the stock crosses above the top of the pennant.\\n\\n If the breakout occurs on Monday, then the measured move target would be around $172\\\\.63, or about 43% above current levels.\\n\\n Others see the pennant as sitting in the middle of a rally, so they will take the length of the \"flagpole,\" or the entire rally, and add that to the breakout point.\\n\\n For Nvidia, the current flagpole is about $88 tall. So a breakout on Monday would target about $213\\\\.80, or 77% above current levels.\\n\\n Of course, a break of the support line could lead to a full retracement, which is about 60% below current levels.\\n\\n A check of history shows that the late 2018 downtrend that followed a three\\\\-year rally took the stock down 56%, and the late\\\\-2021 to late\\\\-2022 downtrend that also followed a three\\\\-year rally saw the stock lose 66%.\\n\\n The current rally has only lasted two years.\\n\\n \\\\-Tomi Kilgore\\n\\n This content was created by MarketWatch, which is operated by Dow Jones \\\\& Co. MarketWatch is published independently from Dow Jones Newswires and The Wall Street Journal.\\n\\n```\\n\\n```\\n\\n (END) Dow Jones Newswires\\n\\n 09\\\\-27\\\\-24 1352ET\\n\\nCopyright (c) 2024 Dow Jones \\\\& Company, Inc. Market Updates\\n--------------\\n\\n [More Market Updates](/markets) * [What’s the Difference Between the CPI and PCE Indexes?\\n------------------------------------------------------\\n\\n Sarah Hansen Apr 23, 2024](/markets/whats-difference-between-cpi-pce)\\n* [Micron Earnings: Great Guidance but Stock Now Looks Fairly Valued\\n-----------------------------------------------------------------\\n\\n William Kerwin, CFA Sep 26, 2024](/markets/micron-earnings-great-guidance-stock-now-looks-fairly-valued)\\n* [August PCE Report Forecasts Show More Good News on Inflation\\n------------------------------------------------------------\\n\\n Frank Lee Sep 25, 2024](/markets/august-pce-report-forecasts-show-more-good-news-inflation)\\n* [AI Stocks May Be Down, but Don’t Count Them Out\\n-----------------------------------------------\\n\\n Bella Albrecht Sep 23, 2024](/markets/ai-stocks-may-be-down-dont-count-them-out)\\n* [4 Stocks to Buy as the Fed Cuts Interest Rates\\n----------------------------------------------\\n\\n David Sekera, CFA Sep 23, 2024](/markets/4-stocks-buy-fed-cuts-interest-rates)\\n* [Markets Brief: The Uncertain Path to Neutral Interest Rates\\n-----------------------------------------------------------\\n\\n Dan Kemp Sep 18, 2024](/markets/markets-brief-uncertain-path-neutral-rates)\\n* [What’s Happening in the Markets This Week\\n-----------------------------------------\\n\\n Frank Lee Jul 20, 2023](/markets/weekly-markets-planner-economics-calendar-corporate-stock-earnings-more)\\n* [Where Top Stock Fund Managers Are Looking Next After the Fed Rate Cut\\n---------------------------------------------------------------------\\n\\n Gabe Alpert Sep 20, 2024](/markets/where-top-stock-fund-managers-are-looking-next-after-fed-rate-cut)\\n Stock Picks\\n-----------\\n\\n [More Stock Picks](/stocks) * [Our Top Pick for Investing in US Renewable Energy\\n-------------------------------------------------\\n\\n Brett Castelli Mar 25, 2024](/stocks/investment-opportunities-us-renewable-energy)\\n* [How to Measure a Stock’s Uncertainty\\n------------------------------------\\n\\n Emelia Fredlick Sep 26, 2024](/stocks/how-measure-stocks-uncertainty)\\n* [How to Determine Whether a Stock Is Cheap, Expensive, or Fairly Valued\\n----------------------------------------------------------------------\\n\\n Emelia Fredlick Sep 25, 2024](/stocks/how-determine-whether-stock-is-cheap-expensive-or-fairly-valued)\\n* [Why a Company’s Management and Capital Allocation Matter\\n--------------------------------------------------------\\n\\n Emelia Fredlick Sep 25, 2024](/stocks/why-companys-management-capital-allocation-matter)\\n* [How to Determine What a Stock Is Worth\\n--------------------------------------\\n\\n Susan Dziubinski Sep 25, 2024](/stocks/how-determine-what-stock-is-worth)\\n* [How to Measure a Company’s Competitive Advantage\\n------------------------------------------------\\n\\n Emelia Fredlick Sep 24, 2024](/stocks/how-measure-companys-competitive-advantage)\\n* [How to Think Like a Stock Analyst\\n---------------------------------\\n\\n Emelia Fredlick Sep 24, 2024](/stocks/how-think-like-stock-analyst)\\n* [How GLP\\\\-1 Drugs Like Ozempic Are Boosting Biopharma Stocks\\n-----------------------------------------------------------\\n\\n Karen Andersen, CFA Sep 24, 2024](/stocks/how-glp-1-drugs-like-ozempic-are-boosting-biopharma-stocks-2)\\n Sponsor Center\\n--------------\\n\\n ![](https://images.contentstack.io/v3/assets/blt4eb669caa7dc65b2/blt39ce1d6a5e7be3d0/60809fdf6371c75a11ada75c/transparency.svg)\\n Transparency is our policy. Learn how it impacts everything we do\\n\\n Read More\\n\\n Transparency is how we protect the integrity of our work and keep\\n empowering investors to achieve their goals and dreams. And we have\\n unwavering standards for how we keep that integrity intact, from our\\n research and data to our policies on content and your personal data.\\n\\n We’d like to share more about how we work and what drives our day\\\\-to\\\\-day business.\\n\\n ![](https://images.contentstack.io/v3/assets/blt4eb669caa7dc65b2/blt3bce7cffbeb60a42/60809fdf26fd84453c018424/make-money.svg) ### How we make money\\n\\n We sell different types of products and services to both investment professionals\\n and individual investors. These products and services are usually sold through\\n license agreements or subscriptions. Our investment management business generates\\n asset\\\\-based fees, which are calculated as a percentage of assets under management.\\n We also sell both admissions and sponsorship packages for our investment conferences\\n and advertising on our websites and newsletters.\\n\\n ![](https://images.contentstack.io/v3/assets/blt4eb669caa7dc65b2/blt218bb7805fb32c9a/60809fdfb35a7a3c69a379ff/personal-data.svg) ### How we use your personal data\\n\\n How we use your information depends on the product and service that you use and your relationship with us. We may use it to:\\n\\n * Verify your identity, personalize the content you receive, or create and administer your account.\\n* Provide specific products and services to you, such as portfolio management or data aggregation.\\n* Develop and improve features of our offerings.\\n* Gear advertisements and other marketing efforts towards your interests.\\n\\n To learn more about how we handle and protect your data, visit our [privacy center](/company/privacy-center).\\n\\n ![](https://images.contentstack.io/v3/assets/blt4eb669caa7dc65b2/blta8bf8e458b569f88/60809fdf03ce953dac756a01/editorial-content.svg) ### How we approach editorial content\\n\\n Maintaining independence and editorial freedom is essential to our mission of\\n empowering investor success. We provide a platform for our authors to report on\\n investments fairly, accurately, and from the investor’s point of view. We also\\n respect individual opinions––they represent the unvarnished thinking of our people\\n and exacting analysis of our research processes. Our authors can publish views that\\n we may or may not agree with, but they show their work, distinguish facts from\\n opinions, and make sure their analysis is clear and in no way misleading or deceptive.\\n\\n To further protect the integrity of our editorial content, we keep a strict separation\\n between our sales teams and authors to remove any pressure or influence on our analyses\\n and research.\\n\\n Read our [editorial policy](/editorial-policy) to learn more about our process.\\n\\n Site Index [![Morningstar](/assets/img/morningstar-70px.0ea2b33.svg)](/) ##### What We Do\\n\\n* [All Products \\\\& Services](/products)\\n* [Our Signature Methodologies](/research/signature)\\n* [Morningstar Investment Conference](/events/mic)\\n ##### Company\\n\\n* [About Us](/company/about-us)\\n* [Careers](/careers)\\n* [Diversity, Equity, \\\\& Inclusion](/company/diversity)\\n* [Corporate Sustainability](/company/corporate-sustainability)\\n* [Newsroom](https://newsroom.morningstar.com)\\n* [Investor Relations](https://shareholders.morningstar.com)\\n ##### Get Help\\n\\n* [Advertising Opportunities](/company/media-kit)\\n* [Feedback](#)\\n* [Reprints](mailto:reprints@morningstar.com)\\n* [Global Contacts](/company/global-contacts)\\n* [Affiliate Program](/products/investor-affiliate-program)\\n\\n---\\n\\n [![United States Flag](/assets/img/us_flag_20x20.34273bf.svg)\\n United States](/company/location)\\n © Copyright 2024 Morningstar, Inc. All rights reserved.\\n Dow Jones Industrial Average, S\\\\&P 500, Nasdaq, and Morningstar Index (Market Barometer) quotes are real\\\\-time.\\n\\n * [Terms and Conditions](https://www.morningstar.com/company/terms-and-conditions)\\n* [Privacy Center](https://www.morningstar.com/company/privacy-center)\\n* [Disclosures](https://www.morningstar.com/company/disclosures)\\n* [Member User Agreement](/user-agreement)\\n* [Corrections](https://www.morningstar.com/corrections)\\n* [Do Not Sell or Share My Personal Information](https://www.morningstar.com/company/privacy-policy/california#resident-rights)\\n* [Accessibility](https://www.morningstar.com/company/accessibility)', 1, 1)

[8] Observation: ToolResult

tool_call_id: call_IQs92nhMwXLwUhq9SFNTS285\n",
+       "kind: tool\n",
        "\n",
-       "1. **Market Volatility**: Nvidia's shares experienced significant drawdowns, falling by 66% at one point in 2022. This was part of a broader trend where the stock had multiple drawdowns of approximately 15% or more throughout the year.\n",
+       "
13483 characters ...('Title: Nvidia Stock Price at 52-Week Low After US Restricts Sales to China - GlobalData\\n=======================\\n[![vertical_menu_area_bottom_logo](https://assets.globaldata.com/gdcom/assets/img/logo/gd_blue-3-1-1.webp)](/)\\n\\n* [Visit Corporate Site](/)\\n\\n[Sign in](https://login.globaldata.com/login/index/gdcom?returnUrl=/data-insights/technology--media-and-telecom/nvidia-stock-price-at-52-week-low-after-us-restricts-sales-to-china/)\\n\\nSearch\\n\\nMenu\\n\\n* [Sign In](https://login.globaldata.com/login/index/gdcom?returnUrl=/data-insights/technology--media-and-telecom/nvidia-stock-price-at-52-week-low-after-us-restricts-sales-to-china/)\\n* [Home](/data/)\\n\\n* [Data \\\\& Insights](/data-insights/)\\n\\t+ Data \\\\& Insights\\n\\t----------------\\n\\n\\t[View all Data \\\\& Insights](/data-insights/listing/search/)\\n\\t[Advanced Search](/data-insights/listing/search?IsExpandRefine=1)\\n\\n\\t### Insight by Sector\\n\\n\\t\\t- [Aerospace \\\\& Defense](/data-insights/aerospace-and-defence/)\\n\\t\\t- [Automotive](/data-insights/automotive/)\\n\\t\\t- [Agriculture \\\\& Forestry](/data-insights/agriculture-forestry/)\\n\\t\\t- [Business \\\\& Consumer Services](/data-insights/business-and-consumer-services/)\\n\\t\\t- [Construction](/data-insights/construction/)\\n\\t\\t- [Chemicals](/data-insights/chemicals/)\\n\\t\\t- [Consumer](/data-insights/consumer/)\\n\\t\\t- [Foodservice](/data-insights/foodservice/)\\n\\t\\t- [Financial Services](/data-insights/financial-services/)\\n\\t\\t- [Government \\\\& Non\\\\-profit Organisations](/data-insights/government-and-non-profit-organisations/)\\n\\t\\t- [Healthcare](/data-insights/healthcare/)\\n\\t\\t- [Industrial Goods \\\\& Machinery](/data-insights/industrial-goods-machinery/)\\n\\t\\t- [Mining](/data-insights/mining/)\\n\\t\\t- [Packaging](/data-insights/packaging/)\\n\\t\\t- [Oil \\\\& Gas](/data-insights/oil-gas/)\\n\\t\\t- [Power \\\\& Utilities](/data-insights/power-utilities/)\\n\\t\\t- [Retail \\\\& Wholesale](/data-insights/retail-wholesale/)\\n\\t\\t- [Real Estate](/data-insights/real-estate/)\\n\\t\\t- [Sports](/data-insights/sport/)\\n\\t\\t- [Transportation, Infrastructure \\\\& Logistics](/data-insights/transportation-infrastructure-and-logistics/)\\n\\t\\t- [Technology, Media \\\\& Telecom](/data-insights/technology-media-and-telecom/)\\n\\t\\t- [Travel \\\\& Tourism](/data-insights/travel-and-tourism/)\\n\\n\\t### Insight Type\\n\\n\\t\\t- [Company Performance](/data-insights/companyperformance/)\\n\\t\\t- [Macro economic](/data-insights/macroeconomic/)\\n\\t\\t- [Other Industry Indicators](/data-insights/other/)\\n\\t\\t- [Market Sizing \\\\& Shares](/data-insights/marketsizingshares/)\\n\\t\\t- [Product Indicators](/data-insights/productindicators/)\\n\\t\\t- [Thematic Indicators](/data-insights/thematicindicators/)\\n\\t\\t- [ESG](/data-insights/esg/)\\n* [Themes](/themes/)\\n\\t+ Themes\\n\\t------\\n\\n\\t[View all Themes](/themes/)\\n\\n\\t### Key Themes\\n\\n\\t\\t- [Artificial Intelligence](/themes/artificial-intelligence/)\\n\\t\\t- [Cloud](/themes/cloud/)\\n\\t\\t- [COVID\\\\-19](/themes/covid-19/)\\n\\t\\t- [Cybersecurity](/themes/cybersecurity/)\\n\\t\\t- [ESG \\\\- Environment](/esg/environment/overview)\\n\\n\\t\\t- [ESG \\\\- Governance](/esg/governance/overview)\\n\\t\\t- [ESG \\\\- Social](/esg/social/overview)\\n\\t\\t- [Internet of Things](/themes/internet-of-things/)\\n\\t\\t- [Robotics](/themes/robotics/)\\n\\n\\t What will the world look like in 2030?\\n\\t Anticipate the challenges and opportunities disrupting your industry.\\n\\n\\t[View Report](https://www.globaldata.com/store/report/tech-in-2030-theme-analysis/?utm_source=Advertisement&utm_medium=Display&utm_campaign=GD_RS_Advertisement_Tech_in_2030_Report_GDwebsite)\\n* [ESG](/esg/overview)\\n\\t+ ### ESG Factors\\n\\n\\t[ESG Overview](/esg/overview)\\n\\t[Environment](/esg/environment/overview)\\n\\t[Social](/esg/social/overview)\\n\\t[Governance](/esg/governance/overview)\\n\\n\\t##### ESG Trending Topics\\n\\n\\t\\t- [Electric Vehicles](/esg/impactinvestingstrategies/electric-vehicles)\\n\\t\\t- [Solar](/esg/impactinvestingstrategies/solar)\\n\\t\\t- [Food and Agritech](/esg/impactinvestingstrategies/food-and-agri-tech)\\n\\t\\t- [Hydrogen](/esg/impactinvestingstrategies/hydrogen)\\n\\t\\t- [Circular Plastic Economy](/esg/impactinvestingstrategies/circular-plastic-economy)\\n\\t\\t- [Edtech](/esg/impactinvestingstrategies/edtech)\\n\\t\\t- [Sustainable Healthcare](/esg/impactinvestingstrategies/sustainable-healthcare)\\n\\t\\t- [Microfinance](/esg/impactinvestingstrategies/microfinance)\\n\\t\\t- [Cybersecurity](/esg/impactinvestingstrategies/cybersecurity)\\n\\t\\t- [Risk Management](/esg/impactinvestingstrategies/risk-management)\\n\\n\\t##### Other Resources\\n\\n\\t\\t- [Signals](/esg/environment/socialmedia/signals)\\n\\t\\t- [Company Key Lists](/esg/companies)\\n\\t\\t- [Regulations](/esg/regulations)\\n\\t\\t- [Surveys and Polls](/esg/surveysandpolls)\\n\\n* Search\\n* [Media](https://www.globaldata.com/media/)\\n* [Investors](https://investors.globaldata.com/)\\n* [Careers](https://www.globaldata.com/careers/)\\n* [Contact Us](https://www.globaldata.com/contact-us/)\\n* [Request a Demo](https://www.globaldata.com/request-a-demo/)\\n\\nSearch our premium data\\n-----------------------\\n\\n×\\n\\n4 views left\\n[Get unlimited views with a free account](/account/register/)\\n\\nSubscribe to GlobalData Explorer\\n\\n Get a 360 degree view on a company powered by live data from the GlobalData Intelligence Center.\\n\\n[Explore Company Solutions](https://www.globaldata.com/companies/)\\n\\n* [Home](/data/)\\n* [Data \\\\& Insights](/data-insights/listing/search/)\\n* Current: Other Industry Indicators\\n\\nNvidia Stock Price at 52\\\\-Week Low After US Restricts Sales to China\\n====================================================================\\n\\nShare\\n\\n* Share on Twitter\\n* Share on LinkedIn\\n\\n* Industry: Software\\n* Current: Other Industry Indicators\\n\\n* *The share price of Nvidia hit a 52\\\\-week low after the US restricted sales to China*\\n* *In 2022, China accounted for over 27% of the total sales*\\n* *Companies would be required to obtain a license from the US government before selling certain cutting\\\\-edge chips to China and Russia*\\n\\nThe stock price of [Nvidia](https://www.globaldata.com/company-profile/nvidia-corp/), one of the largest chipmakers in the US, fell to a 52\\\\-week low after the US imposed new restrictions on the export of the company’s artificial intelligence (AI) chips to China and Russia. [Advanced Micro Devices Inc.](https://www.globaldata.com/company-profile/advanced-micro-devices-inc/), another major chipmaker in the US, was also notified of the new licensing requirement, preventing it from exporting an advanced chip aimed at the AI and high\\\\-performance computing markets. However, AMD said that it does not expect a major impact on its business.\\n\\n**About the Restrictions**\\n\\nThe companies would be required to obtain a license from the US government before selling certain cutting\\\\-edge chips to China and Russia. The restrictions cover Nvidia’s A100 and the coming H100 integrated chips, which are expected to speed up machine learning tasks and any systems that include them. The new restrictions will address the potential risk that the technology/product could be used in, or diverted to, military end use or military end user in China and Russia.\\n\\n**Impact on Chipmakers**\\n\\nThe new restrictions could affect the earnings of the US chip manufacturers such as Nvidia and AMD as both companies have a large exposure to China and this move could result in a major impact in the future, especially if China chooses to retaliate. According to Nvidia, the company could lose as much as $400 million in quarterly sales after the US imposed new licensing requirements on shipments of some of its most advanced chips to China. The new licensing requirements come at a challenging time for chipmakers when demand for personal computers, video games, and smartphones, along with other electronic gadgets, decreased as a result of [high inflation and a bleak economic outlook](https://www.globaldata.com/data-insights/macroeconomic/recession-looms-large-over-the-us-amid-high-inflation/) that continues to affect the consumers’ capacity to spend.\\n\\n**Increasing Tensions Between the US and China**\\n\\nThis is not the first time the US cut the supply of semiconductors to companies in China. In 2020, the US restricted manufacturers from selling chips made using US technology to tech giant Huawei without a special license. Export restrictions by the US hindered the growth of major Chinese chip manufacturers, including Semiconductor Manufacturing International Corp, the largest chipmaker in the country. Without American processors from companies such as Nvidia and AMD, it could be challenging for Chinese companies to efficiently do the complex computation necessary for image and voice recognition, among other jobs.\\n\\n Get a 360 degree view on a company powered by live data from the GlobalData Intelligence Center.\\n\\n Get a 360 degree view on a company powered by live data from the GlobalData Intelligence Center.\\n\\n[Explore Company Solutions](https://www.globaldata.com/companies/)\\n\\n### Related Data \\\\& Insights\\n\\n[Workday: Gross Value of Intangible Assets (FY2018 – FY2022, $ Million)](/data-insights/technology-media-and-telecom/workday-gross-value-of-intangible-assets/)\\n\\n[United States of America](/data-insights/listing/search?location=100244)\\n\\n[New Relic: Gross Value of Intangible Assets (FY2018 – FY2022, $ Million)](/data-insights/technology-media-and-telecom/new-relic-gross-value-of-intangible-assets/)\\n\\n[United States of America](/data-insights/listing/search?location=100244)\\n\\n[Splunk Inc: Gross Value of Intangible Assets (FY2018 – FY2022, $ Million)](/data-insights/technology-media-and-telecom/splunk-inc-gross-value-of-intangible-assets/)\\n\\n[United States of America](/data-insights/listing/search?location=100244)\\n\\n[Paylocity Holding Corp: Gross Value of Intangible Assets (FY2018 – FY2022, $ Million)](/data-insights/technology-media-and-telecom/paylocity-holding-corp-gross-value-of-intangible-assets/)\\n\\n[United States of America](/data-insights/listing/search?location=100244)\\n\\n[ACI Worldwide: Gross Value of Intangible Assets (FY2017 – FY2021, $ Million)](/data-insights/technology-media-and-telecom/aci-worldwide-gross-value-of-intangible-assets/)\\n\\n[United States of America](/data-insights/listing/search?location=100244)\\n\\n[NVIDIA: Workforce Diversity and Inclusion in 2022](/data-insights/technology-media-and-telecom/nvidia-workforce-diversity-and-inclusion-2091182/)\\n\\n[United States of America](/data-insights/listing/search?location=100244)\\n\\n### Related Companies\\n\\n [Apple Inc](/company-profile/apple-inc/)\\n\\nUnited States of America\\n\\n[![Apple Inc](/Uploads/Company/1439305/logo.jpg)](/company-profile/apple-inc/)\\n\\n [Google LLC](/company-profile/google-llc/)\\n\\nUnited States of America\\n\\n[![Google LLC](/Uploads/Company/2633703/Google.jpg)](/company-profile/google-llc/)\\n\\n [Meta Platforms Inc](/company-profile/facebook-inc/)\\n\\nUnited States of America\\n\\n[![Meta Platforms Inc](/Uploads/Company/1536668/logo.PNG)](/company-profile/facebook-inc/)\\n\\n [Verizon Communications Inc](/company-profile/verizon-communications-inc/)\\n\\nUnited States of America\\n\\n[![Verizon Communications Inc](/Uploads/Company/1533980/logo.png)](/company-profile/verizon-communications-inc/)\\n\\n [AT\\\\&T Inc](/company-profile/att-inc/)\\n\\nUnited States of America\\n\\n[![AT&T Inc](/Uploads/Company/1105645/logo.jpg)](/company-profile/att-inc/)\\n\\n [Huawei Investment \\\\& Holding Co Ltd](/company-profile/huawei-investment-holding-co-ltd/)\\n\\nChina\\n\\n[![Huawei Investment & Holding Co Ltd](/Uploads/Company/1022609/1022609.jpeg)](/company-profile/huawei-investment-holding-co-ltd/)\\n\\n [Amazon Web Services Inc](/company-profile/amazon-web-services-inc/)\\n\\nUnited States of America\\n\\n[![Amazon Web Services Inc](/Uploads/Company/2580644/2580644.JPG)](/company-profile/amazon-web-services-inc/)\\n\\n [Sony Group Corp](/company-profile/sony-corp/)\\n\\nJapan\\n\\n[![Sony Group Corp](/Uploads/Company/1677320/Sony.PNG)](/company-profile/sony-corp/)\\n\\n [Tencent Holdings Ltd](/company-profile/tencent-holdings-ltd/)\\n\\nChina\\n\\n[![Tencent Holdings Ltd](/Uploads/Company/1684916/Tencent.PNG)](/company-profile/tencent-holdings-ltd/)\\n\\n [Hitachi Ltd](/company-profile/hitachi-ltd/)\\n\\nJapan\\n\\n[![Hitachi Ltd](/Uploads/Company/1507484/logo.jpg)](/company-profile/hitachi-ltd/)\\n\\nStill looking?\\n\\nDon’t wait \\\\- discover a universe of connected data \\\\& insights with your next search. Browse over 28M data points across 22 industries.\\n\\n[Click here](/data-insights/listing/search/)\\nContinue on page\\n\\n×\\n\\nExplorer\\n\\nAccess more premium companies when you subscribe to Explorer\\n\\n[Find out more](/industries-we-cover/globaldata-explorer/)\\n[Close](javascript:void(0))\\n\\n×\\n\\n![vertical_menu_area_bottom_logo](https://assets.globaldata.com/gdcom/assets/img/logo/gd_blue-3-1-1.webp)\\n\\n---\\n\\n* [Hot Topics](https://hot-topics.globaldata.com/)\\n* [Terms \\\\& Conditions](https://www.globaldata.com/terms-conditions/)\\n* [Privacy Policy](https://www.globaldata.com/privacy-policy/)\\n* [Contact Us](https://www.globaldata.com/contact-us/)\\n* [Sitemap](https://www.globaldata.com/sitemap/)\\n* [Modern Slavery Statement](https://www.globaldata.com/wp-content/uploads/2021/03/FY2122-Modern-Slavery-FINAL.pdf)\\n\\n---\\n\\n[Top of page](#pg-top)\\n\\n© GlobalData Plc 2024 \\\\| Registered Office: John Carpenter House, John Carpenter Street, London, EC4Y 0AN, UK \\\\| Registered in England No. 03925319', 1, 1)

[9] search_agent responds to Agent

kind: respond\n",
+       "copy_output: false\n",
+       "\n",
+       "
1614 characters ...In late 2022, several factors influenced Nvidia's stock price:\n", "\n", - "2. **Economic Concerns**: Investors were worried about the overall economy losing momentum, which affected their confidence in Nvidia's stock. The extreme dominance of large-cap technology stocks at the index level also raised concerns.\n", + "1. **Declining Sales and Earnings**: Nvidia reported three quarters of declining year-over-year sales and four quarters of tapering earnings in late 2022 and early 2023. This negatively impacted investor sentiment and the stock price.\n", "\n", - "3. **AI Market Dynamics**: Nvidia's stock price was heavily influenced by the AI market. The company's significant outperformance in AI-related stocks led to discussions about bubble-like price action. However, Nvidia's financial results showed strong revenue and profit growth, particularly in data centers, which provided some fundamental support for the stock's high valuation.\n", + "2. **US-China Trade Restrictions**: The US government imposed new restrictions on the export of Nvidia's advanced AI chips to China and Russia. This move required Nvidia to obtain a license before selling certain cutting-edge chips, which significantly impacted its sales. China accounted for over 27% of Nvidia's total sales in 2022, and the restrictions led to a 52-week low in Nvidia's stock price.\n", "\n", - "4. **Valuation Concerns**: Nvidia's valuation was high compared to broader market indices. Its one-year forward price-to-earnings ratio was significantly higher than that of the Philadelphia Stock Exchange Semiconductor Index, the NASDAQ 100 Index, and the S&P 500.\n", + "3. **Market Trends and Technical Patterns**: Nvidia's stock was in a holding pattern, forming a \"pennant\" chart pattern, which often leads to continuations of the previous trend. Despite some volatility, the stock was expected to resume its uptrend, influenced by the broader market trends and technical analysis.\n", "\n", - "5. **Investor Sentiment**: There was widespread enthusiasm and speculation about AI, but it was not considered extreme. The options market did not show signs of excessive bullishness, and public company mentions of AI in earnings calls were at a record high.\n", + "4. **Economic Conditions**: High inflation and a bleak economic outlook affected consumer spending on personal computers, video games, smartphones, and other electronic gadgets, which in turn impacted Nvidia's sales and stock price.\n", "\n", - "6. **Belief in New Paradigms**: There was a strong belief in the transformative potential of AI, with significant investments being made in AI-related infrastructure. This belief contributed to the high valuation of Nvidia's stock.\n", + "5. **Geopolitical Tensions**: Increasing tensions between the US and China, including previous restrictions on semiconductor sales to Chinese companies like Huawei, added to the uncertainty and negatively affected Nvidia's stock.\n", "\n", - "Overall, while Nvidia's stock price was influenced by concerns about a potential bubble, the company's strong financial performance and the broader enthusiasm for AI provided some support for its high valuation.
" + "These factors combined to create a challenging environment for Nvidia, leading to fluctuations in its stock price during late 2022.
" ], "text/plain": [ "" ] }, - "execution_count": 22, + "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "\n", "from tapeagents.core import Respond\n", "from tapeagents.prompting import view_to_messages\n", "\n", - "search_system_instruction = (\n", - " f\"\"\"Use at most 5 tool calls to search the request info on on the web.\"\"\"\n", - ")\n", + "search_system_instruction = f\"\"\"Use at most 5 tool calls to search the request info on on the web.\"\"\"\n", "search_system_message = {\"role\": \"system\", \"content\": search_system_instruction}\n", "\n", + "\n", "class SearchAgentMainNode(Node):\n", - " \n", " def make_prompt(self, agent, tape: DialogTape) -> Prompt:\n", " view = agent.compute_view(tape)\n", " return Prompt(messages=view_to_messages(view.top, agent), tools=search_agent_env.get_tool_schema_dicts())\n", - " \n", + "\n", " def generate_steps(self, agent, tape, llm_stream: LLMStream):\n", " m = llm_stream.get_message()\n", " if m.content:\n", @@ -2335,18 +2470,16 @@ " yield SetNextNode(next_node=0)\n", " else:\n", " raise ValueError()\n", - " \n", + "\n", + "\n", "search_agent = Agent.create(\n", " name=\"search_agent\",\n", " llms=LiteLLM(model_name=\"gpt-4o\", parameters={\"temperature\": 0.1}),\n", " nodes=[SearchAgentMainNode()],\n", - ") \n", + ")\n", "# To test the subagent, we'll make a mock root agent that immediately calls \"search_agent\"\n", "call_step = Call(agent_name=\"search_agent\", content=\"What influenced Nvidia stock price in late 2022?\")\n", - "test_root_agent = Agent.create(\n", - " subagents=[search_agent],\n", - " nodes=[Node().with_fixed_steps([call_step])]\n", - ")\n", + "test_root_agent = Agent.create(subagents=[search_agent], nodes=[Node().with_fixed_steps([call_step])])\n", "start_tape = DialogTape()\n", "final_tape = None\n", "for event in main_loop(test_root_agent, start_tape, search_agent_env):\n", @@ -2368,13 +2501,13 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 26, "metadata": { "execution": { - "iopub.execute_input": "2024-09-27T12:58:10.447099Z", - "iopub.status.busy": "2024-09-27T12:58:10.446758Z", - "iopub.status.idle": "2024-09-27T12:58:47.719196Z", - "shell.execute_reply": "2024-09-27T12:58:47.718624Z" + "iopub.execute_input": "2024-09-28T05:59:06.317458Z", + "iopub.status.busy": "2024-09-28T05:59:06.317284Z", + "iopub.status.idle": "2024-09-28T05:59:19.926996Z", + "shell.execute_reply": "2024-09-28T05:59:19.926482Z" } }, "outputs": [ @@ -2384,27 +2517,27 @@ "

Metadata

Show / Hide
author: ''\n", "author_tape_id: null\n", "error: null\n", - "id: 9150f431-6dd8-4c94-acfc-9a1ac00e8cfa\n", + "id: fff54359-0124-44c8-9bfa-aae7362bdb7a\n", "n_added_steps: 3\n", - "parent_id: b6d0cba3-e6fc-4e96-b649-47f739ed73d1\n", + "parent_id: e51ec2df-1192-4fcd-8ee5-157a2d906e2f\n", "result: null\n", "

Steps

[0] User

kind: user\n",
        "\n",
        "Tell me about Vulcan in 3 sentences

[1] Thought: AssistantThought

kind: assistant_thought\n",
        "\n",
        "1. Use the `functions.get_stock_ticker` tool to find the stock ticker symbol for Vulcan.\n",
-       "2. Use the `functions.get_stock_data` tool to retrieve the stock price changes for Vulcan over the last year.\n",
-       "3. Use the `functions.call_search_agent` tool to gather general information about Vulcan, including its business operations and recent news.\n",
-       "4. Summarize the stock price changes and general information about Vulcan in a concise manner.

[2] Thought: SetNextNode

kind: set_next_node\n",
+       "2. Use the `functions.get_stock_data` tool to retrieve the stock price data for Vulcan over the past year, using the stock ticker obtained in step 1.\n",
+       "3. Use the `functions.call_search_agent` tool to gather general information about Vulcan, including its business operations and any notable recent events.\n",
+       "4. Summarize the stock price changes over the past year and provide the general information about the company in a concise manner.

[2] Thought: SetNextNode

kind: set_next_node\n",
        "next_node: 1\n",
        "

[3] Action: ToolCalls

tool_calls:\n",
        "- function:\n",
        "    arguments: '{\"company_name\": \"Vulcan\"}'\n",
        "    name: get_stock_ticker\n",
-       "  id: call_AvNULE6XakmHnWzSeiMP5zoQ\n",
+       "  id: call_HHPuEdeQodwah3GJWIjXKc93\n",
        "  type: function\n",
        "kind: assistant\n",
-       "

[4] Observation: ToolResult

tool_call_id: call_AvNULE6XakmHnWzSeiMP5zoQ\n",
+       "

[4] Observation: ToolResult

tool_call_id: call_HHPuEdeQodwah3GJWIjXKc93\n",
        "kind: tool\n",
        "\n",
        "VMC

[5] Thought: SetNextNode

kind: set_next_node\n",
@@ -2413,10 +2546,10 @@
        "- function:\n",
        "    arguments: '{\"symbol\": \"VMC\", \"start_date\": \"2023-09-17\", \"end_date\": \"2024-09-17\"}'\n",
        "    name: get_stock_data\n",
-       "  id: call_5uELngVxMic7PF7P85YaMol7\n",
+       "  id: call_tgIIDANiZNMWeY40VMsBjD4g\n",
        "  type: function\n",
        "kind: assistant\n",
-       "

[7] Observation: ToolResult

tool_call_id: call_5uELngVxMic7PF7P85YaMol7\n",
+       "

[7] Observation: ToolResult

tool_call_id: call_tgIIDANiZNMWeY40VMsBjD4g\n",
        "kind: tool\n",
        "\n",
        "
2195 characters ...[('2023-09-18', 211.69000244140625), ('2023-09-22', 200.6199951171875), ('2023-09-28', 205.02999877929688), ('2023-10-04', 205.02999877929688), ('2023-10-10', 211.0), ('2023-10-16', 213.0399932861328), ('2023-10-20', 201.5500030517578), ('2023-10-26', 193.97000122070312), ('2023-11-01', 203.8000030517578), ('2023-11-07', 207.2100067138672), ('2023-11-13', 210.49000549316406), ('2023-11-17', 212.35000610351562), ('2023-11-24', 211.67999267578125), ('2023-11-30', 213.55999755859375), ('2023-12-06', 211.92999267578125), ('2023-12-12', 220.89999389648438), ('2023-12-18', 222.6999969482422), ('2023-12-22', 224.92999267578125), ('2023-12-29', 227.00999450683594), ('2024-01-05', 221.6199951171875), ('2024-01-11', 224.36000061035156), ('2024-01-18', 225.1199951171875), ('2024-01-24', 219.8000030517578), ('2024-01-30', 231.0500030517578), ('2024-02-05', 229.64999389648438), ('2024-02-09', 240.0), ('2024-02-15', 242.4600067138672), ('2024-02-22', 256.94000244140625), ('2024-02-28', 262.29998779296875), ('2024-03-05', 264.9800109863281), ('2024-03-11', 264.95001220703125), ('2024-03-15', 266.8599853515625), ('2024-03-21', 275.5899963378906), ('2024-03-27', 272.7900085449219), ('2024-04-03', 268.7699890136719), ('2024-04-09', 265.6199951171875), ('2024-04-15', 260.4700012207031), ('2024-04-19', 252.05999755859375), ('2024-04-25', 258.5400085449219), ('2024-05-01', 259.7300109863281), ('2024-05-07', 268.3500061035156), ('2024-05-13', 270.0899963378906), ('2024-05-17', 259.1000061035156), ('2024-05-23', 257.2099914550781), ('2024-05-30', 254.0800018310547), ('2024-06-05', 251.17999267578125), ('2024-06-11', 244.63999938964844), ('2024-06-17', 256.3500061035156), ('2024-06-24', 247.5800018310547), ('2024-06-28', 248.67999267578125), ('2024-07-05', 244.2100067138672), ('2024-07-11', 254.69000244140625), ('2024-07-17', 255.8000030517578), ('2024-07-23', 260.1499938964844), ('2024-07-29', 264.5299987792969), ('2024-08-02', 266.3399963378906), ('2024-08-08', 246.3300018310547), ('2024-08-14', 242.5), ('2024-08-20', 245.60000610351562), ('2024-08-26', 250.67999267578125), ('2024-08-30', 245.2100067138672), ('2024-09-06', 231.97000122070312), ('2024-09-12', 236.27000427246094)]

[8] Thought: SetNextNode

kind: set_next_node\n",
@@ -2426,113 +2559,60 @@
        "\n",
        "Vulcan company profile and recent news

[10] Action: ToolCalls

tool_calls:\n",
        "- function:\n",
-       "    arguments: '{\"query\": \"Vulcan company profile\", \"max_results\": 1}'\n",
+       "    arguments: '{\"query\": \"Vulcan company profile\"}'\n",
        "    name: get_search_results\n",
-       "  id: call_BSbGYTks1uwLBgJjACJNvHQQ\n",
+       "  id: call_XBXEF6ZzCgvZSshG6h0XfhX9\n",
        "  type: function\n",
        "- function:\n",
-       "    arguments: '{\"query\": \"Vulcan company recent news\", \"max_results\": 3}'\n",
+       "    arguments: '{\"query\": \"Vulcan company recent news\"}'\n",
        "    name: get_search_results\n",
-       "  id: call_cuDAyivVRrpCpHCK6f1GkLOs\n",
+       "  id: call_pm526Z3er0QRh4hOXADunFMP\n",
        "  type: function\n",
        "kind: assistant\n",
        "

[11] Thought: SetNextNode

kind: set_next_node\n",
        "next_node: 0\n",
-       "

[12] Observation: ToolResult

tool_call_id: call_BSbGYTks1uwLBgJjACJNvHQQ\n",
+       "

[12] Observation: ToolResult

tool_call_id: call_XBXEF6ZzCgvZSshG6h0XfhX9\n",
        "kind: tool\n",
        "\n",
-       "[{'title': 'Vulcan Materials Company (VMC) Company Profile & Facts', 'url': 'https://ca.finance.yahoo.com/quote/VMC/profile/', 'content': 'Vulcan Materials Company, together with its subsidiaries, produces and supplies construction aggregates primarily in the United States. It operates through four\\xa0...'}]

[13] Observation: ToolResult

tool_call_id: call_cuDAyivVRrpCpHCK6f1GkLOs\n",
+       "
1408 characters ...[{'title': 'Vulcan Materials Company (VMC) Company Profile & Facts', 'url': 'https://ca.finance.yahoo.com/quote/VMC/profile/', 'content': 'Vulcan Materials Company, together with its subsidiaries, produces and supplies construction aggregates primarily in the United States. It operates through four\\xa0...'}, {'title': 'Vulcan Materials Co - Company Profile', 'url': 'https://www.globaldata.com/company-profile/vulcan-materials-company/', 'content': 'Vulcan Materials Co (Vulcan) is a manufacturer of construction materials. It sells crushed stone, sand, gravel and aggregates-based building materials. The\\xa0...'}, {'title': 'Corporate Profile', 'url': 'https://www.vulcangroup.com/about-vulcan/corporate-profile/', 'content': 'Vulcan Engineering is the largest in-house engineering, manufacturing, and installation group in North America dedicated to the metalcasting and heavy\\xa0...'}, {'title': 'Vulcan Inc - Company Profile and News', 'url': 'https://www.bloomberg.com/profile/company/270128Z:US', 'content': 'Vulcan Inc. operates as an investment company. The Company invests in financial services, internet and technology, life sciences, media, transportation, retail\\xa0...'}, {'title': 'About Vulcan', 'url': 'https://v-er.eu/about-vulcan/', 'content': 'Vulcan aims to be the largest, preferred, strategic producer and supplier of lithium chemicals and renewable energy from Europe for Europe.'}]

[13] Observation: ToolResult

tool_call_id: call_pm526Z3er0QRh4hOXADunFMP\n",
        "kind: tool\n",
        "\n",
-       "[{'title': 'VULCAN ANNOUNCES AGREEMENT TO ACQUIRE ...', 'url': 'https://www.prnewswire.com/news-releases/vulcan-announces-agreement-to-acquire-wake-stone-corporation-302260124.html', 'content': \"17 hours ago — VULCAN ANNOUNCES AGREEMENT TO ACQUIRE WAKE STONE CORPORATION · Share this article · WANT YOUR COMPANY'S NEWS FEATURED ON PRNEWSWIRE.COM? · Also\\xa0...\"}, {'title': 'News', 'url': 'https://ir.vulcanmaterials.com/news/default.aspx', 'content': 'September 26, 2024. VULCAN ANNOUNCES AGREEMENT TO ACQUIRE WAKE STONE CORPORATION ; August 6, 2024. VULCAN REPORTS SECOND QUARTER 2024 RESULTS ; July 19, 2024.'}, {'title': 'Vulcan Materials Company (VMC) Latest Press Releases & ...', 'url': 'https://finance.yahoo.com/quote/VMC/press-releases/', 'content': 'The Board of Directors of Vulcan Materials Company (NYSE: VMC) today declared a quarterly cash dividend of $0.46 per share on its common stock. The dividend\\xa0...'}]

[14] Action: ToolCalls

tool_calls:\n",
-       "- function:\n",
-       "    arguments: '{\"url\": \"https://ca.finance.yahoo.com/quote/VMC/profile/\"}'\n",
-       "    name: get_page\n",
-       "  id: call_YIimV07bfE379JymFQ1Li8sH\n",
-       "  type: function\n",
-       "- function:\n",
-       "    arguments: '{\"url\": \"https://www.prnewswire.com/news-releases/vulcan-announces-agreement-to-acquire-wake-stone-corporation-302260124.html\"}'\n",
-       "    name: get_page\n",
-       "  id: call_WftqnQ3kHIZcRjQGkDfzTznE\n",
-       "  type: function\n",
-       "- function:\n",
-       "    arguments: '{\"url\": \"https://ir.vulcanmaterials.com/news/default.aspx\"}'\n",
-       "    name: get_page\n",
-       "  id: call_n7uML2Wn5AcyWDONKRFCmRzT\n",
-       "  type: function\n",
-       "- function:\n",
-       "    arguments: '{\"url\": \"https://finance.yahoo.com/quote/VMC/press-releases/\"}'\n",
-       "    name: get_page\n",
-       "  id: call_coXqXN9CT67Wb0T1aP30vM1z\n",
-       "  type: function\n",
-       "kind: assistant\n",
-       "

[15] Thought: SetNextNode

kind: set_next_node\n",
-       "next_node: 0\n",
-       "

[16] Observation: ToolResult

tool_call_id: call_YIimV07bfE379JymFQ1Li8sH\n",
-       "kind: tool\n",
+       "[{'title': 'News', 'url': 'https://ir.vulcanmaterials.com/news/default.aspx', 'content': 'News ; August 6, 2024. VULCAN REPORTS SECOND QUARTER 2024 RESULTS ; July 19, 2024. VULCAN ANNOUNCES SECOND QUARTER 2024 CONFERENCE CALL ; July 12, 2024. VULCAN\\xa0...'}, {'title': 'Vulcan News | Latest Local Headlines', 'url': 'https://www.vulcanadvocate.com/category/news/local-news/', 'content': \"4 days ago — Latest News Videos · Mark Carney gets Trudeau job just as his company asks Ottawa for $10 billion · Vulcan's council moves ahead with bylaw that\\xa0...\"}, {'title': 'Vulcan Advocate: Home', 'url': 'https://www.vulcanadvocate.com/', 'content': 'Mark Carney gets Trudeau job just as his company asks Ottawa for $10 billion · play video: Trudeau faces leadership questions after byelection blow in Montreal.'}]

[14] search_agent responds to analyst

kind: respond\n",
+       "copy_output: false\n",
        "\n",
-       "
5931 characters ...('Title: Vulcan Materials Company (VMC) Company Profile & Facts - Yahoo Finance\\n=======================\\n* [**Home**](https://ca.yahoo.com/)\\n* [Mail](https://ca.mail.yahoo.com/?.intl=ca&.lang=en-CA)\\n* [News](https://ca.news.yahoo.com/)\\n* [Sports](https://ca.sports.yahoo.com/)\\n* [Finance](https://ca.finance.yahoo.com/)\\n* [Celebrity](https://ca.news.yahoo.com/celebrity/)\\n* [Style](https://ca.style.yahoo.com/)\\n* [Movies](https://ca.movies.yahoo.com/)\\n* [Weather](https://ca.news.yahoo.com/weather/)\\n* [Mobile](https://ca.mobile.yahoo.com/)\\n[**Yahoo**](https://ca.finance.yahoo.com/)*\\n* [**Mail**](https://mail.yahoo.com/?activity=uh-mail&.intl=ca&.lang=en-CA&.partner=none&.src=finance&pspid=1184585870)\\n* [News](/topic/news/ \"News\")\\n* [Taxes](https://ca.yahoo.com/topics/taxes/ \"Taxes\")\\n* [Watchlists](/watchlists/ \"Watchlists\")\\n* [My Portfolio](/portfolios/ \"My Portfolio\")\\n* [My Screeners](/screener/ \"My Screeners\")\\n* Market Data\\n* Industry News\\n* [Real Estate](https://ca.yahoo.com/topics/canada-real-estate-news/ \"Real Estate\")\\n* [Technology](/topic/technology/ \"Technology\")\\n* [Currency Converter](/currencies/converter/#from=CAD;to=USD;amt=1 \"Currency Converter\")\\n Canada markets open in 32 minutes* ### [S\\\\&P/TSX](/quote/%5EGSPTSE/ \"S&P/TSX\")24,033\\\\.83\\\\+127\\\\.95(\\\\+0\\\\.54%)\\n* ### [S\\\\&P 500](/quote/%5EGSPC/ \"S&P 500\")5,745\\\\.37\\\\+23\\\\.11(\\\\+0\\\\.40%)\\n* ### [DOW](/quote/%5EDJI/ \"DOW\")42,175\\\\.11\\\\+260\\\\.36(\\\\+0\\\\.62%)\\n* ### [CAD/USD](/quote/CADUSD%3DX/ \"CAD/USD\")0\\\\.7423\\\\-0\\\\.0002(\\\\-0\\\\.03%)\\n* ### [CRUDE OIL](/quote/CL%3DF/ \"CRUDE OIL\")67\\\\.74\\\\+0\\\\.07(\\\\+0\\\\.10%)\\n* ### [Bitcoin CAD](/quote/BTC-CAD/ \"Bitcoin CAD\")88,603\\\\.91\\\\+1,705\\\\.29(\\\\+1\\\\.96%)\\n[BREAKINGCANADA\\'S ECONOMY SURPASSES JULY GROWTH FORECAST\\n-----------------------------------------------\\n\\nAdvance estimates show real gross domestic product unchanged in August](/news/canadas-economy-grew-more-than-expected-in-july-123851239.html)Vulcan Materials Company (VMC)\\n==============================\\n\\nNYSE \\\\- Nasdaq Real Time Price. Currency in USDAdd to watchlist250\\\\.58\\\\+0\\\\.95 (\\\\+0\\\\.38%)At close: 04:00PM EDT250\\\\.58 0\\\\.00 (0\\\\.00%)\\nPre\\\\-Market: 08:32AM EDT * [Summary](/quote/VMC/)\\n* [Chart](/quote/VMC/chart/)\\n* [Conversations](/quote/VMC/community/)\\n* [Statistics](/quote/VMC/key-statistics/)\\n* [Historical Data](/quote/VMC/history/)\\n* [Profile](/quote/VMC/profile/)\\n* [Financials](/quote/VMC/financials/)\\n* [Analysis](/quote/VMC/analysis/)\\n* [Options](/quote/VMC/options/)\\n* [Holders](/quote/VMC/holders/)\\n* [Sustainability](/quote/VMC/sustainability/)\\n### Vulcan Materials Company\\n\\n1200 Urban Center Drive\\nBirmingham, AL 35242\\nUnited States\\n[205 298 3000](tel:2052983000)\\n\\n\\nSector(s):\\xa0Basic Materials\\nIndustry:\\xa0Building Materials\\nFull Time Employees:\\xa010,961\\n\\n### Key Executives\\n\\n| Name | Title | Pay | Exercised | Year Born |\\n| --- | --- | --- | --- | --- |\\n| Mr. James Thomas Hill | CEO \\\\& Chairman | 5\\\\.76M | 2\\\\.58M | 1959 |\\n| Mr. Thompson S. Baker II | President | 2\\\\.56M | N/A | 1958 |\\n| Ms. Mary Andrews Carlisle | Senior VP \\\\& CFO | 1\\\\.85M | N/A | 1981 |\\n| Mr. Ronnie A. Pruitt | Chief Operating Officer | 1\\\\.87M | N/A | 1971 |\\n| Mr. Stanley G. Bass | Chief Strategy Officer | 2\\\\.27M | 635\\\\.67k | 1961 |\\n| Mr. Randy L. Pigg | VP, Principal Accounting Officer \\\\& Controller | N/A | N/A | 1973 |\\n| Krzysztof Soltan | Chief Information Officer | N/A | N/A | N/A |\\n| Mr. Mark D. Warren | Vice President of Investor Relations | N/A | N/A | N/A |\\n| Mr. Denson N. Franklin III | Senior VP, General Counsel \\\\& Secretary | 1\\\\.18M | N/A | 1964 |\\n| Ms. Janet F. Kavinoky | Vice President of External Affairs \\\\& Corporate Communications | N/A | N/A | N/A |\\n\\nAmounts are as of December 31, 2023 and compensation values are for the last fiscal year ending on that date. Pay is salary, bonuses, etc. Exercised is the value of options exercised during the fiscal year. Currency in USD.Description\\n-----------\\n\\nVulcan Materials Company, together with its subsidiaries, produces and supplies construction aggregates primarily in the United States. It operates through four segments: Aggregates, Asphalt, Concrete, and Calcium. The company provides crushed stones, sand and gravel, sand, and other aggregates; and related products and services that are applied in construction and maintenance of highways, streets, and other public works, as well as in the construction of housing and commercial, industrial, and other nonresidential facilities. It also offers asphalt mix and asphalt construction paving services; ready\\\\-mixed concrete; and calcium products for the animal feed, plastics, and water treatment industries. The company was formerly known as Virginia Holdco, Inc. and changed its name to Vulcan Materials Company. Vulcan Materials Company was founded in 1909 and is headquartered in Birmingham, Alabama.\\n\\nCorporate Governance\\n--------------------\\n\\nVulcan Materials Company’s ISS Governance QualityScore as of September 18, 2024 is 6\\\\. The pillar scores are Audit: 7; Board: 6; Shareholder Rights: 6; Compensation: 5\\\\.\\n\\nCorporate governance scores courtesy of [Institutional Shareholder Services (ISS)](https://issgovernance.com/quickscore \"Institutional Shareholder Services (ISS)\"). Scores indicate decile rank relative to index or region. A decile score of 1 indicates lower governance risk, while a 10 indicates higher governance risk. [Data Disclaimer](https://help.yahoo.com/kb/finance-for-web/SLN2310.html?locale=en_CA)[Help](https://ca.help.yahoo.com/kb/finance-for-web)[Suggestions](https://yahoo.uservoice.com/forums/566647-finance-ca)[Terms](https://guce.yahoo.com/terms?locale=en-CA)and[Privacy Policy](https://guce.yahoo.com/privacy-policy?locale=en-CA)[About Our Ads](https://legal.yahoo.com/ca/en/yahoo/privacy/adinfo/index.html)*\\n*\\n© 2024 Yahoo. All rights reserved.', 1, 1)

[17] Observation: ToolResult

tool_call_id: call_WftqnQ3kHIZcRjQGkDfzTznE\n",
-       "kind: tool\n",
+       "
2022 characters ...### Vulcan Company Profile\n", "\n", - "
33256 characters ...('Title: VULCAN ANNOUNCES AGREEMENT TO ACQUIRE WAKE STONE CORPORATION\\n=======================\\n* [Resources](/resources/)\\n* [Blog](/resources/articles/)\\n* [Journalists](https://prnmedia.prnewswire.com/)\\n\\n* [Log In](https://portal.prnewswire.com/Login.aspx)\\n* [Sign Up](https://www.prnewswire.com/account/online-membership-form/)\\n* [Data Privacy](https://gdpr.cision.com/)\\n* [Send a Release](https://www.prnewswire.com/account/online-membership-form/)\\n\\n[![Cision PR Newswire: news distribution, targeting and monitoring home](/content/dam/prnewswire/homepage/prn_cision_logo_desktop.png \"Cision PR Newswire: news distribution, targeting and monitoring home\")](/)\\n\\n* [News](/news-releases/)\\n* [Products](/products/overview/)\\n* [Contact](/contact-us/)\\n\\nSearch\\n\\nSearch\\nWhen typing in this field, a list of search results will appear and be automatically updated as you type.\\n\\nSearching for your content...\\n\\n**No results found. Please change your search terms and try again.**\\n\\n* [News in Focus](# \"News in Focus\")\\n\\t+ - [Browse News Releases](/news-releases/)\\n\\t\\t---------------------------------------\\n\\t\\t- [All News Releases](/news-releases/news-releases-list/)\\n\\t\\t- [All Public Company](/news-releases/all-public-company-news/)\\n\\t\\t- [English\\\\-only](/news-releases/english-releases/)\\n\\t\\t- [News Releases Overview](/news-releases/)\\n\\t\\t-----------------------------------------\\n\\n\\t\\t- [Multimedia Gallery](/news-releases/multimedia/)\\n\\t\\t------------------------------------------------\\n\\t\\t- [All Multimedia](/news-releases/multimedia/multimedia-list/)\\n\\t\\t- [All Photos](/news-releases/photos/photos-list/)\\n\\t\\t- [All Videos](/news-releases/videos/videos-list/)\\n\\t\\t- [Multimedia Gallery Overview](/news-releases/multimedia/)\\n\\t\\t---------------------------------------------------------\\n\\n\\t\\t- [Trending Topics](/news-releases/latest-news-topics/)\\n\\t\\t-----------------------------------------------------\\n\\t\\t- [All Trending Topics](/news-releases/latest-news-topics/)\\n* [Business \\\\& Money](# \"Business & Money\")\\n\\t+ - [Auto \\\\& Transportation](/news-releases/automotive-transportation-latest-news/)\\n\\t\\t-------------------------------------------------------------------------------\\n\\t\\t- [All Automotive \\\\& Transportation](/news-releases/automotive-transportation-latest-news/automotive-transportation-latest-news-list/)\\n\\t\\t- [Aerospace, Defense](/news-releases/automotive-transportation-latest-news/aerospace-defense-list/)\\n\\t\\t- [Air Freight](/news-releases/automotive-transportation-latest-news/air-freight-list/)\\n\\t\\t- [Airlines \\\\& Aviation](/news-releases/automotive-transportation-latest-news/airlines-aviation-list/)\\n\\t\\t- [Automotive](/news-releases/automotive-transportation-latest-news/automotive-list/)\\n\\t\\t- [Maritime \\\\& Shipbuilding](/news-releases/automotive-transportation-latest-news/maritime-shipbuilding-list/)\\n\\t\\t- [Railroads and Intermodal Transportation](/news-releases/automotive-transportation-latest-news/railroads-and-intermodal-transportation-list/)\\n\\t\\t- [Supply Chain/Logistics](/news-releases/automotive-transportation-latest-news/supply-chain-logistics-list/)\\n\\t\\t- [Transportation, Trucking \\\\& Railroad](/news-releases/automotive-transportation-latest-news/transportation-trucking-railroad-list/)\\n\\t\\t- [Travel](/news-releases/automotive-transportation-latest-news/travel-list/)\\n\\t\\t- [Trucking and Road Transportation](/news-releases/automotive-transportation-latest-news/trucking-and-road-transportation-list/)\\n\\t\\t- [Auto \\\\& Transportation Overview](/news-releases/automotive-transportation-latest-news/)\\n\\t\\t----------------------------------------------------------------------------------------\\n\\t\\t- [View All Auto \\\\& Transportation](/news-releases/automotive-transportation-latest-news/automotive-transportation-latest-news-list/)\\n\\t\\t-----------------------------------------------------------------------------------------------------------------------------------\\n\\t\\t- [Business Technology](/news-releases/business-technology-latest-news/)\\n\\t\\t----------------------------------------------------------------------\\n\\t\\t- [All Business Technology](/news-releases/business-technology-latest-news/business-technology-latest-news-list/)\\n\\t\\t- [Blockchain](/news-releases/business-technology-latest-news/blockchain-list/)\\n\\t\\t- [Broadcast Tech](/news-releases/business-technology-latest-news/broadcast-tech-list/)\\n\\t\\t- [Computer \\\\& Electronics](/news-releases/business-technology-latest-news/computer-electronics-list/)\\n\\t\\t- [Computer Hardware](/news-releases/business-technology-latest-news/computer-hardware-list/)\\n\\t\\t- [Computer Software](/news-releases/business-technology-latest-news/computer-software-list/)\\n\\t\\t- [Data Analytics](/news-releases/business-technology-latest-news/data-analytics-list/)\\n\\t\\t- [Electronic Commerce](/news-releases/business-technology-latest-news/electronic-commerce-list/)\\n\\t\\t- [Electronic Components](/news-releases/business-technology-latest-news/electronic-components-list/)\\n\\t\\t- [Electronic Design Automation](/news-releases/business-technology-latest-news/electronic-design-automation-list/)\\n\\t\\t- [Financial Technology](/news-releases/business-technology-latest-news/financial-technology-list/)\\n\\t\\t- [High Tech Security](/news-releases/business-technology-latest-news/high-tech-security-list/)\\n\\t\\t- [Internet Technology](/news-releases/business-technology-latest-news/internet-technology-list/)\\n\\t\\t- [Nanotechnology](/news-releases/business-technology-latest-news/nanotechnology-list/)\\n\\t\\t- [Networks](/news-releases/business-technology-latest-news/networks-list/)\\n\\t\\t- [Peripherals](/news-releases/business-technology-latest-news/peripherals-list/)\\n\\t\\t- [Semiconductors](/news-releases/business-technology-latest-news/semiconductors-list/)\\n\\t\\t- [Business Technology Overview](/news-releases/business-technology-latest-news/)\\n\\t\\t-------------------------------------------------------------------------------\\n\\t\\t- [View All Business Technology](/news-releases/business-technology-latest-news/business-technology-latest-news-list/)\\n\\t\\t--------------------------------------------------------------------------------------------------------------------\\n\\t\\t- [Entertain\\xadment \\\\& Media](/news-releases/entertainment-media-latest-news/)\\n\\t\\t--------------------------------------------------------------------------\\n\\t\\t- [All Entertain\\xadment \\\\& Media](/news-releases/entertainment-media-latest-news/entertainment-media-latest-news-list/)\\n\\t\\t- [Advertising](/news-releases/entertainment-media-latest-news/advertising-list/)\\n\\t\\t- [Art](/news-releases/entertainment-media-latest-news/art-list/)\\n\\t\\t- [Books](/news-releases/entertainment-media-latest-news/books-list/)\\n\\t\\t- [Entertainment](/news-releases/entertainment-media-latest-news/entertainment-list/)\\n\\t\\t- [Film and Motion Picture](/news-releases/entertainment-media-latest-news/film-and-motion-picture-list/)\\n\\t\\t- [Magazines](/news-releases/entertainment-media-latest-news/magazines-list/)\\n\\t\\t- [Music](/news-releases/entertainment-media-latest-news/music-list/)\\n\\t\\t- [Publishing \\\\& Information Services](/news-releases/entertainment-media-latest-news/publishing-information-services-list/)\\n\\t\\t- [Radio \\\\& Podcast](/news-releases/entertainment-media-latest-news/radio-list/)\\n\\t\\t- [Television](/news-releases/entertainment-media-latest-news/television-list/)\\n\\t\\t- [Entertain\\xadment \\\\& Media Overview](/news-releases/entertainment-media-latest-news/)\\n\\t\\t-----------------------------------------------------------------------------------\\n\\t\\t- [View All Entertain\\xadment \\\\& Media](/news-releases/entertainment-media-latest-news/entertainment-media-latest-news-list/)\\n\\t\\t------------------------------------------------------------------------------------------------------------------------\\n\\t\\t- [Financial Services \\\\& Investing](/news-releases/financial-services-latest-news/)\\n\\t\\t---------------------------------------------------------------------------------\\n\\t\\t- [All Financial Services \\\\& Investing](/news-releases/financial-services-latest-news/financial-services-latest-news-list/)\\n\\t\\t- [Accounting News \\\\& Issues](/news-releases/financial-services-latest-news/accounting-news-issues-list/)\\n\\t\\t- [Acquisitions, Mergers and Takeovers](/news-releases/financial-services-latest-news/acquisitions-mergers-and-takeovers-list/)\\n\\t\\t- [Banking \\\\& Financial Services](/news-releases/financial-services-latest-news/banking-financial-services-list/)\\n\\t\\t- [Bankruptcy](/news-releases/financial-services-latest-news/bankruptcy-list/)\\n\\t\\t- [Bond \\\\& Stock Ratings](/news-releases/financial-services-latest-news/bond-stock-ratings-list/)\\n\\t\\t- [Conference Call Announcements](/news-releases/financial-services-latest-news/conference-call-announcements-list/)\\n\\t\\t- [Contracts](/news-releases/financial-services-latest-news/contracts-list/)\\n\\t\\t- [Cryptocurrency](/news-releases/financial-services-latest-news/cryptocurrency-list/)\\n\\t\\t- [Dividends](/news-releases/financial-services-latest-news/dividends-list/)\\n\\t\\t- [Earnings](/news-releases/financial-services-latest-news/earnings-list/)\\n\\t\\t- [Earnings Forecasts \\\\& Projections](/news-releases/financial-services-latest-news/earnings-forecasts-projections-list/)\\n\\t\\t- [Financing Agreements](/news-releases/financial-services-latest-news/financing-agreements-list/)\\n\\t\\t- [Insurance](/news-releases/financial-services-latest-news/insurance-list/)\\n\\t\\t- [Investments Opinions](/news-releases/financial-services-latest-news/investment-opinions-list/)\\n\\t\\t- [Joint Ventures](/news-releases/financial-services-latest-news/joint-ventures-list/)\\n\\t\\t- [Mutual Funds](/news-releases/financial-services-latest-news/mutual-funds-list/)\\n\\t\\t- [Private Placement](/news-releases/financial-services-latest-news/private-placement-list/)\\n\\t\\t- [Real Estate](/news-releases/financial-services-latest-news/real-estate-list/)\\n\\t\\t- [Restructuring \\\\& Recapitalization](/news-releases/financial-services-latest-news/restructuring-recapitalization-list/)\\n\\t\\t- [Sales Reports](/news-releases/financial-services-latest-news/sales-reports-list/)\\n\\t\\t- [Shareholder Activism](/news-releases/financial-services-latest-news/shareholder-activism-list/)\\n\\t\\t- [Shareholder Meetings](/news-releases/financial-services-latest-news/shareholder-meetings-list/)\\n\\t\\t- [Stock Offering](/news-releases/financial-services-latest-news/stock-offering-list/)\\n\\t\\t- [Stock Split](/news-releases/financial-services-latest-news/stock-split-list/)\\n\\t\\t- [Venture Capital](/news-releases/financial-services-latest-news/venture-capital-list/)\\n\\t\\t- [Financial Services \\\\& Investing Overview](/news-releases/financial-services-latest-news/)\\n\\t\\t------------------------------------------------------------------------------------------\\n\\t\\t- [View All Financial Services \\\\& Investing](/news-releases/financial-services-latest-news/financial-services-latest-news-list/)\\n\\t\\t------------------------------------------------------------------------------------------------------------------------------\\n\\t\\t- [General Business](/news-releases/general-business-latest-news/)\\n\\t\\t----------------------------------------------------------------\\n\\t\\t- [All General Business](/news-releases/general-business-latest-news/general-business-latest-news-list/)\\n\\t\\t- [Awards](/news-releases/general-business-latest-news/awards-list/)\\n\\t\\t- [Commercial Real Estate](/news-releases/general-business-latest-news/commercial-real-estate-list/)\\n\\t\\t- [Corporate Expansion](/news-releases/general-business-latest-news/corporate-expansion-list/)\\n\\t\\t- [Earnings](/news-releases/general-business-latest-news/earnings-list/)\\n\\t\\t- [Environmental, Social and Governance (ESG)](/news-releases/general-business-latest-news/environmental-social-governance-list/)\\n\\t\\t- [Human Resource \\\\& Workforce Management](/news-releases/general-business-latest-news/human-resource-workforce-management-list/)\\n\\t\\t- [Licensing](/news-releases/general-business-latest-news/licensing-list/)\\n\\t\\t- [New Products \\\\& Services](/news-releases/general-business-latest-news/new-products-services-list/)\\n\\t\\t- [Obituaries](/news-releases/general-business-latest-news/obituaries-list/)\\n\\t\\t- [Outsourcing Businesses](/news-releases/general-business-latest-news/outsourcing-businesses-list/)\\n\\t\\t- [Overseas Real Estate (non\\\\-US)](/news-releases/general-business-latest-news/overseas-real-estate-list/)\\n\\t\\t- [Personnel Announcements](/news-releases/general-business-latest-news/personnel-announcements-list/)\\n\\t\\t- [Real Estate Transactions](/news-releases/general-business-latest-news/real-estate-transactions-list/)\\n\\t\\t- [Residential Real Estate](/news-releases/general-business-latest-news/residential-real-estate-list/)\\n\\t\\t- [Small Business Services](/news-releases/general-business-latest-news/small-business-services-list/)\\n\\t\\t- [Socially Responsible Investing](/news-releases/general-business-latest-news/socially-responsible-investing-list/)\\n\\t\\t- [Surveys, Polls and Research](/news-releases/general-business-latest-news/surveys-polls-and-research-list/)\\n\\t\\t- [Trade Show News](/news-releases/general-business-latest-news/trade-show-news-list/)\\n\\t\\t- [General Business Overview](/news-releases/general-business-latest-news/)\\n\\t\\t-------------------------------------------------------------------------\\n\\t\\t- [View All General Business](/news-releases/general-business-latest-news/general-business-latest-news-list/)\\n\\t\\t-----------------------------------------------------------------------------------------------------------\\n* [Science \\\\& Tech](# \"Science & Tech\")\\n\\t+ - [Consumer Technology](/news-releases/consumer-technology-latest-news/)\\n\\t\\t----------------------------------------------------------------------\\n\\t\\t- [All Consumer Technology](/news-releases/consumer-technology-latest-news/consumer-technology-latest-news-list/)\\n\\t\\t- [Artificial Intelligence](/news-releases/consumer-technology-latest-news/artificial-intelligence-list/)\\n\\t\\t- [Blockchain](/news-releases/consumer-technology-latest-news/blockchain-list/)\\n\\t\\t- [Cloud Computing/Internet of Things](/news-releases/consumer-technology-latest-news/cloud-computing-internet-of-things-list/)\\n\\t\\t- [Computer Electronics](/news-releases/consumer-technology-latest-news/computer-electronics-list/)\\n\\t\\t- [Computer Hardware](/news-releases/consumer-technology-latest-news/computer-hardware-list/)\\n\\t\\t- [Computer Software](/news-releases/consumer-technology-latest-news/computer-software-list/)\\n\\t\\t- [Consumer Electronics](/news-releases/consumer-technology-latest-news/consumer-electronics-list/)\\n\\t\\t- [Cryptocurrency](/news-releases/consumer-technology-latest-news/cryptocurrency-list/)\\n\\t\\t- [Data Analytics](/news-releases/consumer-technology-latest-news/data-analytics-list/)\\n\\t\\t- [Electronic Commerce](/news-releases/consumer-technology-latest-news/electronic-commerce-list/)\\n\\t\\t- [Electronic Gaming](/news-releases/consumer-technology-latest-news/electronic-gaming-list/)\\n\\t\\t- [Financial Technology](/news-releases/consumer-technology-latest-news/financial-technology-list/)\\n\\t\\t- [Mobile Entertainment](/news-releases/consumer-technology-latest-news/mobile-entertainment-list/)\\n\\t\\t- [Multimedia \\\\& Internet](/news-releases/consumer-technology-latest-news/multimedia-internet-list/)\\n\\t\\t- [Peripherals](/news-releases/consumer-technology-latest-news/peripherals-list/)\\n\\t\\t- [Social Media](/news-releases/consumer-technology-latest-news/social-media-list/)\\n\\t\\t- [STEM (Science, Tech, Engineering, Math)](/news-releases/consumer-technology-latest-news/science-tech-engineering-math-list/)\\n\\t\\t- [Supply Chain/Logistics](/news-releases/consumer-technology-latest-news/supply-chain-logistics-list/)\\n\\t\\t- [Wireless Communications](/news-releases/consumer-technology-latest-news/wireless-communications-list/)\\n\\t\\t- [Consumer Technology Overview](/news-releases/consumer-technology-latest-news/)\\n\\t\\t-------------------------------------------------------------------------------\\n\\t\\t- [View All Consumer Technology](/news-releases/consumer-technology-latest-news/consumer-technology-latest-news-list/)\\n\\t\\t--------------------------------------------------------------------------------------------------------------------\\n\\t\\t- [Energy \\\\& Natural Resources](/news-releases/energy-latest-news/)\\n\\t\\t-----------------------------------------------------------------\\n\\t\\t- [All Energy](/news-releases/energy-latest-news/energy-latest-news-list/)\\n\\t\\t- [Alternative Energies](/news-releases/energy-latest-news/alternative-energies-list/)\\n\\t\\t- [Chemical](/news-releases/energy-latest-news/chemical-list/)\\n\\t\\t- [Electrical Utilities](/news-releases/energy-latest-news/electrical-utilities-list/)\\n\\t\\t- [Gas](/news-releases/energy-latest-news/gas-list/)\\n\\t\\t- [General Manufacturing](/news-releases/energy-latest-news/general-manufacturing-list/)\\n\\t\\t- [Mining](/news-releases/energy-latest-news/mining-list/)\\n\\t\\t- [Mining \\\\& Metals](/news-releases/energy-latest-news/mining-metals-list/)\\n\\t\\t- [Oil \\\\& Energy](/news-releases/energy-latest-news/oil-energy-list/)\\n\\t\\t- [Oil and Gas Discoveries](/news-releases/energy-latest-news/oil-and-gas-discoveries-list/)\\n\\t\\t- [Utilities](/news-releases/energy-latest-news/utilities-list/)\\n\\t\\t- [Water Utilities](/news-releases/energy-latest-news/water-utilities-list/)\\n\\t\\t- [Energy \\\\& Natural Resources Overview](/news-releases/energy-latest-news/)\\n\\t\\t--------------------------------------------------------------------------\\n\\t\\t- [View All Energy \\\\& Natural Resources](/news-releases/energy-latest-news/energy-latest-news-list/)\\n\\t\\t--------------------------------------------------------------------------------------------------\\n\\t\\t- [Environ\\xadment](/news-releases/environment-latest-news/)\\n\\t\\t-------------------------------------------------------\\n\\t\\t- [All Environ\\xadment](/news-releases/environment-latest-news/environment-latest-news-list/)\\n\\t\\t- [Conservation \\\\& Recycling](/news-releases/environment-latest-news/conservation-recycling-list/)\\n\\t\\t- [Environmental Issues](/news-releases/environment-latest-news/environmental-issues-list/)\\n\\t\\t- [Environmental Policy](/news-releases/environment-latest-news/environmental-policy-list/)\\n\\t\\t- [Environmental Products \\\\& Services](/news-releases/environment-latest-news/environmental-products-services-list/)\\n\\t\\t- [Green Technology](/news-releases/environment-latest-news/green-technology-list/)\\n\\t\\t- [Natural Disasters](/news-releases/environment-latest-news/natural-disasters/)\\n\\t\\t- [Environ\\xadment Overview](/news-releases/environment-latest-news/)\\n\\t\\t----------------------------------------------------------------\\n\\t\\t- [View All Environ\\xadment](/news-releases/environment-latest-news/environment-latest-news-list/)\\n\\t\\t---------------------------------------------------------------------------------------------\\n\\t\\t- [Heavy Industry \\\\& Manufacturing](/news-releases/heavy-industry-manufacturing-latest-news/)\\n\\t\\t-------------------------------------------------------------------------------------------\\n\\t\\t- [All Heavy Industry \\\\& Manufacturing](/news-releases/heavy-industry-manufacturing-latest-news/heavy-industry-manufacturing-latest-news-list/)\\n\\t\\t- [Aerospace \\\\& Defense](/news-releases/heavy-industry-manufacturing-latest-news/aerospace-defense-list/)\\n\\t\\t- [Agriculture](/news-releases/heavy-industry-manufacturing-latest-news/agriculture-list/)\\n\\t\\t- [Chemical](/news-releases/heavy-industry-manufacturing-latest-news/chemical-list/)\\n\\t\\t- [Construction \\\\& Building](/news-releases/heavy-industry-manufacturing-latest-news/construction-building-list/)\\n\\t\\t- [General Manufacturing](/news-releases/heavy-industry-manufacturing-latest-news/general-manufacturing-list/)\\n\\t\\t- [HVAC (Heating, Ventilation and Air\\\\-Conditioning)](/news-releases/heavy-industry-manufacturing-latest-news/hvac-list/)\\n\\t\\t- [Machinery](/news-releases/heavy-industry-manufacturing-latest-news/machinery-list/)\\n\\t\\t- [Machine Tools, Metalworking and Metallurgy](/news-releases/heavy-industry-manufacturing-latest-news/machine-tools-metalworking-and-metallury-list/)\\n\\t\\t- [Mining](/news-releases/heavy-industry-manufacturing-latest-news/mining-list/)\\n\\t\\t- [Mining \\\\& Metals](/news-releases/heavy-industry-manufacturing-latest-news/mining-metals-list/)\\n\\t\\t- [Paper, Forest Products \\\\& Containers](/news-releases/heavy-industry-manufacturing-latest-news/paper-forest-products-containers-list/)\\n\\t\\t- [Precious Metals](/news-releases/heavy-industry-manufacturing-latest-news/precious-metals-list/)\\n\\t\\t- [Textiles](/news-releases/heavy-industry-manufacturing-latest-news/textiles-list/)\\n\\t\\t- [Tobacco](/news-releases/heavy-industry-manufacturing-latest-news/tobacco-list/)\\n\\t\\t- [Heavy Industry \\\\& Manufacturing Overview](/news-releases/heavy-industry-manufacturing-latest-news/)\\n\\t\\t----------------------------------------------------------------------------------------------------\\n\\t\\t- [View All Heavy Industry \\\\& Manufacturing](/news-releases/heavy-industry-manufacturing-latest-news/heavy-industry-manufacturing-latest-news-list/)\\n\\t\\t--------------------------------------------------------------------------------------------------------------------------------------------------\\n\\t\\t- [Telecomm\\xadunications](/news-releases/telecommunications-latest-news/)\\n\\t\\t---------------------------------------------------------------------\\n\\t\\t- [All Telecomm\\xadunications](/news-releases/telecommunications-latest-news/telecommunications-latest-news-list/)\\n\\t\\t- [Carriers and Services](/news-releases/telecommunications-latest-news/carriers-and-services-list/)\\n\\t\\t- [Mobile Entertainment](/news-releases/telecommunications-latest-news/mobile-entertainment-list/)\\n\\t\\t- [Networks](/news-releases/telecommunications-latest-news/networks-list/)\\n\\t\\t- [Peripherals](/news-releases/telecommunications-latest-news/peripherals-list/)\\n\\t\\t- [Telecommunications Equipment](/news-releases/telecommunications-latest-news/telecommunications-equipment-list/)\\n\\t\\t- [Telecommunications Industry](/news-releases/telecommunications-latest-news/telecommunications-industry-list/)\\n\\t\\t- [VoIP (Voice over Internet Protocol)](/news-releases/telecommunications-latest-news/voip-list/)\\n\\t\\t- [Wireless Communications](/news-releases/telecommunications-latest-news/wireless-communications-list/)\\n\\t\\t- [Telecomm\\xadunications Overview](/news-releases/telecommunications-latest-news/)\\n\\t\\t------------------------------------------------------------------------------\\n\\t\\t- [View All Telecomm\\xadunications](/news-releases/telecommunications-latest-news/telecommunications-latest-news-list/)\\n\\t\\t------------------------------------------------------------------------------------------------------------------\\n* [Lifestyle \\\\& Health](# \"Lifestyle & Health\")\\n\\t+ - [Consumer Products \\\\& Retail](/news-releases/consumer-products-retail-latest-news/)\\n\\t\\t-----------------------------------------------------------------------------------\\n\\t\\t- [All Consumer Products \\\\& Retail](/news-releases/consumer-products-retail-latest-news/consumer-products-retail-latest-news-list/)\\n\\t\\t- [Animals \\\\& Pets](/news-releases/consumer-products-retail-latest-news/animals-pets-list/)\\n\\t\\t- [Beers, Wines and Spirits](/news-releases/consumer-products-retail-latest-news/beers-wines-and-spirits-list/)\\n\\t\\t- [Beverages](/news-releases/consumer-products-retail-latest-news/beverages-list/)\\n\\t\\t- [Bridal Services](/news-releases/consumer-products-retail-latest-news/bridal-services-list/)\\n\\t\\t- [Cannabis](/news-releases/consumer-products-retail-latest-news/cannabis-list/)\\n\\t\\t- [Cosmetics and Personal Care](/news-releases/consumer-products-retail-latest-news/cosmetics-and-personal-care-list/)\\n\\t\\t- [Fashion](/news-releases/consumer-products-retail-latest-news/fashion-list/)\\n\\t\\t- [Food \\\\& Beverages](/news-releases/consumer-products-retail-latest-news/food-beverages-list/)\\n\\t\\t- [Furniture and Furnishings](/news-releases/consumer-products-retail-latest-news/furniture-and-furnishings-list/)\\n\\t\\t- [Home Improvement](/news-releases/consumer-products-retail-latest-news/home-improvements-list/)\\n\\t\\t- [Household, Consumer \\\\& Cosmetics](/news-releases/consumer-products-retail-latest-news/household-consumer-cosmetics-list/)\\n\\t\\t- [Household Products](/news-releases/consumer-products-retail-latest-news/household-products-list/)\\n\\t\\t- [Jewelry](/news-releases/consumer-products-retail-latest-news/jewelry-list/)\\n\\t\\t- [Non\\\\-Alcoholic Beverages](/news-releases/consumer-products-retail-latest-news/non-alcoholic-beverages-list/)\\n\\t\\t- [Office Products](/news-releases/consumer-products-retail-latest-news/office-products-list/)\\n\\t\\t- [Organic Food](/news-releases/consumer-products-retail-latest-news/organic-food-list/)\\n\\t\\t- [Product Recalls](/news-releases/consumer-products-retail-latest-news/product-recalls-list/)\\n\\t\\t- [Restaurants](/news-releases/consumer-products-retail-latest-news/restaurants-list/)\\n\\t\\t- [Retail](/news-releases/consumer-products-retail-latest-news/retail-list/)\\n\\t\\t- [Supermarkets](/news-releases/consumer-products-retail-latest-news/supermarkets-list/)\\n\\t\\t- [Toys](/news-releases/consumer-products-retail-latest-news/toys-list/)\\n\\t\\t- [Consumer Products \\\\& Retail Overview](/news-releases/consumer-products-retail-latest-news/)\\n\\t\\t--------------------------------------------------------------------------------------------\\n\\t\\t- [View All Consumer Products \\\\& Retail](/news-releases/consumer-products-retail-latest-news/consumer-products-retail-latest-news-list/)\\n\\t\\t--------------------------------------------------------------------------------------------------------------------------------------\\n\\t\\t- [Entertain\\xadment \\\\& Media](/news-releases/entertainment-media-latest-news/)\\n\\t\\t--------------------------------------------------------------------------\\n\\t\\t- [All Entertain\\xadment \\\\& Media](/news-releases/entertainment-media-latest-news/entertainment-media-latest-news-list/)\\n\\t\\t- [Advertising](/news-releases/entertainment-media-latest-news/advertising-list/)\\n\\t\\t- [Art](/news-releases/entertainment-media-latest-news/art-list/)\\n\\t\\t- [Books](/news-releases/entertainment-media-latest-news/books-list/)\\n\\t\\t- [Entertainment](/news-releases/entertainment-media-latest-news/entertainment-list/)\\n\\t\\t- [Film and Motion Picture](/news-releases/entertainment-media-latest-news/film-and-motion-picture-list/)\\n\\t\\t- [Magazines](/news-releases/entertainment-media-latest-news/magazines-list/)\\n\\t\\t- [Music](/news-releases/entertainment-media-latest-news/music-list/)\\n\\t\\t- [Publishing \\\\& Information Services](/news-releases/entertainment-media-latest-news/publishing-information-services-list/)\\n\\t\\t- [Radio \\\\& Podcast](/news-releases/entertainment-media-latest-news/radio-list/)\\n\\t\\t- [Television](/news-releases/entertainment-media-latest-news/television-list/)\\n\\t\\t- [Entertain\\xadment \\\\& Media Overview](/news-releases/entertainment-media-latest-news/)\\n\\t\\t-----------------------------------------------------------------------------------\\n\\t\\t- [View All Entertain\\xadment \\\\& Media](/news-releases/entertainment-media-latest-news/entertainment-media-latest-news-list/)\\n\\t\\t------------------------------------------------------------------------------------------------------------------------\\n\\t\\t- [Health](/news-releases/health-latest-news/)\\n\\t\\t--------------------------------------------\\n\\t\\t- [All Health](/news-releases/health-latest-news/health-latest-news-list/)\\n\\t\\t- [Biometrics](/news-releases/health-latest-news/biometrics-list/)\\n\\t\\t- [Biotechnology](/news-releases/health-latest-news/biotechnology-list/)\\n\\t\\t- [Clinical Trials \\\\& Medical Discoveries](/news-releases/health-latest-news/clinical-trials-medical-discoveries-list/)\\n\\t\\t- [Dentistry](/news-releases/health-latest-news/dentistry-list/)\\n\\t\\t- [FDA Approval](/news-releases/health-latest-news/fda-approval-list/)\\n\\t\\t- [Fitness/Wellness](/news-releases/health-latest-news/fitness-wellness-list/)\\n\\t\\t- [Health Care \\\\& Hospitals](/news-releases/health-latest-news/health-care-hospitals-list/)\\n\\t\\t- [Health Insurance](/news-releases/health-latest-news/health-insurance-list/)\\n\\t\\t- [Infection Control](/news-releases/health-latest-news/infection-control-list/)\\n\\t\\t- [International Medical Approval](/news-releases/health-latest-news/international-medical-approval-list/)\\n\\t\\t- [Medical Equipment](/news-releases/health-latest-news/medical-equipment-list/)\\n\\t\\t- [Medical Pharmaceuticals](/news-releases/health-latest-news/medical-pharmaceuticals-list/)\\n\\t\\t- [Mental Health](/news-releases/health-latest-news/mental-health-list/)\\n\\t\\t- [Pharmaceuticals](/news-releases/health-latest-news/pharmaceuticals-list/)\\n\\t\\t- [Supplementary Medicine](/news-releases/health-latest-news/supplementary-medicine-list/)\\n\\t\\t- [Health Overview](/news-releases/health-latest-news/)\\n\\t\\t-----------------------------------------------------\\n\\t\\t- [View All Health](/news-releases/health-latest-news/health-latest-news-list/)\\n\\t\\t-----------------------------------------------------------------------------\\n\\t\\t- [Sports](/news-releases/sports-latest-news/)\\n\\t\\t--------------------------------------------\\n\\t\\t- [All Sports](/news-releases/sports-latest-news/sports-latest-news-list/)\\n\\t\\t- [General Sports](/news-releases/sports-latest-news/general-sports-list/)\\n\\t\\t- [Outdoors, Camping \\\\& Hiking](/news-releases/sports-latest-news/outdoors-camping-hiking-list/)\\n\\t\\t- [Sporting Events](/news-releases/sports-latest-news/sporting-events-list/)\\n\\t\\t- [Sports Equipment \\\\& Accessories](/news-releases/sports-latest-news/sports-equipment-accessories-list/)\\n\\t\\t- [Sports Overview](/news-releases/sports-latest-news/)\\n\\t\\t-----------------------------------------------------\\n\\t\\t- [View All Sports](/news-releases/sports-latest-news/sports-latest-news-list/)\\n\\t\\t-----------------------------------------------------------------------------\\n\\t\\t- [Travel](/news-releases/travel-latest-news/)\\n\\t\\t--------------------------------------------\\n\\t\\t- [All Travel](/news-releases/travel-latest-news/travel-latest-news-list/)\\n\\t\\t- [Amusement Parks and Tourist Attractions](/news-releases/travel-latest-news/amusement-parks-and-tourist-attractions-list/)\\n\\t\\t- [Gambling \\\\& Casinos](/news-releases/travel-latest-news/gambling-casinos-list/)\\n\\t\\t- [Hotels and Resorts](/news-releases/travel-latest-news/hotels-and-resorts-list/)\\n\\t\\t- [Leisure \\\\& Tourism](/news-releases/travel-latest-news/leisure-tourism-list/)\\n\\t\\t- [Outdoors, Camping \\\\& Hiking](/news-releases/travel-latest-news/outdoors-camping-hiking-list/)\\n\\t\\t- [Passenger Aviation](/news-releases/travel-latest-news/passenger-aviation-list/)\\n\\t\\t- [Travel Industry](/news-releases/travel-latest-news/travel-industry-list/)\\n\\t\\t- [Travel Overview](/news-releases/travel-latest-news/)\\n\\t\\t-----------------------------------------------------\\n\\t\\t- [View All Travel](/news-releases/travel-latest-news/travel-latest-news-list/)\\n\\t\\t-----------------------------------------------------------------------------\\n* [Policy \\\\& Public Interest](# \"Policy & Public Interest\")\\n\\t+ - [Policy \\\\& Public Interest](/news-releases/policy-public-interest-latest-news/)\\n\\t\\t-------------------------------------------------------------------------------\\n\\t\\t- [All Policy \\\\& Public Interest](/news-releases/policy-public-interest-latest-news/policy-public-interest-latest-news-list/)\\n\\t\\t- [Advocacy Group Opinion](/news-releases/policy-public-interest-latest-news/advocacy-group-opinion-list/)\\n\\t\\t- [Animal Welfare](/news-releases/policy-public-interest-latest-news/animal-welfare-list/)\\n\\t\\t- [Congressional \\\\& Presidential Campaigns](/news-releases/policy-public-interest-latest-news/congressional-presidential-campaigns-list/)\\n\\t\\t- [Corporate Social Responsibility](/news-releases/policy-public-interest-latest-news/corporate-social-responsibility-list/)\\n\\t\\t- [Domestic Policy](/news-releases/policy-public-interest-latest-news/domestic-policy-list/)\\n\\t\\t- [Economic News, Trends, Analysis](/news-releases/policy-public-interest-latest-news/economic-news-trends-analysis-list/)\\n\\t\\t- [Education](/news-releases/policy-public-interest-latest-news/education-list/)\\n\\t\\t- [Environmental](/news-releases/policy-public-interest-latest-news/environmental-list/)\\n\\t\\t- [European Government](/news-releases/policy-public-interest-latest-news/european-government-list/)\\n\\t\\t- [FDA Approval](/news-releases/policy-public-interest-latest-news/fda-approval-list/)\\n\\t\\t- [Federal and State Legislation](/news-releases/policy-public-interest-latest-news/federal-and-state-legislation-list/)\\n\\t\\t- [Federal Executive Branch \\\\& Agency](/news-releases/policy-public-interest-latest-news/federal-executive-branch-agency-news-list/)\\n\\t\\t- [Foreign Policy \\\\& International Affairs](/news-releases/policy-public-interest-latest-news/foreign-policy-international-affairs-list/)\\n\\t\\t- [Homeland Security](/news-releases/policy-public-interest-latest-news/homeland-security-list/)', 1, 2)

[18] Observation: ToolResult

tool_call_id: call_n7uML2Wn5AcyWDONKRFCmRzT\n",
-       "kind: tool\n",
+       "1. **[Vulcan Materials Company (VMC) Company Profile & Facts](https://ca.finance.yahoo.com/quote/VMC/profile/)**\n",
+       "   - Vulcan Materials Company, together with its subsidiaries, produces and supplies construction aggregates primarily in the United States. It operates through four main segments.\n",
        "\n",
-       "
9714 characters ...('Title: \\n\\tVulcan Materials Company - News\\n\\n=======================\\nir@vmcmail.com\\n(205\\\\) 298\\\\-3220\\n\\n* [Overview](https://ir.vulcanmaterials.com/overview/default.aspx)\\n\\t+ [Why Invest](https://ir.vulcanmaterials.com/why-invest/default.aspx)\\n\\t+ [News](https://ir.vulcanmaterials.com/news/default.aspx)\\n\\t+ [Events \\\\& Presentations](https://ir.vulcanmaterials.com/events-and-presentations/default.aspx)\\n\\t+ [Stock Info](https://ir.vulcanmaterials.com/stock-info/default.aspx)\\n\\t\\t- [Stock Quote](/stock-info/default.aspx#stock-quote)\\n\\t\\t- [Stock Chart](/stock-info/default.aspx#stock-chart)\\n\\t\\t- [Historical Stock Quote](/stock-info/default.aspx#stock-historical)\\n\\t\\t- [Investment Calculator](/stock-info/default.aspx#calculator)\\n\\t\\t- [Transfer Agent](https://ir.vulcanmaterials.com/stock-info/Transfer-Agent/default.aspx)\\n\\t\\t- [Analyst Coverage](https://ir.vulcanmaterials.com/stock-info/analyst-coverage/default.aspx)\\n\\t+ [Financials](https://ir.vulcanmaterials.com/financials/quarterly-results/default.aspx)\\n\\t\\t- [Quarterly Results](https://ir.vulcanmaterials.com/financials/quarterly-results/default.aspx)\\n\\t\\t- [Annual Reports](https://ir.vulcanmaterials.com/financials/annual-reports/default.aspx)\\n\\t\\t- [SEC Filings](https://ir.vulcanmaterials.com/financials/sec-filings/default.aspx)\\n\\t+ [Governance](https://ir.vulcanmaterials.com/governance/governance-documents/default.aspx)\\n\\t\\t- [Governance Documents](https://ir.vulcanmaterials.com/governance/governance-documents/default.aspx)\\n\\t\\t- [Executive Management](https://ir.vulcanmaterials.com/governance/executive-management/default.aspx)\\n\\t\\t- [Board of Directors](https://ir.vulcanmaterials.com/governance/board-of-directors/default.aspx)\\n\\t\\t- [Committee Composition](https://ir.vulcanmaterials.com/governance/committee-composition/default.aspx)\\n\\t\\t- [Contact the Board](https://ir.vulcanmaterials.com/governance/contact-the-board/default.aspx)\\n\\t+ [Resources](https://ir.vulcanmaterials.com/resources/investor-faqs/default.aspx)\\n\\t\\t- [Investor FAQs](https://ir.vulcanmaterials.com/resources/investor-faqs/default.aspx)\\n\\t\\t- [Information Request Form](https://ir.vulcanmaterials.com/resources/information-request-form/default.aspx)\\n\\t\\t- [Investor Email Alerts](https://ir.vulcanmaterials.com/resources/investor-email-alerts/default.aspx)\\n\\t\\t- [Investor Contacts](https://ir.vulcanmaterials.com/resources/investor-contacts/default.aspx)\\n\\n[Skip to main content](#maincontent)\\n\\n[![Vulcan Company Logo](//s201.q4cdn.com/142563501/files/design/vulcan-logo.png)](https://www.vulcanmaterials.com/)\\n\\n* [About Vulcan](https://www.vulcanmaterials.com/about-vulcan)\\n\\n\\t+ [History](https://www.vulcanmaterials.com/about-vulcan/history)\\n\\t+ [Mission and Values](https://www.vulcanmaterials.com/about-vulcan/mission-and-values)\\n\\t+ [Executive Management](/governance/executive-management/default.aspx)\\n\\t+ [Corporate Office](https://www.vulcanmaterials.com/about-vulcan/corporate-office)\\n\\t+ [Industry Links](https://www.vulcanmaterials.com/about-vulcan/industry-links)\\n\\t+ [Careers](https://www.vulcanmaterials.com/careers)\\n* Construction Materials\\n\\n\\t+ [Product Sales](https://www.vulcanmaterials.com/construction-materials/product-sales)\\n\\t+ [Products and Services](https://www.vulcanmaterials.com/construction-materials/products-and-services)\\n\\t+ [Suppliers](https://www.vulcanmaterials.com/construction-materials/suppliers)\\n\\t+ [Facilities Map](https://www.vulcanmaterials.com/construction-materials/facilities-map)\\n\\t+ [Operating Groups](https://www.vulcanmaterials.com/construction-materials/operating-groups)\\n\\t+ [Product Calculators](https://www.vulcanmaterials.com/construction-materials/product-calculators)\\n\\t+ [Credit Applications](https://www.vulcanmaterials.com/construction-materials/credit-applications)\\n\\t+ [Safety Data Sheets](https://www.vulcanmaterials.com/construction-materials/safety-data-sheets)\\n\\t+ [Product Declaration](https://www.vulcanmaterials.com/construction-materials/product-declaration)\\n\\t+ [Facilities](https://www.vulcanmaterials.com/construction-materials/facilities)\\n* [Investor Relations](/overview)\\n* [Social Responsibility](https://csr.vulcanmaterials.com/)\\n\\n\\t+ [2023 Sustainability Report](https://csr.vulcanmaterials.com)\\n\\t+ [Safety \\\\& Health](https://www.vulcanmaterials.com/social-responsibility/safety-health)\\n\\t+ [Environmental Stewardship](https://www.vulcanmaterials.com/social-responsibility/environmental-stewardship)\\n\\t+ [People](https://www.vulcanmaterials.com/social-responsibility/people)\\n\\t+ [Community](https://www.vulcanmaterials.com/social-responsibility/community)\\n\\t+ [Governance](https://www.vulcanmaterials.com/social-responsibility/governance)\\n\\t+ [Teacher Center](https://www.vulcanmaterials.com/social-responsibility/teacher-center)\\n\\t+ [Vulcan Foundation](https://www.vulcanmaterials.com/social-responsibility/vulcan-foundation)\\n\\nNews\\n====\\n\\n* [Overview](https://ir.vulcanmaterials.com/overview/default.aspx)\\n\\t+ [Why Invest](https://ir.vulcanmaterials.com/why-invest/default.aspx)\\n\\t+ [News](https://ir.vulcanmaterials.com/news/default.aspx)\\n\\t+ [Events \\\\& Presentations](https://ir.vulcanmaterials.com/events-and-presentations/default.aspx)\\n\\t+ [Stock Info](https://ir.vulcanmaterials.com/stock-info/default.aspx)\\n\\t\\t- [Stock Quote](/stock-info/default.aspx#stock-quote)\\n\\t\\t- [Stock Chart](/stock-info/default.aspx#stock-chart)\\n\\t\\t- [Historical Stock Quote](/stock-info/default.aspx#stock-historical)\\n\\t\\t- [Investment Calculator](/stock-info/default.aspx#calculator)\\n\\t\\t- [Transfer Agent](https://ir.vulcanmaterials.com/stock-info/Transfer-Agent/default.aspx)\\n\\t\\t- [Analyst Coverage](https://ir.vulcanmaterials.com/stock-info/analyst-coverage/default.aspx)\\n\\t+ [Financials](https://ir.vulcanmaterials.com/financials/quarterly-results/default.aspx)\\n\\t\\t- [Quarterly Results](https://ir.vulcanmaterials.com/financials/quarterly-results/default.aspx)\\n\\t\\t- [Annual Reports](https://ir.vulcanmaterials.com/financials/annual-reports/default.aspx)\\n\\t\\t- [SEC Filings](https://ir.vulcanmaterials.com/financials/sec-filings/default.aspx)\\n\\t+ [Governance](https://ir.vulcanmaterials.com/governance/governance-documents/default.aspx)\\n\\t\\t- [Governance Documents](https://ir.vulcanmaterials.com/governance/governance-documents/default.aspx)\\n\\t\\t- [Executive Management](https://ir.vulcanmaterials.com/governance/executive-management/default.aspx)\\n\\t\\t- [Board of Directors](https://ir.vulcanmaterials.com/governance/board-of-directors/default.aspx)\\n\\t\\t- [Committee Composition](https://ir.vulcanmaterials.com/governance/committee-composition/default.aspx)\\n\\t\\t- [Contact the Board](https://ir.vulcanmaterials.com/governance/contact-the-board/default.aspx)\\n\\t+ [Resources](https://ir.vulcanmaterials.com/resources/investor-faqs/default.aspx)\\n\\t\\t- [Investor FAQs](https://ir.vulcanmaterials.com/resources/investor-faqs/default.aspx)\\n\\t\\t- [Information Request Form](https://ir.vulcanmaterials.com/resources/information-request-form/default.aspx)\\n\\t\\t- [Investor Email Alerts](https://ir.vulcanmaterials.com/resources/investor-email-alerts/default.aspx)\\n\\t\\t- [Investor Contacts](https://ir.vulcanmaterials.com/resources/investor-contacts/default.aspx)\\n\\nSelecting a year value will change the news content\\nSelect Year:\\n\\nLoading\\n\\n[![footer logo](//s201.q4cdn.com/142563501/files/design/vulcan-logo.png)](https://www.vulcanmaterials.com/)\\n### Investor Contacts\\n\\n[(205\\\\) 298\\\\-3220](tel:(205) 298-3220)\\n\\n[ir@vmcmail.com](mailto:ir@vmcmail.com)\\n\\n### Quick Links\\n\\n* [Quarterly Reports](https://ir.vulcanmaterials.com/financials/quarterly-results/default.aspx)\\n* [SEC Filings](https://ir.vulcanmaterials.com/financials/sec-filings/default.aspx)\\n* [Board of Directors](https://ir.vulcanmaterials.com/governance/board-of-directors/default.aspx)\\n* [Analyst Coverage](https://ir.vulcanmaterials.com/stock-info/analyst-coverage/default.aspx)\\n\\nEmail Alerts\\n------------\\n\\nTo opt\\\\-in for investor email alerts, please enter your email address in the field below and select at least one alert option. After submitting your request, you will receive an activation email to the requested email address. You must click the activation link in order to complete your subscription. You can sign up for additional alert options at any time.\\n\\nAt Vulcan, we promise to treat your data with respect and will not share your information with any third party. You can unsubscribe to any of the investor alerts you are subscribed to by visiting the ‘unsubscribe’ section below. If you experience any issues with this process, please contact us for further assistance.\\n\\n**By providing your email address below, you are providing consent to Vulcan to send you the requested Investor Email Alert updates.**\\n\\n\\\\* Required\\n\\n| Email Address \\\\* |\\n| --- |\\n\\nInvestor Alert Options\\n\\n| Investor Alert Options \\\\* |\\n| --- |\\n| | News | | --- | | Quarterly Reports | | Annual Reports | | SEC Filings | | End of Day Stock Quote | | Events \\\\& Presentations | |\\n\\n[Unsubscribe](/resources/investor-email-alerts/#unsubscribe)\\n\\nEmail Alert Sign Up Confirmation\\n--------------------------------\\n\\n* [Facebook](https://www.facebook.com/VulcanMaterialsCompany/)\\n* [Instagram](https://www.instagram.com/vulcanmaterialscompany/)\\n* [LinkedIn](https://www.linkedin.com/company/vulcan-materials-company/)\\n* [YouTube](https://www.youtube.com/user/VulcanCorporate/videos)\\n\\n* [Privacy Policy](https://www.vulcanmaterials.com/privacy-policy)\\n* [Cookies Policy](https://ir.vulcanmaterials.com/cookies-policy/default.aspx)\\n* [Terms of Use](https://www.vulcanmaterials.com/terms-of-use)', 1, 1)

[19] Observation: ToolResult

tool_call_id: call_coXqXN9CT67Wb0T1aP30vM1z\n",
-       "kind: tool\n",
+       "2. **[Vulcan Materials Co - Company Profile](https://www.globaldata.com/company-profile/vulcan-materials-company/)**\n",
+       "   - Vulcan Materials Co (Vulcan) is a manufacturer of construction materials. It sells crushed stone, sand, gravel, and aggregates-based building materials.\n",
        "\n",
-       "
32994 characters ...('Title: Vulcan Materials Company (VMC) Latest Press Releases & Corporate News - Yahoo Finance\\n=======================\\n### [News](https://www.yahoo.com/)\\n\\n* [Today\\'s news](https://www.yahoo.com/news/)\\n* [US](https://www.yahoo.com/news/us/)\\n* [Politics](https://www.yahoo.com/news/politics/)\\n* [World](https://www.yahoo.com/news/world/)\\n* [Tech](https://www.yahoo.com/tech/)\\n\\t+\\n\\t+ [Reviews and deals](https://www.yahoo.com/tech/reviews-deals/)\\n\\t+ [Audio](https://www.yahoo.com/tech/audio/)\\n\\t+ [Computing](https://www.yahoo.com/tech/computing/)\\n\\t+ [Gaming](https://www.yahoo.com/tech/gaming/)\\n\\t+ [Health](https://www.yahoo.com/tech/health/)\\n\\t+ [Home](https://www.yahoo.com/tech/home/)\\n\\t+ [Phones](https://www.yahoo.com/tech/phones/)\\n\\t+ [Science](https://www.yahoo.com/tech/science/)\\n\\t+ [TVs](https://www.yahoo.com/tech/tvs/)\\n* [Climate change](https://www.yahoo.com/tagged/climate-change/)\\n* [Health](https://www.yahoo.com/news/health/)\\n* [Science](https://www.yahoo.com/news/science/)\\n* [2024 election](https://www.yahoo.com/elections/)\\n* [Originals](https://news.yahoo.com/originals/)\\n\\t+\\n\\t+ [The 360](https://www.yahoo.com/news/tagged/360/)\\n* [Newsletters](https://news.yahoo.com/newsletters/)\\n ### [Life](https://www.yahoo.com/lifestyle/)\\n\\n* [Health](https://www.yahoo.com/lifestyle/tagged/health/)\\n\\t+\\n\\t+ [COVID\\\\-19](https://www.yahoo.com/lifestyle/tagged/covid/)\\n\\t+ [Fall allergies](https://www.yahoo.com/lifestyle/fall-allergies/)\\n\\t+ [Health news](https://www.yahoo.com/lifestyle/tagged/do-i-need-to-worry/)\\n\\t+ [Mental health](https://www.yahoo.com/lifestyle/tagged/mental-health/)\\n\\t+ [Relax](https://www.yahoo.com/lifestyle/relax/)\\n\\t+ [Sexual health](https://www.yahoo.com/lifestyle/tagged/sexual-health/)\\n\\t+ [Studies](https://www.yahoo.com/lifestyle/tagged/study/)\\n\\t+ [The Unwind](https://www.yahoo.com/lifestyle/tagged/the-unwind/)\\n* [Parenting](https://www.yahoo.com/lifestyle/tagged/parenting/)\\n\\t+\\n\\t+ [Family health](https://www.yahoo.com/lifestyle/tagged/family-health/)\\n\\t+ [So mini ways](https://www.yahoo.com/lifestyle/tagged/so-mini-ways/)\\n* [Style and beauty](https://www.yahoo.com/lifestyle/style-beauty/)\\n\\t+\\n\\t+ [It Figures](https://www.yahoo.com/lifestyle/tagged/it-figures/)\\n\\t+ [Unapologetically](https://www.yahoo.com/lifestyle/tagged/unapologetically/)\\n* [Horoscopes](https://www.yahoo.com/lifestyle/horoscope/)\\n* [Shopping](https://shopping.yahoo.com/)\\n\\t+\\n\\t+ [Buying guides](https://www.yahoo.com/lifestyle/tagged/best-of/)\\n* [Food](https://www.yahoo.com/lifestyle/tagged/food/)\\n* [Travel](https://www.yahoo.com/lifestyle/tagged/travel/)\\n* [Autos](https://autos.yahoo.com/)\\n* [Prime Day](https://www.yahoo.com/lifestyle/amazon-october-prime-day-2024-early-deals-and-everything-to-know-about-the-big-deal-days-sale-143607967.html)\\n* [Gift ideas](https://www.yahoo.com/topics/gift-ideas/)\\n* [Buying guides](https://www.yahoo.com/topics/buying-guides/)\\n ### [Entertainment](https://www.yahoo.com/entertainment/)\\n\\n* [Celebrity](https://www.yahoo.com/entertainment/celebrity/)\\n* [TV](https://www.yahoo.com/entertainment/tv/)\\n* [Movies](https://www.yahoo.com/entertainment/movies/)\\n* [Music](https://www.yahoo.com/entertainment/music/)\\n* [How to Watch](https://www.yahoo.com/entertainment/tagged/how-to-watch/)\\n* [Interviews](https://www.yahoo.com/entertainment/tagged/interviews/)\\n* [Videos](https://www.yahoo.com/entertainment/tagged/videos/)\\n* [Shopping](https://www.yahoo.com/lifestyle/tagged/shopping/)\\n ### [Finance](https://finance.yahoo.com/)\\n\\n* [My Portfolio](https://finance.yahoo.com/portfolios)\\n* [News](https://finance.yahoo.com/news/)\\n\\t+\\n\\t+ [Latest News](https://finance.yahoo.com/topic/latest-news/)\\n\\t+ [Stock Market](https://finance.yahoo.com/topic/stock-market-news/)\\n\\t+ [Originals](https://finance.yahoo.com/topic/yahoo-finance-originals/)\\n\\t+ [The Morning Brief](https://finance.yahoo.com/topic/morning-brief/)\\n\\t+ [Economics](https://finance.yahoo.com/topic/economic-news/)\\n\\t+ [Housing](https://finance.yahoo.com/topic/housing-market/)\\n\\t+ [Earnings](https://finance.yahoo.com/topic/earnings/)\\n\\t+ [Tech](https://finance.yahoo.com/topic/tech/)\\n\\t+ [Crypto](https://finance.yahoo.com/topic/crypto/)\\n\\t+ [Biden Economy](https://finance.yahoo.com/bidenomics/)\\n* [Markets](https://finance.yahoo.com/markets)\\n\\t+\\n\\t+ [Stocks: Most Actives](https://finance.yahoo.com/markets/stocks/most-active/)\\n\\t+ [Stocks: Gainers](https://finance.yahoo.com/markets/stocks/gainers/)\\n\\t+ [Stocks: Losers](https://finance.yahoo.com/markets/stocks/losers/)\\n\\t+ [Trending Tickers](https://finance.yahoo.com/markets/stocks/trending/)\\n\\t+ [Futures](https://finance.yahoo.com/markets/commodities/)\\n\\t+ [World Indices](https://finance.yahoo.com/markets/world-indices/)\\n\\t+ [US Treasury Bonds Rates](https://finance.yahoo.com/markets/bonds/)\\n\\t+ [Currencies](https://finance.yahoo.com/markets/currencies/)\\n\\t+ [Crypto](https://finance.yahoo.com/markets/crypto/all/)\\n\\t+ [Top ETFs](https://finance.yahoo.com/markets/etfs/top/)\\n\\t+ [Top Mutual Funds](https://finance.yahoo.com/markets/mutualfunds/top/)\\n\\t+ [Options: Highest Open Interest](https://finance.yahoo.com/markets/options/highest-open-interest/)\\n\\t+ [Options: Highest Implied Volatility](https://finance.yahoo.com/markets/options/highest-implied-volatility/)\\n\\t+ [Sectors](https://finance.yahoo.com/sectors/)\\n\\t+ [Basic Materials](https://finance.yahoo.com/sectors/basic-materials/)\\n\\t+ [Communication Services](https://finance.yahoo.com/sectors/communication-services/)\\n\\t+ [Consumer Cyclical](https://finance.yahoo.com/sectors/consumer-cyclical/)\\n\\t+ [Consumer Defensive](https://finance.yahoo.com/sectors/consumer-defensive/)\\n\\t+ [Energy](https://finance.yahoo.com/sectors/energy/)\\n\\t+ [Financial Services](https://finance.yahoo.com/sectors/financial-services/)\\n\\t+ [Healthcare](https://finance.yahoo.com/sectors/healthcare/)\\n\\t+ [Industrials](https://finance.yahoo.com/sectors/industrials/)\\n\\t+ [Real Estate](https://finance.yahoo.com/sectors/real-estate/)\\n\\t+ [Technology](https://finance.yahoo.com/sectors/technology/)\\n\\t+ [Utilities](https://finance.yahoo.com/sectors/utilities/)\\n* [Research](https://finance.yahoo.com/screener/)\\n\\t+\\n\\t+ [Screeners](https://finance.yahoo.com/screener/)\\n\\t+ [Watchlists](https://finance.yahoo.com/watchlists/)\\n\\t+ [Calendar](https://finance.yahoo.com/calendar/)\\n\\t+ [Stock Comparison](https://finance.yahoo.com/compare/)\\n\\t+ [Advanced Chart](https://finance.yahoo.com/chart/%5EGSPC/)\\n\\t+ [Currency Converter](https://finance.yahoo.com/currency-converter/)\\n* [Personal Finance](https://finance.yahoo.com/personal-finance/)\\n\\t+\\n\\t+ [Credit Cards](https://finance.yahoo.com/personal-finance/credit-cards/)\\n\\t+ [Balance Transfer Cards](https://finance.yahoo.com/personal-finance/best-credit-card-for-balance-transfer-213356438.html)\\n\\t+ [Cash\\\\-back Cards](https://finance.yahoo.com/personal-finance/best-cash-back-credit-cards-220845639.html)\\n\\t+ [Rewards Cards](https://finance.yahoo.com/personal-finance/best-rewards-credit-card-203736692.html)\\n\\t+ [Travel Cards](https://finance.yahoo.com/personal-finance/best-travel-credit-card-203950032.html)\\n\\t+ [Credit Card Offers](https://finance.yahoo.com/personal-finance/best-credit-card-sign-up-bonus-212458984.html)\\n\\t+ [Banking](https://finance.yahoo.com/personal-finance/banking/)\\n\\t+ [CD Rates](https://finance.yahoo.com/personal-finance/find-best-cd-rates-165749654.html)\\n\\t+ [Best HYSA](https://finance.yahoo.com/personal-finance/best-high-yield-savings-account-203140689.html)\\n\\t+ [Best Free Checking](https://finance.yahoo.com/personal-finance/best-free-checking-accounts-195709452.html)\\n\\t+ [Student Loans](https://finance.yahoo.com/personal-finance/student-loans/)\\n\\t+ [Personal Loans](https://finance.yahoo.com/personal-finance/personal-loans/)\\n\\t+ [Insurance](https://finance.yahoo.com/personal-finance/insurance/)\\n\\t+ [Car insurance](https://finance.yahoo.com/personal-finance/cheap-car-insurance-152307402.html)\\n\\t+ [Mortgages](https://finance.yahoo.com/personal-finance/mortgages/)\\n\\t+ [Mortgage Refinancing](https://finance.yahoo.com/personal-finance/refinance-mortgage-162831396.html)\\n\\t+ [Mortgage Calculator](https://finance.yahoo.com/personal-finance/calculators/mortgage-calculator/)\\n\\t+ [Taxes](https://finance.yahoo.com/taxes/)\\n* [Videos](https://finance.yahoo.com/videos/)\\n\\t+\\n\\t+ [Latest News](https://finance.yahoo.com/videos/latest/)\\n\\t+ [Editor\\'s Picks](https://finance.yahoo.com/videos/editor-picks/)\\n\\t+ [Investing Insights](https://finance.yahoo.com/videos/investing-insights/)\\n\\t+ [Trending Stocks](https://finance.yahoo.com/videos/trending-stocks/)\\n\\t+ [All Shows](https://finance.yahoo.com/videos/series/)\\n\\t+ [Morning Brief](https://finance.yahoo.com/videos/series/morning-brief/)\\n\\t+ [Opening Bid](https://finance.yahoo.com/videos/series/opening-bid/)\\n\\t+ [Wealth](https://finance.yahoo.com/videos/series/wealth/)\\n\\t+ [ETF Report](https://finance.yahoo.com/topic/etf-report/)\\n ### [Sports](https://sports.yahoo.com/)\\n\\n* [Fantasy](https://sports.yahoo.com/fantasy/)\\n\\t+\\n\\t+ [News](https://sports.yahoo.com/fantasy/news/)\\n\\t+ [Fantasy football](https://football.fantasysports.yahoo.com/)\\n\\t+ [Best Ball](https://bestball.fantasysports.yahoo.com/)\\n\\t+ [Pro Pick \\'Em](https://football.fantasysports.yahoo.com/pickem)\\n\\t+ [College Pick \\'Em](https://football.fantasysports.yahoo.com/college)\\n\\t+ [Fantasy baseball](https://baseball.fantasysports.yahoo.com/)\\n\\t+ [Fantasy hockey](https://hockey.fantasysports.yahoo.com/)\\n\\t+ [Fantasy basketball](https://basketball.fantasysports.yahoo.com/)\\n\\t+ [Download the app](https://sports.yahoo.com/fantasy/mobile/)\\n* [Daily fantasy](https://sports.yahoo.com/dailyfantasy/)\\n* [NFL](https://sports.yahoo.com/nfl/)\\n\\t+\\n\\t+ [News](https://sports.yahoo.com/nfl/news/)\\n\\t+ [Scores and schedules](https://sports.yahoo.com/nfl/scoreboard/)\\n\\t+ [Standings](https://sports.yahoo.com/nfl/standings/)\\n\\t+ [Stats](https://sports.yahoo.com/nfl/stats/)\\n\\t+ [Teams](https://sports.yahoo.com/nfl/teams/)\\n\\t+ [Players](https://sports.yahoo.com/nfl/players/)\\n\\t+ [Drafts](https://sports.yahoo.com/nfl/draft/)\\n\\t+ [Injuries](https://sports.yahoo.com/nfl/injuries/)\\n\\t+ [Odds](https://sports.yahoo.com/nfl/odds/)\\n\\t+ [Super Bowl](https://sports.yahoo.com/nfl/topic/super-bowl/)\\n\\t+ [GameChannel](https://sports.yahoo.com/nfl/gamechannel/)\\n\\t+ [Videos](https://sports.yahoo.com/videos/nfl/)\\n* [MLB](https://sports.yahoo.com/mlb/)\\n\\t+\\n\\t+ [News](https://sports.yahoo.com/mlb/news/)\\n\\t+ [Scores and schedules](https://sports.yahoo.com/mlb/scoreboard/)\\n\\t+ [Standings](https://sports.yahoo.com/mlb/standings/)\\n\\t+ [Stats](https://sports.yahoo.com/mlb/stats/)\\n\\t+ [Teams](https://sports.yahoo.com/mlb/teams/)\\n\\t+ [Players](https://sports.yahoo.com/mlb/players/)\\n\\t+ [Odds](https://sports.yahoo.com/mlb/odds/)\\n\\t+ [Videos](https://sports.yahoo.com/videos/mlb/)\\n\\t+ [World Baseball Classic](https://sports.yahoo.com/mlb/world-baseball-classic/)\\n* [NBA](https://sports.yahoo.com/nba/)\\n\\t+\\n\\t+ [News](https://sports.yahoo.com/nba/news/)\\n\\t+ [Draft](https://sports.yahoo.com/nba/draft/)\\n\\t+ [Scores and schedules](https://sports.yahoo.com/nba/scoreboard/)\\n\\t+ [Standings](https://sports.yahoo.com/nba/standings/)\\n\\t+ [Stats](https://sports.yahoo.com/nba/stats/)\\n\\t+ [Teams](https://sports.yahoo.com/nba/teams/)\\n\\t+ [Players](https://sports.yahoo.com/nba/players/)\\n\\t+ [Injuries](https://sports.yahoo.com/nba/injuries/)\\n\\t+ [Videos](https://sports.yahoo.com/videos/nba/)\\n\\t+ [Odds](https://sports.yahoo.com/nba/odds/)\\n\\t+ [Playoffs](https://sports.yahoo.com/nba/playoffs/)\\n* [NHL](https://sports.yahoo.com/nhl/)\\n\\t+\\n\\t+ [News](https://sports.yahoo.com/nhl/news/)\\n\\t+ [Scores and schedules](https://sports.yahoo.com/nhl/scoreboard/)\\n\\t+ [Standings](https://sports.yahoo.com/nhl/standings/)\\n\\t+ [Stats](https://sports.yahoo.com/nhl/stats/)\\n\\t+ [Teams](https://sports.yahoo.com/nhl/teams/)\\n\\t+ [Players](https://sports.yahoo.com/nhl/players/)\\n\\t+ [Odds](https://sports.yahoo.com/nhl/odds/)\\n\\t+ [Playoffs](https://sports.yahoo.com/nhl/stanley-cup-playoffs/)\\n* [Soccer](https://sports.yahoo.com/soccer/)\\n\\t+\\n\\t+ [News](https://sports.yahoo.com/soccer/news/)\\n\\t+ [Scores and schedules](https://sports.yahoo.com/soccer/scoreboard/)\\n\\t+ [Premier League](https://sports.yahoo.com/soccer/premier-league/)\\n\\t+ [MLS](https://sports.yahoo.com/soccer/mls/)\\n\\t+ [NWSL](https://sports.yahoo.com/soccer/nwsl/)\\n\\t+ [Liga MX](https://sports.yahoo.com/soccer/ligamx-clausura/)\\n\\t+ [CONCACAF League](https://sports.yahoo.com/soccer/concacaf-league/)\\n\\t+ [Champions League](https://sports.yahoo.com/soccer/champions-league/)\\n\\t+ [La Liga](https://sports.yahoo.com/soccer/la-liga/)\\n\\t+ [Serie A](https://sports.yahoo.com/soccer/serie-a/)\\n\\t+ [Bundesliga](https://sports.yahoo.com/soccer/bundesliga/)\\n\\t+ [Ligue 1](https://sports.yahoo.com/soccer/ligue-1/)\\n\\t+ [World Cup](https://sports.yahoo.com/soccer/world-cup/)\\n* [College football](https://sports.yahoo.com/college-football/)\\n\\t+\\n\\t+ [News](https://sports.yahoo.com/college-football/news/)\\n\\t+ [Scores and schedules](https://sports.yahoo.com/college-football/scoreboard/)\\n\\t+ [Standings](https://sports.yahoo.com/college-football/standings/)\\n\\t+ [Rankings](https://sports.yahoo.com/college-football/rankings/)\\n\\t+ [Stats](https://sports.yahoo.com/college-football/stats/)\\n\\t+ [Teams](https://sports.yahoo.com/college-football/teams/)\\n* Show all\\n\\t+\\n\\t+ [MMA](https://sports.yahoo.com/mma/)\\n\\t+ [WNBA](https://sports.yahoo.com/wnba/)\\n\\t+ [Sportsbook](https://sports.yahoo.com/sportsbook/)\\n\\t+ [NCAAF](https://sports.yahoo.com/college-football/)\\n\\t+ [Tennis](https://sports.yahoo.com/tennis/)\\n\\t+ [Golf](https://sports.yahoo.com/golf/)\\n\\t+ [NASCAR](https://sports.yahoo.com/motorsports/nascar/)\\n\\t+ [NCAAB](https://sports.yahoo.com/college-basketball/)\\n\\t+ [NCAAW](https://sports.yahoo.com/college-womens-basketball/)\\n\\t+ [Boxing](https://sports.yahoo.com/boxing/)\\n\\t+ [USFL](https://sports.yahoo.com/usfl/)\\n\\t+ [Cycling](https://sports.yahoo.com/cycling/)\\n\\t+ [Motorsports](https://sports.yahoo.com/motorsports/)\\n\\t+ [Olympics](https://sports.yahoo.com/olympics/beijing-2022/)\\n\\t+ [Horse racing](https://sports.yahoo.com/horse-racing/)\\n\\t+ [GameChannel](https://sports.yahoo.com/mlb/gamechannel/)\\n\\t+ [Rivals](https://n.rivals.com/)\\n\\t+ [Newsletters](https://sports.yahoo.com/newsletters/)\\n\\t+ [Podcasts](https://sports.yahoo.com/podcasts/)\\n\\t+ [Videos](https://sports.yahoo.com/videos/)\\n\\t+ [RSS](https://sports.yahoo.com/syndication/)\\n\\t+ [Jobs](https://sports.yahoo.com/jobs/)\\n\\t+ [Help](https://help.yahoo.com/kb/sports-news)\\n\\t+ [World Cup](https://sports.yahoo.com/soccer/world-cup/)\\n\\t+ [More news](https://sports.yahoo.com/news/)\\n ### New on Yahoo\\n\\n* [Games](https://www.yahoo.com/games/)\\n* [Tech](https://www.yahoo.com/tech/)\\n * [Terms](https://guce.yahoo.com/terms?locale=en-US)\\n* [Privacy](https://guce.yahoo.com/privacy-policy?locale=en-US)\\n* [Privacy \\\\& Cookie Settings](https://guce.yahoo.com/privacy-settings?locale=en-US)\\n* [Feedback](https://yahoo.uservoice.com/forums/952723-finance-b3)\\n\\n © 2024 All rights reserved. [About our ads](https://legal.yahoo.com/us/en/yahoo/privacy/adinfo/index.html) [Advertising](https://www.adtech.yahooinc.com/advertising/solutions) [Careers](https://www.yahooinc.com/careers/) Yahoo Finance\\n=============\\n\\n [Yahoo Finance](https://finance.yahoo.com/) Search query Select edition * [USEnglish](https://www.yahoo.com/?p=dnr)\\n* [US y LATAMEspañol](https://espanol.yahoo.com/?p=dnr)\\n* [AustraliaEnglish](https://au.yahoo.com/?p=dnr)\\n* [CanadaEnglish](https://ca.yahoo.com/?p=dnr)\\n* [CanadaFrançais](https://qc.yahoo.com/?p=dnr)\\n* [DeutschlandDeutsch](https://de.yahoo.com/?p=dnr)\\n* [FranceFrançais](https://fr.yahoo.com/?p=dnr)\\n* [香港繁中](https://hk.yahoo.com/?p=dnr)\\n* [MalaysiaEnglish](https://malaysia.yahoo.com/?p=dnr)\\n* [New ZealandEnglish](https://nz.yahoo.com/?p=dnr)\\n* [SingaporeEnglish](https://sg.yahoo.com/?p=dnr)\\n* [台灣繁中](https://tw.yahoo.com/?p=dnr)\\n* [UKEnglish](https://uk.yahoo.com/?p=dnr)\\n * [News](https://www.yahoo.com/)\\n* [Finance](https://finance.yahoo.com/)\\n* [Sports](https://sports.yahoo.com/)\\n* More\\n\\t+ [News](https://www.yahoo.com/)\\n\\t\\t- [Today\\'s news](https://www.yahoo.com/news/)\\n\\t\\t- [US](https://www.yahoo.com/news/us/)\\n\\t\\t- [Politics](https://www.yahoo.com/news/politics/)\\n\\t\\t- [World](https://www.yahoo.com/news/world/)\\n\\t\\t- [Weather](https://www.yahoo.com/news/weather/)\\n\\t\\t- [Climate change](https://yahoo.com/tagged/climate-change/)\\n\\t\\t- [Health](https://www.yahoo.com/news/health/)\\n\\t\\t- [Science](https://www.yahoo.com/news/science/)\\n\\t\\t- [2024 election](https://www.yahoo.com/election/)\\n\\t\\t- [Originals](https://www.yahoo.com/news/originals/)\\n\\t\\t- [Newsletters](https://news.yahoo.com/newsletters/)\\n\\t+ [Life](https://www.yahoo.com/lifestyle/)\\n\\t\\t- [Health](https://www.yahoo.com/lifestyle/tagged/health/)\\n\\t\\t- [Parenting](https://www.yahoo.com/lifestyle/tagged/parenting/)\\n\\t\\t- [Style and beauty](https://www.yahoo.com/lifestyle/style-beauty/)\\n\\t\\t- [Horoscopes](https://www.yahoo.com/lifestyle/horoscope/)\\n\\t\\t- [Shopping](https://shopping.yahoo.com)\\n\\t\\t- [Food](https://www.yahoo.com/lifestyle/tagged/food/)\\n\\t\\t- [Travel](https://www.yahoo.com/lifestyle/tagged/travel/)\\n\\t\\t- [Autos](https://autos.yahoo.com/)\\n\\t\\t- [Prime Day](https://www.yahoo.com/lifestyle/amazon-october-prime-day-2024-early-deals-and-everything-to-know-about-the-big-deal-days-sale-143607967.html)\\n\\t\\t- [Gift ideas](https://www.yahoo.com/topics/gift-ideas/)\\n\\t\\t- [Buying guides](https://www.yahoo.com/topics/buying-guides/)\\n\\t+ [Entertainment](https://www.yahoo.com/entertainment/)\\n\\t\\t- [Celebrity](https://www.yahoo.com/entertainment/celebrity/)\\n\\t\\t- [TV](https://www.yahoo.com/entertainment/tv/)\\n\\t\\t- [Movies](https://www.yahoo.com/entertainment/movies/)\\n\\t\\t- [Music](https://www.yahoo.com/entertainment/music/)\\n\\t\\t- [How to watch](https://www.yahoo.com/entertainment/tagged/how-to-watch/)\\n\\t\\t- [Interviews](https://www.yahoo.com/entertainment/tagged/interviews/)\\n\\t\\t- [Videos](https://www.yahoo.com/entertainment/tagged/videos/)\\n\\t\\t- [Shopping](https://www.yahoo.com/lifestyle/tagged/shopping/)\\n\\t+ [Finance](https://finance.yahoo.com/)\\n\\t\\t- [My portfolio](https://finance.yahoo.com/portfolios/)\\n\\t\\t- [Watchlists](https://finance.yahoo.com/watchlists/)\\n\\t\\t- [Markets](https://finance.yahoo.com/calendar/)\\n\\t\\t- [News](https://finance.yahoo.com/news/)\\n\\t\\t- [Videos](https://finance.yahoo.com/videos/)\\n\\t\\t- [Screeners](https://finance.yahoo.com/screener/)\\n\\t\\t- [Personal finance](https://finance.yahoo.com/topic/personal-finance/)\\n\\t\\t- [Crypto](https://finance.yahoo.com/crypto/)\\n\\t\\t- [Industries](https://finance.yahoo.com/screener/predefined/ms_basic_materials/)\\n\\t+ [Sports](https://sports.yahoo.com/)\\n\\t\\t- [Fantasy](https://sports.yahoo.com/fantasy/)\\n\\t\\t- [NFL](https://sports.yahoo.com/nfl/)\\n\\t\\t- [NBA](https://sports.yahoo.com/nba/)\\n\\t\\t- [MLB](https://sports.yahoo.com/mlb/)\\n\\t\\t- [NHL](https://sports.yahoo.com/nhl/)\\n\\t\\t- [College football](https://sports.yahoo.com/college-football/)\\n\\t\\t- [College basketball](https://sports.yahoo.com/college-basketball/)\\n\\t\\t- [Soccer](https://sports.yahoo.com/soccer/)\\n\\t\\t- [MMA](https://sports.yahoo.com/mma/)\\n\\t\\t- [Yahoo Sports AM](https://sports.yahoo.com/newsletters/yahoo-sports-am/)\\n\\t+ - New on Yahoo\\n\\t\\t\\t* [Games](https://www.yahoo.com/games/)\\n\\t\\t\\t* [Tech](https://www.yahoo.com/tech/)\\n\\t\\t- [Selected edition](https://www.yahoo.com/everything/world/) USEnglish\\n [Mail](https://mail.yahoo.com/) [Sign in](https://login.yahoo.com/?.lang=en-US&src=finance) * [My Portfolio](https://finance.yahoo.com/portfolios)\\n* [News](https://finance.yahoo.com/news/)\\n\\t+ [Latest News](https://finance.yahoo.com/topic/latest-news/)\\n\\t+ [Stock Market](https://finance.yahoo.com/topic/stock-market-news/)\\n\\t+ [Originals](https://finance.yahoo.com/topic/yahoo-finance-originals/)\\n\\t+ [The Morning Brief](https://finance.yahoo.com/topic/morning-brief/)\\n\\t+ [Economics](https://finance.yahoo.com/topic/economic-news/)\\n\\t+ [Housing](https://finance.yahoo.com/topic/housing-market/)\\n\\t+ [Earnings](https://finance.yahoo.com/topic/earnings/)\\n\\t+ [Tech](https://finance.yahoo.com/topic/tech/)\\n\\t+ [Crypto](https://finance.yahoo.com/topic/crypto/)\\n\\t+ [Biden Economy](https://finance.yahoo.com/bidenomics/)\\n* [Markets](https://finance.yahoo.com/markets)\\n\\t+ [Stocks: Most Actives](https://finance.yahoo.com/markets/stocks/most-active/)\\n\\t+ [Stocks: Gainers](https://finance.yahoo.com/markets/stocks/gainers/)\\n\\t+ [Stocks: Losers](https://finance.yahoo.com/markets/stocks/losers/)\\n\\t+ [Trending Tickers](https://finance.yahoo.com/markets/stocks/trending/)\\n\\t+ [Futures](https://finance.yahoo.com/markets/commodities/)\\n\\t+ [World Indices](https://finance.yahoo.com/markets/world-indices/)\\n\\t+ [US Treasury Bonds Rates](https://finance.yahoo.com/markets/bonds/)\\n\\t+ [Currencies](https://finance.yahoo.com/markets/currencies/)\\n\\t+ [Crypto](https://finance.yahoo.com/markets/crypto/all/)\\n\\t+ [Top ETFs](https://finance.yahoo.com/markets/etfs/top/)\\n\\t+ [Top Mutual Funds](https://finance.yahoo.com/markets/mutualfunds/top/)\\n\\t+ [Options: Highest Open Interest](https://finance.yahoo.com/markets/options/highest-open-interest/)\\n\\t+ [Options: Highest Implied Volatility](https://finance.yahoo.com/markets/options/highest-implied-volatility/)\\n\\t+ [Sectors](https://finance.yahoo.com/sectors/)\\n\\t+ [Basic Materials](https://finance.yahoo.com/sectors/basic-materials/)\\n\\t+ [Communication Services](https://finance.yahoo.com/sectors/communication-services/)\\n\\t+ [Consumer Cyclical](https://finance.yahoo.com/sectors/consumer-cyclical/)\\n\\t+ [Consumer Defensive](https://finance.yahoo.com/sectors/consumer-defensive/)\\n\\t+ [Energy](https://finance.yahoo.com/sectors/energy/)\\n\\t+ [Financial Services](https://finance.yahoo.com/sectors/financial-services/)\\n\\t+ [Healthcare](https://finance.yahoo.com/sectors/healthcare/)\\n\\t+ [Industrials](https://finance.yahoo.com/sectors/industrials/)\\n\\t+ [Real Estate](https://finance.yahoo.com/sectors/real-estate/)\\n\\t+ [Technology](https://finance.yahoo.com/sectors/technology/)\\n\\t+ [Utilities](https://finance.yahoo.com/sectors/utilities/)\\n* [Research](https://finance.yahoo.com/screener/)\\n\\t+ [Screeners](https://finance.yahoo.com/screener/)\\n\\t+ [Watchlists](https://finance.yahoo.com/watchlists/)\\n\\t+ [Calendar](https://finance.yahoo.com/calendar/)\\n\\t+ [Stock Comparison](https://finance.yahoo.com/compare/)\\n\\t+ [Advanced Chart](https://finance.yahoo.com/chart/%5EGSPC/)\\n\\t+ [Currency Converter](https://finance.yahoo.com/currency-converter/)\\n* [Personal Finance](https://finance.yahoo.com/personal-finance/)\\n\\t+ [Credit Cards](https://finance.yahoo.com/personal-finance/credit-cards/)\\n\\t+ [Balance Transfer Cards](https://finance.yahoo.com/personal-finance/best-credit-card-for-balance-transfer-213356438.html)\\n\\t+ [Cash\\\\-back Cards](https://finance.yahoo.com/personal-finance/best-cash-back-credit-cards-220845639.html)\\n\\t+ [Rewards Cards](https://finance.yahoo.com/personal-finance/best-rewards-credit-card-203736692.html)\\n\\t+ [Travel Cards](https://finance.yahoo.com/personal-finance/best-travel-credit-card-203950032.html)\\n\\t+ [Credit Card Offers](https://finance.yahoo.com/personal-finance/best-credit-card-sign-up-bonus-212458984.html)\\n\\t+ [Banking](https://finance.yahoo.com/personal-finance/banking/)\\n\\t+ [CD Rates](https://finance.yahoo.com/personal-finance/find-best-cd-rates-165749654.html)\\n\\t+ [Best HYSA](https://finance.yahoo.com/personal-finance/best-high-yield-savings-account-203140689.html)\\n\\t+ [Best Free Checking](https://finance.yahoo.com/personal-finance/best-free-checking-accounts-195709452.html)\\n\\t+ [Student Loans](https://finance.yahoo.com/personal-finance/student-loans/)\\n\\t+ [Personal Loans](https://finance.yahoo.com/personal-finance/personal-loans/)\\n\\t+ [Insurance](https://finance.yahoo.com/personal-finance/insurance/)\\n\\t+ [Car insurance](https://finance.yahoo.com/personal-finance/cheap-car-insurance-152307402.html)\\n\\t+ [Mortgages](https://finance.yahoo.com/personal-finance/mortgages/)\\n\\t+ [Mortgage Refinancing](https://finance.yahoo.com/personal-finance/refinance-mortgage-162831396.html)\\n\\t+ [Mortgage Calculator](https://finance.yahoo.com/personal-finance/calculators/mortgage-calculator/)\\n\\t+ [Taxes](https://finance.yahoo.com/taxes/)\\n* [Videos](https://finance.yahoo.com/videos/)\\n\\t+ [Latest News](https://finance.yahoo.com/videos/latest/)\\n\\t+ [Editor\\'s Picks](https://finance.yahoo.com/videos/editor-picks/)\\n\\t+ [Investing Insights](https://finance.yahoo.com/videos/investing-insights/)\\n\\t+ [Trending Stocks](https://finance.yahoo.com/videos/trending-stocks/)\\n\\t+ [All Shows](https://finance.yahoo.com/videos/series/)\\n\\t+ [Morning Brief](https://finance.yahoo.com/videos/series/morning-brief/)\\n\\t+ [Opening Bid](https://finance.yahoo.com/videos/series/opening-bid/)\\n\\t+ [Wealth](https://finance.yahoo.com/videos/series/wealth/)\\n\\t+ [ETF Report](https://finance.yahoo.com/topic/etf-report/)\\n\\n …\\n * [Summary](/quote/VMC/ \"Summary\")\\n* [News](/quote/VMC/news/ \"News\")\\n* [Chart](/quote/VMC/chart/ \"Chart\")\\n* [Conversations](/quote/VMC/community/ \"Conversations\")\\n* [Statistics](/quote/VMC/key-statistics/ \"Statistics\")\\n* [Historical Data](/quote/VMC/history/ \"Historical Data\")\\n* [Profile](/quote/VMC/profile/ \"Profile\")\\n* [Financials](/quote/VMC/financials/ \"Financials\")\\n* [Analysis](/quote/VMC/analysis/ \"Analysis\")\\n* [Options](/quote/VMC/options/ \"Options\")\\n* [Holders](/quote/VMC/holders/ \"Holders\")\\n* [Sustainability](/quote/VMC/sustainability/ \"Sustainability\")\\n\\n NYSE \\\\- Delayed Quote *•* USD Vulcan Materials Company (VMC)\\n==============================\\n\\n Follow [Compare](/compare/VMC) 250\\\\.58 \\\\+0\\\\.95 (\\\\+0\\\\.38%) At close: September 26 at 4:00 PM EDT 250\\\\.58 0\\\\.00 (0\\\\.00%) Pre\\\\-Market: 8:32 AM EDT All News Press Releases SEC Filings All SEC Filings Corporate Changes \\\\& Voting Matters Periodic Financial Reports Proxy Statements Tender Offer/Acquisition Reports Offering Registrations * [![VULCAN ANNOUNCES AGREEMENT TO ACQUIRE WAKE STONE CORPORATION](https://s.yimg.com/uu/api/res/1.2/aDnKX49Ozg774P8gFLwaTg--~B/Zmk9c3RyaW07aD0xMjY7cT04MDt3PTE2ODthcHBpZD15dGFjaHlvbg--/https://media.zenfs.com/en/prnewswire.com/e759bf67d41f724a33cfb8ce8ed4a995)](https://finance.yahoo.com/news/vulcan-announces-agreement-acquire-wake-201500559.html \"VULCAN ANNOUNCES AGREEMENT TO ACQUIRE WAKE STONE CORPORATION\") [### VULCAN ANNOUNCES AGREEMENT TO ACQUIRE WAKE STONE CORPORATION\\n\\n Vulcan Materials Company (NYSE: VMC), the nation\\'s largest producer of construction aggregates, today announced that it has entered into a definitive agreement to acquire Wake Stone Corporation, a leading pure\\\\-play aggregates supplier in the Carolinas. This value\\\\-enhancing acquisition is expected to provide more than 60 years of quality hard rock reserves to serve attractive high\\\\-growth geographies, most notably Raleigh, North Carolina.](https://finance.yahoo.com/news/vulcan-announces-agreement-acquire-wake-201500559.html \"VULCAN ANNOUNCES AGREEMENT TO ACQUIRE WAKE STONE CORPORATION\") PR Newswire *•* 16 hours ago\\n*\\n* [![VULCAN REPORTS SECOND QUARTER 2024 RESULTS](https://s.yimg.com/uu/api/res/1.2/aDnKX49Ozg774P8gFLwaTg--~B/Zmk9c3RyaW07aD0xMjY7cT04MDt3PTE2ODthcHBpZD15dGFjaHlvbg--/https://media.zenfs.com/en/prnewswire.com/e759bf67d41f724a33cfb8ce8ed4a995)](https://finance.yahoo.com/news/vulcan-reports-second-quarter-2024-113000682.html \"VULCAN REPORTS SECOND QUARTER 2024 RESULTS\") [### VULCAN REPORTS SECOND QUARTER 2024 RESULTS\\n\\n Vulcan Materials Company (NYSE: VMC), the nation\\'s largest producer of construction aggregates, today announced results for the quarter ended June 30, 2024\\\\.](https://finance.yahoo.com/news/vulcan-reports-second-quarter-2024-113000682.html \"VULCAN REPORTS SECOND QUARTER 2024 RESULTS\") PR Newswire *•* last month\\n* [![VULCAN ANNOUNCES SECOND QUARTER 2024 CONFERENCE CALL](https://s.yimg.com/uu/api/res/1.2/aDnKX49Ozg774P8gFLwaTg--~B/Zmk9c3RyaW07aD0xMjY7cT04MDt3PTE2ODthcHBpZD15dGFjaHlvbg--/https://media.zenfs.com/en/prnewswire.com/e759bf67d41f724a33cfb8ce8ed4a995)](https://finance.yahoo.com/news/vulcan-announces-second-quarter-2024-125400553.html \"VULCAN ANNOUNCES SECOND QUARTER 2024 CONFERENCE CALL\") [### VULCAN ANNOUNCES SECOND QUARTER 2024 CONFERENCE CALL\\n\\n Vulcan Materials Company (NYSE: VMC) will host its second quarter 2024 earnings conference call on Tuesday, August 6, 2024 at 10:00 a.m. CT (11:00 a.m. ET). Financial results will be released before the NYSE market opens.](https://finance.yahoo.com/news/vulcan-announces-second-quarter-2024-125400553.html \"VULCAN ANNOUNCES SECOND QUARTER 2024 CONFERENCE CALL\") PR Newswire *•* 2 months ago\\n* [![VULCAN DECLARES QUARTERLY DIVIDEND ON COMMON STOCK](https://s.yimg.com/uu/api/res/1.2/aDnKX49Ozg774P8gFLwaTg--~B/Zmk9c3RyaW07aD0xMjY7cT04MDt3PTE2ODthcHBpZD15dGFjaHlvbg--/https://media.zenfs.com/en/prnewswire.com/e759bf67d41f724a33cfb8ce8ed4a995)](https://finance.yahoo.com/news/vulcan-declares-quarterly-dividend-common-203000839.html \"VULCAN DECLARES QUARTERLY DIVIDEND ON COMMON STOCK\") [### VULCAN DECLARES QUARTERLY DIVIDEND ON COMMON STOCK\\n\\n The Board of Directors of Vulcan Materials Company (NYSE: VMC) today declared a quarterly cash dividend of $0\\\\.46 cents per share on its common stock. The dividend will be payable on September 4, 2024, to shareholders of record at the close of business on August 15, 2024\\\\.](https://finance.yahoo.com/news/vulcan-declares-quarterly-dividend-common-203000839.html \"VULCAN DECLARES QUARTERLY DIVIDEND ON COMMON STOCK\") PR Newswire *•* 2 months ago\\n* [![VULCAN REPORTS FIRST QUARTER 2024 RESULTS](https://s.yimg.com/uu/api/res/1.2/aDnKX49Ozg774P8gFLwaTg--~B/Zmk9c3RyaW07aD0xMjY7cT04MDt3PTE2ODthcHBpZD15dGFjaHlvbg--/https://media.zenfs.com/en/prnewswire.com/e759bf67d41f724a33cfb8ce8ed4a995)](https://finance.yahoo.com/news/vulcan-reports-first-quarter-2024-113000663.html \"VULCAN REPORTS FIRST QUARTER 2024 RESULTS\") [### VULCAN REPORTS FIRST QUARTER 2024 RESULTS\\n\\n Vulcan Materials Company (NYSE: VMC), the nation\\'s largest producer of construction aggregates, today announced results for the quarter ended March 31, 2024\\\\.](https://finance.yahoo.com/news/vulcan-reports-first-quarter-2024-113000663.html \"VULCAN REPORTS FIRST QUARTER 2024 RESULTS\") PR Newswire *•* 4 months ago\\n*\\n* [![VULCAN ANNOUNCES FIRST QUARTER 2024 CONFERENCE CALL](https://s.yimg.com/uu/api/res/1.2/aDnKX49Ozg774P8gFLwaTg--~B/Zmk9c3RyaW07aD0xMjY7cT04MDt3PTE2ODthcHBpZD15dGFjaHlvbg--/https://media.zenfs.com/en/prnewswire.com/e759bf67d41f724a33cfb8ce8ed4a995)](https://finance.yahoo.com/news/vulcan-announces-first-quarter-2024-210000542.html \"VULCAN ANNOUNCES FIRST QUARTER 2024 CONFERENCE CALL\") [### VULCAN ANNOUNCES FIRST QUARTER 2024 CONFERENCE CALL\\n\\n Vulcan Materials Company (NYSE: VMC) will host its first quarter 2024 earnings conference call on Thursday, May 2, 2024 at 10:00 a.m. CT (11:00 a.m. ET). Financial results will be released before the NYSE market opens.](https://finance.yahoo.com/news/vulcan-announces-first-quarter-2024-210000542.html \"VULCAN ANNOUNCES FIRST QUARTER 2024 CONFERENCE CALL\") PR Newswire *•* 5 months ago\\n* [![VULCAN REPORTS FOURTH QUARTER AND FULL YEAR 2023 RESULTS](https://s.yimg.com/uu/api/res/1.2/aDnKX49Ozg774P8gFLwaTg--~B/Zmk9c3RyaW07aD0xMjY7cT04MDt3PTE2ODthcHBpZD15dGFjaHlvbg--/https://media.zenfs.com/en/prnewswire.com/e759bf67d41f724a33cfb8ce8ed4a995)](https://finance.yahoo.com/news/vulcan-reports-fourth-quarter-full-121000502.html \"VULCAN REPORTS FOURTH QUARTER AND FULL YEAR 2023 RESULTS\") [### VULCAN REPORTS FOURTH QUARTER AND FULL YEAR 2023 RESULTS\\n\\n Vulcan Materials Company (NYSE: VMC), the nation\\'s largest producer of construction aggregates, today announced results for the quarter and year ended December 31, 2023\\\\.](https://finance.yahoo.com/news/vulcan-reports-fourth-quarter-full-121000502.html \"VULCAN REPORTS FOURTH QUARTER AND FULL YEAR 2023 RESULTS\") PR Newswire *•* 7 months ago\\n* [![VULCAN INCREASES QUARTERLY DIVIDEND ON COMMON STOCK](https://s.yimg.com/uu/api/res/1.2/aDnKX49Ozg774P8gFLwaTg--~B/Zmk9c3RyaW07aD0xMjY7cT04MDt3PTE2ODthcHBpZD15dGFjaHlvbg--/https://media.zenfs.com/en/prnewswire.com/e759bf67d41f724a33cfb8ce8ed4a995)](https://finance.yahoo.com/news/vulcan-increases-quarterly-dividend-common-213000996.html \"VULCAN INCREASES QUARTERLY DIVIDEND ON COMMON STOCK\") [### VULCAN INCREASES QUARTERLY DIVIDEND ON COMMON STOCK\\n\\n The Board of Directors of Vulcan Materials Company (NYSE: VMC) today declared a quarterly cash dividend of $0\\\\.46 per', 1, 2)

[20] search_agent responds to analyst

kind: respond\n",
-       "copy_output: false\n",
+       "3. **[Corporate Profile](https://www.vulcangroup.com/about-vulcan/corporate-profile/)**\n",
+       "   - Vulcan Engineering is the largest in-house engineering, manufacturing, and installation group in North America dedicated to the metalcasting and heavy industries.\n",
+       "\n",
+       "4. **[Vulcan Inc - Company Profile and News](https://www.bloomberg.com/profile/company/270128Z:US)**\n",
+       "   - Vulcan Inc. operates as an investment company. The Company invests in financial services, internet and technology, life sciences, media, transportation, and retail sectors.\n",
+       "\n",
+       "5. **[About Vulcan](https://v-er.eu/about-vulcan/)**\n",
+       "   - Vulcan aims to be the largest, preferred, strategic producer and supplier of lithium chemicals and renewable energy from Europe for Europe.\n",
+       "\n",
+       "### Recent News on Vulcan\n",
        "\n",
-       "
3158 characters ...### Vulcan Materials Company Profile\n", - "\n", - "**Company Overview:**\n", - "- **Name:** Vulcan Materials Company\n", - "- **Headquarters:** 1200 Urban Center Drive, Birmingham, AL 35242, United States\n", - "- **Website:** [vulcanmaterials.com](https://www.vulcanmaterials.com)\n", - "- **Sector:** Basic Materials\n", - "- **Industry:** Building Materials\n", - "- **Full-Time Employees:** 10,961\n", - "- **Founded:** 1909\n", - "\n", - "**Business Description:**\n", - "Vulcan Materials Company, together with its subsidiaries, produces and supplies construction aggregates primarily in the United States. It operates through four segments: Aggregates, Asphalt, Concrete, and Calcium. The company provides crushed stones, sand and gravel, sand, and other aggregates; and related products and services that are applied in construction and maintenance of highways, streets, and other public works, as well as in the construction of housing and commercial, industrial, and other nonresidential facilities. It also offers asphalt mix and asphalt construction paving services; ready-mixed concrete; and calcium products for the animal feed, plastics, and water treatment industries.\n", - "\n", - "**Key Executives:**\n", - "- **James Thomas Hill:** CEO & Chairman\n", - "- **Thompson S. Baker II:** President\n", - "- **Mary Andrews Carlisle:** Senior VP & CFO\n", - "- **Ronnie A. Pruitt:** Chief Operating Officer\n", - "- **Stanley G. Bass:** Chief Strategy Officer\n", - "\n", - "**Corporate Governance:**\n", - "- **ISS Governance QualityScore:** 6 (as of September 18, 2024)\n", - " - **Audit:** 7\n", - " - **Board:** 6\n", - " - **Shareholder Rights:** 6\n", - " - **Compensation:** 5\n", - "\n", - "### Recent News\n", - "\n", - "1. **Vulcan Announces Agreement to Acquire Wake Stone Corporation**\n", - " - **Date:** 17 hours ago\n", - " - **Summary:** Vulcan Materials Company announced that it has entered into a definitive agreement to acquire Wake Stone Corporation, a leading pure-play aggregates supplier in the Carolinas. This acquisition is expected to provide more than 60 years of quality hard rock reserves to serve high-growth geographies, most notably Raleigh, North Carolina.\n", - " - **Source:** [PR Newswire](https://www.prnewswire.com/news-releases/vulcan-announces-agreement-to-acquire-wake-stone-corporation-302260124.html)\n", - "\n", - "2. **Vulcan Reports Second Quarter 2024 Results**\n", - " - **Date:** August 6, 2024\n", - " - **Summary:** Vulcan Materials Company reported its financial results for the quarter ended June 30, 2024. The company continues to be the nation's largest producer of construction aggregates.\n", - " - **Source:** [Yahoo Finance](https://finance.yahoo.com/news/vulcan-reports-second-quarter-2024-113000682.html)\n", - "\n", - "3. **Vulcan Declares Quarterly Dividend on Common Stock**\n", - " - **Date:** July 19, 2024\n", - " - **Summary:** The Board of Directors of Vulcan Materials Company declared a quarterly cash dividend of $0.46 per share on its common stock. The dividend will be payable on September 4, 2024, to shareholders of record at the close of business on August 15, 2024.\n", - " - **Source:** [Yahoo Finance](https://finance.yahoo.com/news/vulcan-declares-quarterly-dividend-common-203000839.html)\n", - "\n", - "For more detailed and up-to-date information, you can visit the [Vulcan Materials Company News Page](https://ir.vulcanmaterials.com/news/default.aspx).

[21] Assistant

kind: assistant\n",
-       "\n",
-       "Vulcan Materials Company (NYSE: VMC) is the largest producer of construction aggregates in the United States, including crushed stone, sand, and gravel. Over the past year, Vulcan's stock price has seen significant fluctuations, starting at around $211 in September 2023 and peaking at approximately $275 in March 2024, before settling at around $236 in September 2024. Recently, Vulcan announced an agreement to acquire Wake Stone Corporation, which is expected to enhance its reserves and market presence in high-growth areas like Raleigh, North Carolina.

[22] Thought: SetNextNode

kind: set_next_node\n",
+       "1. **[News](https://ir.vulcanmaterials.com/news/default.aspx)**\n",
+       "   - August 6, 2024: Vulcan reports second quarter 2024 results.\n",
+       "   - July 19, 2024: Vulcan announces second quarter 2024 conference call.\n",
+       "   - July 12, 2024: Vulcan releases other updates.\n",
+       "\n",
+       "2. **[Vulcan News | Latest Local Headlines](https://www.vulcanadvocate.com/category/news/local-news/)**\n",
+       "   - Latest news videos and updates, including Mark Carney getting a job with Trudeau just as his company asks Ottawa for $10 billion.\n",
+       "\n",
+       "3. **[Vulcan Advocate: Home](https://www.vulcanadvocate.com/)**\n",
+       "   - Various local news updates, including political and economic developments affecting the company.

[15] Thought: SetNextNode

kind: set_next_node\n",
        "next_node: 0\n",
-       "
" + "

[16] Assistant

kind: assistant\n",
+       "\n",
+       "Vulcan Materials Company (VMC) is a leading producer of construction aggregates, including crushed stone, sand, and gravel, primarily serving the United States. Over the past year, Vulcan's stock price has seen significant fluctuations, starting at around $211.69 in September 2023 and peaking at approximately $275.59 in March 2024, before settling at $236.27 in September 2024. Recently, Vulcan reported its second-quarter 2024 results and announced updates on its business operations, reflecting its ongoing commitment to growth and market presence.
" ], "text/plain": [ "" @@ -2557,15 +2637,15 @@ "\"\"\"\n", "system_message = {\"role\": \"system\", \"content\": system_instruction}\n", "\n", - "class PlanNode(Node):\n", "\n", + "class PlanNode(Node):\n", " def make_prompt(self, agent, tape) -> Prompt:\n", " view = agent.compute_view(tape)\n", " guidance = \"Write a natural language plan on how to use tools help the user. Output a list of numbered items, like 1., 2., 3., etc.\"\n", " guidance_message = {\"role\": \"user\", \"content\": guidance}\n", " return Prompt(\n", - " messages=[system_message] + view_to_messages(view.top, agent) + [guidance_message], \n", - " tools=main_agent_env.get_tool_schema_dicts()\n", + " messages=[system_message] + view_to_messages(view.top, agent) + [guidance_message],\n", + " tools=main_agent_env.get_tool_schema_dicts(),\n", " )\n", "\n", " def generate_steps(self, agent, dialog, llm_stream: LLMStream):\n", @@ -2574,22 +2654,22 @@ " else:\n", " raise ValueError()\n", "\n", - "class ActNode(Node):\n", "\n", + "class ActNode(Node):\n", " def make_prompt(self, agent, tape: DialogTape) -> Prompt:\n", " view = agent.compute_view(tape)\n", " guidance = \"Follow the plan you created to earlier. When you are done, respond to the user.\"\n", " guidance_message = {\"role\": \"user\", \"content\": guidance}\n", " return Prompt(\n", - " messages=[system_message] + view_to_messages(view.top, agent) + [guidance_message], \n", - " tools=main_agent_env.get_tool_schema_dicts()\n", + " messages=[system_message] + view_to_messages(view.top, agent) + [guidance_message],\n", + " tools=main_agent_env.get_tool_schema_dicts(),\n", " )\n", "\n", " def generate_steps(self, agent, dialog, llm_stream: LLMStream):\n", " m = llm_stream.get_message()\n", " if m.content:\n", - " yield AssistantStep(content=m.content)\n", " yield SetNextNode(next_node=0)\n", + " yield AssistantStep(content=m.content)\n", " elif m.tool_calls:\n", " yield SetNextNode(next_node=1)\n", " # only keep the tool calls before the call to another agent\n", @@ -2599,17 +2679,18 @@ " break\n", " else:\n", " tool_calls.append(tc)\n", - " # either produce the ToolCalls action OR call another agent \n", + " # either produce the ToolCalls action OR call another agent\n", " if tool_calls:\n", " yield ToolCalls(tool_calls=tool_calls)\n", - " else: \n", + " else:\n", " tc = m.tool_calls[0]\n", - " assert tc.function.name == \"call_search_agent\" \n", + " assert tc.function.name == \"call_search_agent\"\n", " yield Call(agent_name=\"search_agent\", content=json.loads(m.tool_calls[0].function.arguments)[\"query\"])\n", - " \n", + "\n", " else:\n", " raise ValueError()\n", "\n", + "\n", "multi_agent_analyst = Agent.create(\n", " name=\"analyst\",\n", " subagents=[search_agent.clone()],\n", @@ -2620,7 +2701,7 @@ "print(\"Run the agent!\")\n", "start_tape = DialogTape(steps=[UserStep(content=\"Tell me about Vulcan in 3 sentences\")])\n", "for event in main_loop(multi_agent_analyst, start_tape, whole_env):\n", - " # This agent runs for a while, so we will show you a fresh render every time \n", + " # This agent runs for a while, so we will show you a fresh render every time\n", " # when the environment finishes reacting with new actions\n", " if new_tape := event.agent_tape or event.env_tape:\n", " clear_output()\n", @@ -2629,7 +2710,7 @@ " # if event.env_tape:\n", " # input(\"Press Enter the run the next iteration of the main loop\")\n", " if event.status == MainLoopStatus.EXTERNAL_INPUT_NEEDED:\n", - " break " + " break" ] }, { @@ -2638,16 +2719,11 @@ "source": [ "Look at this rather long tape and note how \"analyst\" calls \"search_agent\", and how the latter then responds to \"analyst\". Congratulations, you now know how to build a multi-agent TapeAgent!" ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [] } ], "metadata": { "kernelspec": { - "display_name": "tapes", + "display_name": "tapeagents", "language": "python", "name": "python3" }, @@ -2662,568 +2738,6 @@ "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.14" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": { - "001f28da24cd46e0a8c6dad91d252ed3": { - "model_module": "@jupyter-widgets/controls", - "model_module_version": "2.0.0", - "model_name": "VBoxModel", - "state": { - "_dom_classes": [], - "_model_module": "@jupyter-widgets/controls", - "_model_module_version": "2.0.0", - "_model_name": "VBoxModel", - "_view_count": null, - "_view_module": "@jupyter-widgets/controls", - "_view_module_version": "2.0.0", - "_view_name": "VBoxView", - "box_style": "", - "children": [ - "IPY_MODEL_d0ee8fa114704451aa1c53239fcc1d48", - "IPY_MODEL_73938d01cad043cb97cf8cf4aea1d329", - "IPY_MODEL_59bd0d00dcbf495eb380e94977d20d16", - "IPY_MODEL_6f5f428058d047b0b00712b772172368", - "IPY_MODEL_0399226daa4e4b20931986d5a9d1435f" - ], - "layout": "IPY_MODEL_886abc723f0040dd964a2a657846106e", - "tabbable": null, - "tooltip": null - } - }, - "0399226daa4e4b20931986d5a9d1435f": { - "model_module": "@jupyter-widgets/controls", - "model_module_version": "2.0.0", - "model_name": "HTMLModel", - "state": { - "_dom_classes": [], - "_model_module": "@jupyter-widgets/controls", - "_model_module_version": "2.0.0", - "_model_name": "HTMLModel", - "_view_count": null, - "_view_module": "@jupyter-widgets/controls", - "_view_module_version": "2.0.0", - "_view_name": "HTMLView", - "description": "", - "description_allow_html": false, - "layout": "IPY_MODEL_a37388ca5ace4c58b6295a04df04e54f", - "placeholder": "​", - "style": "IPY_MODEL_ce89c7f0d44040df843ceefdc4cbc53c", - "tabbable": null, - "tooltip": null, - "value": "\nPro Tip: If you don't already have one, you can create a dedicated\n'notebooks' token with 'write' access, that you can then easily reuse for all\nnotebooks.
" - } - }, - "4ccbe793cf1e47bdbbf4ecaa0d8ab28a": { - "model_module": "@jupyter-widgets/base", - "model_module_version": "2.0.0", - "model_name": "LayoutModel", - "state": { - "_model_module": "@jupyter-widgets/base", - "_model_module_version": "2.0.0", - "_model_name": "LayoutModel", - "_view_count": null, - "_view_module": "@jupyter-widgets/base", - "_view_module_version": "2.0.0", - "_view_name": "LayoutView", - "align_content": null, - "align_items": null, - "align_self": null, - "border_bottom": null, - "border_left": null, - "border_right": null, - "border_top": null, - "bottom": null, - "display": null, - "flex": null, - "flex_flow": null, - "grid_area": null, - "grid_auto_columns": null, - "grid_auto_flow": null, - "grid_auto_rows": null, - "grid_column": null, - "grid_gap": null, - "grid_row": null, - "grid_template_areas": null, - "grid_template_columns": null, - "grid_template_rows": null, - "height": null, - "justify_content": null, - "justify_items": null, - "left": null, - "margin": null, - "max_height": null, - "max_width": null, - "min_height": null, - "min_width": null, - "object_fit": null, - "object_position": null, - "order": null, - "overflow": null, - "padding": null, - "right": null, - "top": null, - "visibility": null, - "width": null - } - }, - "4fce15c7874a44658564d6ea878046a2": { - "model_module": "@jupyter-widgets/controls", - "model_module_version": "2.0.0", - "model_name": "TextStyleModel", - "state": { - "_model_module": "@jupyter-widgets/controls", - "_model_module_version": "2.0.0", - "_model_name": "TextStyleModel", - "_view_count": null, - "_view_module": "@jupyter-widgets/base", - "_view_module_version": "2.0.0", - "_view_name": "StyleView", - "background": null, - "description_width": "", - "font_size": null, - "text_color": null - } - }, - "59bd0d00dcbf495eb380e94977d20d16": { - "model_module": "@jupyter-widgets/controls", - "model_module_version": "2.0.0", - "model_name": "CheckboxModel", - "state": { - "_dom_classes": [], - "_model_module": "@jupyter-widgets/controls", - "_model_module_version": "2.0.0", - "_model_name": "CheckboxModel", - "_view_count": null, - "_view_module": "@jupyter-widgets/controls", - "_view_module_version": "2.0.0", - "_view_name": "CheckboxView", - "description": "Add token as git credential?", - "description_allow_html": false, - "disabled": false, - "indent": true, - "layout": "IPY_MODEL_e78c07c886f4408bb2b4e574fe65cf66", - "style": "IPY_MODEL_e8af16b55056402da46be597413d169c", - "tabbable": null, - "tooltip": null, - "value": true - } - }, - "6f5f428058d047b0b00712b772172368": { - "model_module": "@jupyter-widgets/controls", - "model_module_version": "2.0.0", - "model_name": "ButtonModel", - "state": { - "_dom_classes": [], - "_model_module": "@jupyter-widgets/controls", - "_model_module_version": "2.0.0", - "_model_name": "ButtonModel", - "_view_count": null, - "_view_module": "@jupyter-widgets/controls", - "_view_module_version": "2.0.0", - "_view_name": "ButtonView", - "button_style": "", - "description": "Login", - "disabled": false, - "icon": "", - "layout": "IPY_MODEL_d6d9b4556587427486a8699b09b93799", - "style": "IPY_MODEL_fd3bd8587a8f4106a4a720004dfd623c", - "tabbable": null, - "tooltip": null - } - }, - "73938d01cad043cb97cf8cf4aea1d329": { - "model_module": "@jupyter-widgets/controls", - "model_module_version": "2.0.0", - "model_name": "PasswordModel", - "state": { - "_dom_classes": [], - "_model_module": "@jupyter-widgets/controls", - "_model_module_version": "2.0.0", - "_model_name": "PasswordModel", - "_view_count": null, - "_view_module": "@jupyter-widgets/controls", - "_view_module_version": "2.0.0", - "_view_name": "PasswordView", - "continuous_update": true, - "description": "Token:", - "description_allow_html": false, - "disabled": false, - "layout": "IPY_MODEL_4ccbe793cf1e47bdbbf4ecaa0d8ab28a", - "placeholder": "​", - "style": "IPY_MODEL_4fce15c7874a44658564d6ea878046a2", - "tabbable": null, - "tooltip": null, - "value": "" - } - }, - "73b3b53bdbf240f393b2b4f2ae686830": { - "model_module": "@jupyter-widgets/base", - "model_module_version": "2.0.0", - "model_name": "LayoutModel", - "state": { - "_model_module": "@jupyter-widgets/base", - "_model_module_version": "2.0.0", - "_model_name": "LayoutModel", - "_view_count": null, - "_view_module": "@jupyter-widgets/base", - "_view_module_version": "2.0.0", - "_view_name": "LayoutView", - "align_content": null, - "align_items": null, - "align_self": null, - "border_bottom": null, - "border_left": null, - "border_right": null, - "border_top": null, - "bottom": null, - "display": null, - "flex": null, - "flex_flow": null, - "grid_area": null, - "grid_auto_columns": null, - "grid_auto_flow": null, - "grid_auto_rows": null, - "grid_column": null, - "grid_gap": null, - "grid_row": null, - "grid_template_areas": null, - "grid_template_columns": null, - "grid_template_rows": null, - "height": null, - "justify_content": null, - "justify_items": null, - "left": null, - "margin": null, - "max_height": null, - "max_width": null, - "min_height": null, - "min_width": null, - "object_fit": null, - "object_position": null, - "order": null, - "overflow": null, - "padding": null, - "right": null, - "top": null, - "visibility": null, - "width": null - } - }, - "886abc723f0040dd964a2a657846106e": { - "model_module": "@jupyter-widgets/base", - "model_module_version": "2.0.0", - "model_name": "LayoutModel", - "state": { - "_model_module": "@jupyter-widgets/base", - "_model_module_version": "2.0.0", - "_model_name": "LayoutModel", - "_view_count": null, - "_view_module": "@jupyter-widgets/base", - "_view_module_version": "2.0.0", - "_view_name": "LayoutView", - "align_content": null, - "align_items": "center", - "align_self": null, - "border_bottom": null, - "border_left": null, - "border_right": null, - "border_top": null, - "bottom": null, - "display": "flex", - "flex": null, - "flex_flow": "column", - "grid_area": null, - "grid_auto_columns": null, - "grid_auto_flow": null, - "grid_auto_rows": null, - "grid_column": null, - "grid_gap": null, - "grid_row": null, - "grid_template_areas": null, - "grid_template_columns": null, - "grid_template_rows": null, - "height": null, - "justify_content": null, - "justify_items": null, - "left": null, - "margin": null, - "max_height": null, - "max_width": null, - "min_height": null, - "min_width": null, - "object_fit": null, - "object_position": null, - "order": null, - "overflow": null, - "padding": null, - "right": null, - "top": null, - "visibility": null, - "width": "50%" - } - }, - "a37388ca5ace4c58b6295a04df04e54f": { - "model_module": "@jupyter-widgets/base", - "model_module_version": "2.0.0", - "model_name": "LayoutModel", - "state": { - "_model_module": "@jupyter-widgets/base", - "_model_module_version": "2.0.0", - "_model_name": "LayoutModel", - "_view_count": null, - "_view_module": "@jupyter-widgets/base", - "_view_module_version": "2.0.0", - "_view_name": "LayoutView", - "align_content": null, - "align_items": null, - "align_self": null, - "border_bottom": null, - "border_left": null, - "border_right": null, - "border_top": null, - "bottom": null, - "display": null, - "flex": null, - "flex_flow": null, - "grid_area": null, - "grid_auto_columns": null, - "grid_auto_flow": null, - "grid_auto_rows": null, - "grid_column": null, - "grid_gap": null, - "grid_row": null, - "grid_template_areas": null, - "grid_template_columns": null, - "grid_template_rows": null, - "height": null, - "justify_content": null, - "justify_items": null, - "left": null, - "margin": null, - "max_height": null, - "max_width": null, - "min_height": null, - "min_width": null, - "object_fit": null, - "object_position": null, - "order": null, - "overflow": null, - "padding": null, - "right": null, - "top": null, - "visibility": null, - "width": null - } - }, - "bb30cf00e8274065bb36c6d927457c0c": { - "model_module": "@jupyter-widgets/controls", - "model_module_version": "2.0.0", - "model_name": "HTMLStyleModel", - "state": { - "_model_module": "@jupyter-widgets/controls", - "_model_module_version": "2.0.0", - "_model_name": "HTMLStyleModel", - "_view_count": null, - "_view_module": "@jupyter-widgets/base", - "_view_module_version": "2.0.0", - "_view_name": "StyleView", - "background": null, - "description_width": "", - "font_size": null, - "text_color": null - } - }, - "ce89c7f0d44040df843ceefdc4cbc53c": { - "model_module": "@jupyter-widgets/controls", - "model_module_version": "2.0.0", - "model_name": "HTMLStyleModel", - "state": { - "_model_module": "@jupyter-widgets/controls", - "_model_module_version": "2.0.0", - "_model_name": "HTMLStyleModel", - "_view_count": null, - "_view_module": "@jupyter-widgets/base", - "_view_module_version": "2.0.0", - "_view_name": "StyleView", - "background": null, - "description_width": "", - "font_size": null, - "text_color": null - } - }, - "d0ee8fa114704451aa1c53239fcc1d48": { - "model_module": "@jupyter-widgets/controls", - "model_module_version": "2.0.0", - "model_name": "HTMLModel", - "state": { - "_dom_classes": [], - "_model_module": "@jupyter-widgets/controls", - "_model_module_version": "2.0.0", - "_model_name": "HTMLModel", - "_view_count": null, - "_view_module": "@jupyter-widgets/controls", - "_view_module_version": "2.0.0", - "_view_name": "HTMLView", - "description": "", - "description_allow_html": false, - "layout": "IPY_MODEL_73b3b53bdbf240f393b2b4f2ae686830", - "placeholder": "​", - "style": "IPY_MODEL_bb30cf00e8274065bb36c6d927457c0c", - "tabbable": null, - "tooltip": null, - "value": "

Copy a token from your Hugging Face\ntokens page and paste it below.
Immediately click login after copying\nyour token or it might be stored in plain text in this notebook file.
" - } - }, - "d6d9b4556587427486a8699b09b93799": { - "model_module": "@jupyter-widgets/base", - "model_module_version": "2.0.0", - "model_name": "LayoutModel", - "state": { - "_model_module": "@jupyter-widgets/base", - "_model_module_version": "2.0.0", - "_model_name": "LayoutModel", - "_view_count": null, - "_view_module": "@jupyter-widgets/base", - "_view_module_version": "2.0.0", - "_view_name": "LayoutView", - "align_content": null, - "align_items": null, - "align_self": null, - "border_bottom": null, - "border_left": null, - "border_right": null, - "border_top": null, - "bottom": null, - "display": null, - "flex": null, - "flex_flow": null, - "grid_area": null, - "grid_auto_columns": null, - "grid_auto_flow": null, - "grid_auto_rows": null, - "grid_column": null, - "grid_gap": null, - "grid_row": null, - "grid_template_areas": null, - "grid_template_columns": null, - "grid_template_rows": null, - "height": null, - "justify_content": null, - "justify_items": null, - "left": null, - "margin": null, - "max_height": null, - "max_width": null, - "min_height": null, - "min_width": null, - "object_fit": null, - "object_position": null, - "order": null, - "overflow": null, - "padding": null, - "right": null, - "top": null, - "visibility": null, - "width": null - } - }, - "e78c07c886f4408bb2b4e574fe65cf66": { - "model_module": "@jupyter-widgets/base", - "model_module_version": "2.0.0", - "model_name": "LayoutModel", - "state": { - "_model_module": "@jupyter-widgets/base", - "_model_module_version": "2.0.0", - "_model_name": "LayoutModel", - "_view_count": null, - "_view_module": "@jupyter-widgets/base", - "_view_module_version": "2.0.0", - "_view_name": "LayoutView", - "align_content": null, - "align_items": null, - "align_self": null, - "border_bottom": null, - "border_left": null, - "border_right": null, - "border_top": null, - "bottom": null, - "display": null, - "flex": null, - "flex_flow": null, - "grid_area": null, - "grid_auto_columns": null, - "grid_auto_flow": null, - "grid_auto_rows": null, - "grid_column": null, - "grid_gap": null, - "grid_row": null, - "grid_template_areas": null, - "grid_template_columns": null, - "grid_template_rows": null, - "height": null, - "justify_content": null, - "justify_items": null, - "left": null, - "margin": null, - "max_height": null, - "max_width": null, - "min_height": null, - "min_width": null, - "object_fit": null, - "object_position": null, - "order": null, - "overflow": null, - "padding": null, - "right": null, - "top": null, - "visibility": null, - "width": null - } - }, - "e8af16b55056402da46be597413d169c": { - "model_module": "@jupyter-widgets/controls", - "model_module_version": "2.0.0", - "model_name": "CheckboxStyleModel", - "state": { - "_model_module": "@jupyter-widgets/controls", - "_model_module_version": "2.0.0", - "_model_name": "CheckboxStyleModel", - "_view_count": null, - "_view_module": "@jupyter-widgets/base", - "_view_module_version": "2.0.0", - "_view_name": "StyleView", - "background": null, - "description_width": "" - } - }, - "fd3bd8587a8f4106a4a720004dfd623c": { - "model_module": "@jupyter-widgets/controls", - "model_module_version": "2.0.0", - "model_name": "ButtonStyleModel", - "state": { - "_model_module": "@jupyter-widgets/controls", - "_model_module_version": "2.0.0", - "_model_name": "ButtonStyleModel", - "_view_count": null, - "_view_module": "@jupyter-widgets/base", - "_view_module_version": "2.0.0", - "_view_name": "StyleView", - "button_color": null, - "font_family": null, - "font_size": null, - "font_style": null, - "font_variant": null, - "font_weight": null, - "text_color": null, - "text_decoration": null - } - } - }, - "version_major": 2, - "version_minor": 0 - } } }, "nbformat": 4, diff --git a/requirements.dev.txt b/requirements.dev.txt index 847f764..de92ceb 100644 --- a/requirements.dev.txt +++ b/requirements.dev.txt @@ -1,4 +1,5 @@ pytest==8.3.3 testbook==0.4.2 flake8==6.0.0 -ruff==0.6.6 \ No newline at end of file +ruff==0.6.6 +nbconvert==7.16.4 \ No newline at end of file diff --git a/tapeagents/llms.py b/tapeagents/llms.py index 1504dfa..7fae5b0 100644 --- a/tapeagents/llms.py +++ b/tapeagents/llms.py @@ -250,7 +250,7 @@ def make_training_text(self, *args, **kwargs) -> TrainingText: raise NotImplementedError() -class LLAMAConfig(BaseModel): +class TrainableLLMConfig(BaseModel): model_name: str base_url: str parameters: dict[str, Any] = {} @@ -263,7 +263,7 @@ class TypedVLLM(LLM): _obj_log: dict - def __init__(self, config: LLAMAConfig, use_cache: bool = True, only_cache: bool = False): + def __init__(self, config: TrainableLLMConfig, use_cache: bool = True, only_cache: bool = False): import transformers self.model_name = config.model_name @@ -357,12 +357,11 @@ def fix_schema(schema: dict) -> dict: return fix_schema(schema) -class LLAMA(CachedLLM): - """Talk to TGI or VLLM endpoints serving LLAMA (or another HF based model) using OpenAI API. +class TrainableLLM(CachedLLM): + """Talk to TGI or VLLM endpoints serving HF based model (Llama, Mistral, etc.) using OpenAI API. # TODO: use OpenAI Python client when the certificate issue is resolved. # TODO: consider using litellm - """ base_url: str @@ -430,7 +429,7 @@ def load_tokenizer(self): def make_training_text(self, prompt: Prompt, output: LLMOutput) -> TrainingText: self.load_tokenizer() - return llama_make_training_text(prompt, output, self.tokenizer) + return trainable_llm_make_training_text(prompt, output, self.tokenizer) def count_tokens(self, messages: list[dict] | str) -> int: self.load_tokenizer() @@ -535,7 +534,7 @@ def make_training_text(self, prompt: Prompt, output: LLMOutput) -> TrainingText: return TrainingText(text="mock trace", n_predicted=10) -def llama_make_training_text(prompt: Prompt, output: LLMOutput, tokenizer) -> TrainingText: +def trainable_llm_make_training_text(prompt: Prompt, output: LLMOutput, tokenizer) -> TrainingText: prompt_text = tokenizer.apply_chat_template(conversation=prompt.messages, tokenize=False) output_text = tokenizer.apply_chat_template([{"role": "assistant", "content": output.content}], tokenize=False) if tokenizer.bos_token and output_text.startswith(tokenizer.bos_token): diff --git a/tests/test_examples.py b/tests/test_examples.py index da92d52..3dc70f5 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -21,7 +21,7 @@ from tapeagents.core import AgentStep, TrainingText from tapeagents.dialog_tape import DialogTape from tapeagents.environment import EmptyEnvironment -from tapeagents.llms import LLAMA, LLM, ReplayLLM +from tapeagents.llms import TrainableLLM, LLM, ReplayLLM from tapeagents.observe import LLMCall, init_sqlite_if_not_exists, retrieve_tape_llm_calls from tapeagents.runtime import replay_tape, replay_tapes from tapeagents.team import TeamTape @@ -33,7 +33,7 @@ def mock_llm(run_dir: str) -> LLM: - llama = LLAMA( + llama = TrainableLLM( base_url="https://api.together.xyz", model_name="meta-llama/Meta-Llama-3-70B-Instruct-Turbo", tokenizer_name="meta-llama/Meta-Llama-3-70B-Instruct",