Skip to content

Commit

Permalink
More docs tweaks (#16684)
Browse files Browse the repository at this point in the history
  • Loading branch information
seldo authored Oct 24, 2024
1 parent 3d981aa commit 6d4e694
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 24 deletions.
39 changes: 17 additions & 22 deletions docs/docs/examples/agent/lats_agent.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@
"id": "bb60646b-d09b-41c4-b799-eaef0b5b8471",
"metadata": {},
"source": [
"## Setup Agent\n",
"## Set up Agent\n",
"\n",
"Now we can setup the LATS agent.\n",
"Now we can set up the LATS agent.\n",
"\n",
"Here, `num_expansions` refers to the number of possible sub-actions to explore under each node. `num_expansions=2` means we will explore to possible next-actions for every parent action.\n",
"\n",
Expand All @@ -220,15 +220,14 @@
"source": [
"from llama_index.agent.lats import LATSAgentWorker\n",
"\n",
"\n",
"agent_worker = LATSAgentWorker.from_tools(\n",
" query_engine_tools,\n",
" llm=llm,\n",
" num_expansions=2,\n",
" max_rollouts=3, # using -1 for unlimited rollouts\n",
" verbose=True,\n",
")\n",
"agent = agent.as_worker()"
"agent = agent_worker.as_agent()"
]
},
{
Expand Down Expand Up @@ -265,32 +264,28 @@
"output_type": "stream",
"text": [
"\u001b[1;3;32m> Selecting node to expand: Observation: Given the risk factors of Uber and Lyft described in their 10K files, which company is performing better? Please use concrete numbers to inform your decision.\n",
"\u001b[0m\u001b[1;3;33m> Got candidates: ['Review the 10K files of Uber and Lyft to extract relevant financial data and risk factors.', 'Compare key financial metrics from the 10K files of Uber and Lyft, such as revenue, profit margins, and growth rates.']\n",
"\u001b[0m\u001b[1;3;33m> Got candidates: ['Retrieve and compare the latest financial metrics from the 10K files of Uber and Lyft, such as revenue growth, profit margins, and debt levels.', 'Analyze the specific risk factors listed in the 10K files for Uber and Lyft and determine which company has a more manageable risk profile.']\n",
"\u001b[0m=== Calling Function ===\n",
"Calling function: uber_10k with args: {\"input\": \"Provide key financial metrics from Uber's 10K for 2021, including revenue, profit margins, and growth rates.\"}\n",
"Calling function: uber_10k with args: {\"input\": \"What is the revenue growth, profit margins, and debt levels for Uber in 2021?\"}\n",
"=== Calling Function ===\n",
"Calling function: uber_10k with args: {\"input\": \"What are the key financial figures and risk factors for Uber in 2021?\"}\n",
"Calling function: lyft_10k with args: {\"input\": \"What are the main risk factors listed in the Lyft 10K report for 2021?\"}\n",
"=== Function Output ===\n",
"In 2021, Uber Technologies, Inc. reported a revenue of $17,455 million. The company experienced a significant revenue growth rate of 57% compared to the previous year. The total costs and expenses were $21,289 million, leading to a loss from operations of $3,834 million. The net loss attributable to Uber Technologies, Inc. was $496 million. The costs as a percentage of revenue included cost of revenue (exclusive of depreciation and amortization) at 54%, operations and support at 11%, sales and marketing at 27%, research and development at 12%, general and administrative at 13%, and depreciation and amortization at 5%. The total costs and expenses amounted to 122% of the revenue. Other income (expense), net, significantly improved, contributing 19% to the revenue.\n",
"In 2021, Uber's revenue grew by 57%, increasing from $11,139 million in 2020 to $17,455 million. The company's loss from operations improved, showing a decrease from 44% of revenue in 2020 to 22% in 2021. However, Uber still reported a net loss, which also improved significantly from 61% of revenue in 2020 to just 3% in 2021. The interest expense as a percentage of revenue decreased from 4% in 2020 to 3% in 2021, indicating a slight reduction in debt levels relative to revenue.\n",
"=== Function Output ===\n",
"Uber Technologies, Inc., in its 2021 financial statements, consolidates its wholly-owned and majority-owned subsidiaries, as well as variable interest entities where it is the primary beneficiary. The financial statements are prepared in accordance with GAAP, and management uses estimates and assumptions that affect reported financial figures, such as the fair values of investments, useful lives of assets, and reserves for income taxes and insurance, among others. These estimates consider the impact of the COVID-19 pandemic on market data and investment recoverability.\n",
"\n",
"Key financial risks for Uber include concentration of credit risk, where cash and other receivables are potentially subject to credit risk concentration. The company's cash, cash equivalents, and securities consist largely of high-credit-quality money market funds, U.S. government and agency securities, and corporate debt securities. Despite exceeding insured limits, these are placed with financial institutions that Uber assesses as having high credit quality. Uber has not reported material losses related to these concentrations during the periods presented. Additionally, Uber's performance and strategy involve forward-looking statements subject to various risks and uncertainties, which could materially affect actual results.\n",
"\u001b[1;3;34m> Generated new reasoning step: Thought: To compare the performance of Uber and Lyft using their 10K files, I need to gather financial data and risk factors from both companies. I will start by querying the Uber 10K tool.\n",
"The main risk factors listed in the Lyft 10K report for 2021 include general economic factors such as the impact of the COVID-19 pandemic, natural disasters, and macroeconomic conditions. Operational factors include Lyft's limited operating history, the unpredictability of financial performance, competition, the growth of the ridesharing market, and the ability to attract and retain qualified drivers and riders. Additional risks involve insurance coverage issues, reliance on third-party providers, and challenges related to autonomous vehicle technology. There are also concerns about the company's reputation, the accuracy of background checks on drivers, and cybersecurity. Moreover, Lyft notes the potential adverse effects on its business due to new or changing regulations, the need to manage growth effectively, and the ability to maintain profitability.\n",
"\u001b[1;3;34m> Generated new reasoning step: Thought: The user has asked for the latest financial metrics from the 10K files of Uber and Lyft, including revenue growth, profit margins, and debt levels. I need to use the tools to retrieve this information.\n",
"Action: uber_10k\n",
"Action Input: {'input': 'What are the key financial figures and risk factors for Uber in 2021?'}\n",
"Observation: Uber Technologies, Inc., in its 2021 financial statements, consolidates its wholly-owned and majority-owned subsidiaries, as well as variable interest entities where it is the primary beneficiary. The financial statements are prepared in accordance with GAAP, and management uses estimates and assumptions that affect reported financial figures, such as the fair values of investments, useful lives of assets, and reserves for income taxes and insurance, among others. These estimates consider the impact of the COVID-19 pandemic on market data and investment recoverability.\n",
"\n",
"Key financial risks for Uber include concentration of credit risk, where cash and other receivables are potentially subject to credit risk concentration. The company's cash, cash equivalents, and securities consist largely of high-credit-quality money market funds, U.S. government and agency securities, and corporate debt securities. Despite exceeding insured limits, these are placed with financial institutions that Uber assesses as having high credit quality. Uber has not reported material losses related to these concentrations during the periods presented. Additionally, Uber's performance and strategy involve forward-looking statements subject to various risks and uncertainties, which could materially affect actual results.\n",
"\u001b[0m\u001b[1;3;34m> Generated new reasoning step: Thought: The current language of the user is English. I need to use tools to gather detailed financial metrics from the 10K files of Uber and Lyft.\n",
"Action: uber_10k\n",
"Action Input: {'input': \"Provide key financial metrics from Uber's 10K for 2021, including revenue, profit margins, and growth rates.\"}\n",
"Observation: In 2021, Uber Technologies, Inc. reported a revenue of $17,455 million. The company experienced a significant revenue growth rate of 57% compared to the previous year. The total costs and expenses were $21,289 million, leading to a loss from operations of $3,834 million. The net loss attributable to Uber Technologies, Inc. was $496 million. The costs as a percentage of revenue included cost of revenue (exclusive of depreciation and amortization) at 54%, operations and support at 11%, sales and marketing at 27%, research and development at 12%, general and administrative at 13%, and depreciation and amortization at 5%. The total costs and expenses amounted to 122% of the revenue. Other income (expense), net, significantly improved, contributing 19% to the revenue.\n",
"Action Input: {'input': 'What is the revenue growth, profit margins, and debt levels for Uber in 2021?'}\n",
"Observation: In 2021, Uber's revenue grew by 57%, increasing from $11,139 million in 2020 to $17,455 million. The company's loss from operations improved, showing a decrease from 44% of revenue in 2020 to 22% in 2021. However, Uber still reported a net loss, which also improved significantly from 61% of revenue in 2020 to just 3% in 2021. The interest expense as a percentage of revenue decreased from 4% in 2020 to 3% in 2021, indicating a slight reduction in debt levels relative to revenue.\n",
"\u001b[0m\u001b[1;3;34m> Generated new reasoning step: Thought: The current language of the user is English. I need to use tools to extract information about the specific risk factors from the 10K files of Uber and Lyft to compare their risk profiles.\n",
"Action: lyft_10k\n",
"Action Input: {'input': 'What are the main risk factors listed in the Lyft 10K report for 2021?'}\n",
"Observation: The main risk factors listed in the Lyft 10K report for 2021 include general economic factors such as the impact of the COVID-19 pandemic, natural disasters, and macroeconomic conditions. Operational factors include Lyft's limited operating history, the unpredictability of financial performance, competition, the growth of the ridesharing market, and the ability to attract and retain qualified drivers and riders. Additional risks involve insurance coverage issues, reliance on third-party providers, and challenges related to autonomous vehicle technology. There are also concerns about the company's reputation, the accuracy of background checks on drivers, and cybersecurity. Moreover, Lyft notes the potential adverse effects on its business due to new or changing regulations, the need to manage growth effectively, and the ability to maintain profitability.\n",
"\u001b[0m\u001b[1;3;38;5;200m> Evaluation for input Given the risk factors of Uber and Lyft described in their 10K files, which company is performing better? Please use concrete numbers to inform your decision.\n",
": score=9 is_done=False reasoning=\"The conversation history indicates a methodical approach to answering the query about which company, Uber or Lyft, is performing better based on their 10K filings. The observation and thought processes correctly identify the need to compare key financial figures and risk factors from both companies' 10K files. The action taken to query the Uber 10K tool is appropriate and directly addresses part of the query by obtaining Uber's financial data and identifying key risks.\\n\\nHowever, the answer is not yet complete as the information for Lyft has not been gathered, and a direct comparison between the two companies has not been made. The trajectory so far is correct in terms of the steps taken towards gathering the necessary data, but it is incomplete as more information is needed to fully answer the query.\"\n",
": score=8 is_done=False reasoning=\"The conversation trajectory indicates a focused effort towards answering the query about comparing Uber and Lyft based on their 10K financial metrics. The actions taken to retrieve Uber's financial data from 2021, including revenue growth, profit margins, and debt levels, align well with the requirements of the question. However, the information for Lyft has not yet been retrieved or compared, which is necessary for a complete and correct evaluation of which company is performing better. Thus, the process is correct in approach but incomplete in execution.\"\n",
"\n",
"\u001b[0m\u001b[1;3;38;5;200m> Evaluation for input Given the risk factors of Uber and Lyft described in their 10K files, which company is performing better? Please use concrete numbers to inform your decision.\n",
": score=8 is_done=False reasoning=\"The conversation so far has correctly focused on extracting key financial metrics from the 10K files of Uber and Lyft, which is essential for answering the query about which company is performing better. The action taken to retrieve Uber's financial metrics from its 10K file is correct and relevant to the query. The observation provides detailed information about Uber's revenue, growth rate, and profit margins, which are crucial data points needed to assess the company's performance.\\n\\nHowever, the conversation is not yet complete as it lacks the corresponding financial data for Lyft. Without comparing similar metrics from Lyft, a complete evaluation cannot be made. Therefore, the next logical step would be to retrieve Lyft's financial metrics from its 10K file to enable a comprehensive comparison. The trajectory is on the right path but needs to continue gathering and analyzing the necessary data to reach a conclusion.\"\n",
": score=7 is_done=False reasoning=\"The conversation so far has correctly identified and extracted the main risk factors from Lyft's 10K report, which is a necessary step towards comparing the risk profiles of Uber and Lyft. However, the conversation has not yet addressed the risk factors from Uber's 10K report, which is essential for a comprehensive comparison. Therefore, the conversation is on the right track but incomplete as it only covers half of the necessary data. The score of 7 reflects that the correct direction is being taken but the task is not yet completed.\"\n",
"\n",
"\u001b[0m\u001b[1;3;32m> Got final response: I am still thinking.\n",
"\u001b[0m"
Expand Down
3 changes: 2 additions & 1 deletion docs/docs/llama_cloud/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ LlamaCloud allows you to spend less time wrangling with your data and more time

## Resources

- [LlamaCloud documentation](https://docs.cloud.llamaindex.ai/)
- If you're interested in LlamaCloud, [come talk to us](https://www.llamaindex.ai/contact).
- [LlamaParse](./llama_parse.md) is available to **everyone** via self-serve (with free and premium tiers). [Sign up here](cloud.llamaindex.ai).
- [LlamaParse](./llama_parse.md) is available to everyone: [sign up](cloud.llamaindex.ai) by signing up for LlamaCloud.
- [LlamaCloud launch blog post](https://www.llamaindex.ai/blog/introducing-llamacloud-and-llamaparse-af8cedf9006b)
1 change: 1 addition & 0 deletions docs/docs/llama_cloud/llama_parse.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ LlamaParse exists as a standalone API and also as part of the LlamaCloud platfor

## Resources

- [LlamaParse documentation](https://docs.cloud.llamaindex.ai/llamaparse/getting_started/web_ui)
- [Sign up by signing up for LlamaCloud](https://cloud.llamaindex.ai/)
- [Launch blog post](https://www.llamaindex.ai/blog/launching-the-first-genai-native-document-parsing-platform)
16 changes: 15 additions & 1 deletion docs/docs/module_guides/workflow/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,21 @@ class MyWorkflow(Workflow):

## Streaming Events

You can also iterate over events as they come in. This is useful for streaming purposes, showing progress, or for debugging.
You can also iterate over events as they come in. This is useful for streaming purposes, showing progress, or for debugging. The handler object will emit events that are explicitly written to the stream using `ctx.write_event_to_stream()`:

```python
class ProgressEvent(Event):
msg: str


class MyWorkflow(Workflow):
@step
async def step_one(self, ctx: Context, ev: StartEvent) -> FirstEvent:
ctx.write_event_to_stream(ProgressEvent(msg="Step one is happening"))
return FirstEvent(first_output="First step complete.")
```

You can then pick up the events like this:

```python
w = MyWorkflow(...)
Expand Down

0 comments on commit 6d4e694

Please sign in to comment.