Let us try how we can build a agent using llama opensource and compare this use case with
ChatGPT & Perplexity.
Go to API page, and generate key, copy and keep it safe.
PS F:/python3.11.exe f:/iMM/aiagent/2_finance_agent.py
DEBUG Debug logs enabled
DEBUG *********** Agent Run Start: 3ccf1064-648a-4654-a6a4-06e111db6a1c ***********
DEBUG Function get_current_stock_price from yfinance_tools added to model.
DEBUG Function get_analyst_recommendations from yfinance_tools added to model.
DEBUG ---------- Groq Response Start ----------
DEBUG ============== system ==============
DEBUG ## Instructions
- Use tables to display data.
- Use markdown to format your answers.
DEBUG ============== user ==============
DEBUG Summarize and compare analyst recommendations and fundamentals for TSL
and NVDA
DEBUG ============== assistant ==============
DEBUG Tool Calls: [
{
"id": "call_wz34",
"function": {
"arguments": "{\"symbol\": \"TSLA\"}",
"name": "get_analyst_recommendations"
},
"type": "function"
},
{
"id": "call_fkv1",
"function": {
"arguments": "{\"symbol\": \"NVDA\"}",
"name": "get_analyst_recommendations"
},
"type": "function"
},
{
"id": "call_rvt4",
"function": {
"arguments": "{\"symbol\": \"TSLA\"}",
"name": "get_current_stock_price"
},
"type": "function"
},
{
"id": "call_0ge1",
"function": {
"arguments": "{\"symbol\": \"NVDA\"}",
"name": "get_current_stock_price"
},
"type": "function"
}
]
DEBUG **************** METRICS START ****************
DEBUG * Time to generate response: 4.1421s
DEBUG * Tokens per second: 22.6938 tokens/s
DEBUG * Input tokens: 703
DEBUG * Output tokens: 94
DEBUG * Total tokens: 797
DEBUG * Completion time: 0.4474s
DEBUG * Prompt time: 0.1129s
DEBUG * Queue time: -1.8120s
DEBUG * Total time: 0.5603s
DEBUG **************** METRICS END ******************
DEBUG Getting function get_analyst_recommendations
DEBUG Getting function get_analyst_recommendations
DEBUG Getting function get_current_stock_price
DEBUG Getting function get_current_stock_price
DEBUG Running: get_analyst_recommendations(symbol=TSLA)
DEBUG Running: get_analyst_recommendations(symbol=NVDA)
DEBUG Running: get_current_stock_price(symbol=TSLA)
DEBUG Running: get_current_stock_price(symbol=NVDA)
DEBUG ---------- Groq Response Start ----------
DEBUG ============== system ==============
DEBUG ## Instructions
- Use tables to display data.
- Use markdown to format your answers.
DEBUG ============== user ==============
DEBUG Summarize and compare analyst recommendations and fundamentals for TSL and NVDA
DEBUG ============== assistant ==============
DEBUG Tool Calls: [
{
"id": "call_wz34",
"function": {
"arguments": "{\"symbol\": \"TSLA\"}",
"name": "get_analyst_recommendations"
},
"type": "function"
},
{
"id": "call_fkv1",
"function": {
"arguments": "{\"symbol\": \"NVDA\"}",
"name": "get_analyst_recommendations"
},
"type": "function"
},
{
"id": "call_rvt4",
"function": {
"arguments": "{\"symbol\": \"TSLA\"}",
"name": "get_current_stock_price"
},
"type": "function"
},
{
"id": "call_0ge1",
"function": {
"arguments": "{\"symbol\": \"NVDA\"}",
"name": "get_current_stock_price"
},
"type": "function"
}
]
DEBUG ============== tool ==============
DEBUG Tool call Id: call_wz34
DEBUG {"0":{"period":"0m","strongBuy":6,"buy":14,"hold":15,"sell":9,"strongSell":4},"1":{"
period":"-1m","strongBuy":6,"buy":14,"hold":15,"sell":8,"strongSell":5},"2":{"period
":"-2m","strongBuy":5,"buy":13,"hold":17,"sell":8,"strongSell":5},"3":{"period":"-3m
","strongBuy":6,"buy":12,"hold":19,"sell":7,"strongSell":4}}
DEBUG ============== tool ==============
DEBUG Tool call Id: call_fkv1
DEBUG {"0":{"period":"0m","strongBuy":12,"buy":46,"hold":5,"sell":0,"strongSell":0},"1":{"
period":"-1m","strongBuy":12,"buy":48,"hold":4,"sell":0,"strongSell":0},"2":{"period
":"-2m","strongBuy":12,"buy":48,"hold":4,"sell":0,"strongSell":0},"3":{"period":"-3m
","strongBuy":11,"buy":48,"hold":3,"sell":0,"strongSell":1}}
DEBUG ============== tool ==============
DEBUG Tool call Id: call_rvt4
DEBUG 394.7400
DEBUG ============== tool ==============
DEBUG Tool call Id: call_0ge1
DEBUG 135.9100
DEBUG ============== assistant ==============
DEBUG ### Analyst Recommendations for TSLA and NVDA
The following tables summarize the analyst recommendations for TSLA and NVDA:
#### TSLA Analyst Recommendations
| Period | Strong Buy | Buy | Hold | Sell | Strong Sell |
| --- | --- | --- | --- | --- | --- |
| 0m | 6 | 14 | 15 | 9 | 4 |
| -1m | 6 | 14 | 15 | 8 | 5 |
| -2m | 5 | 13 | 17 | 8 | 5 |
| -3m | 6 | 12 | 19 | 7 | 4 |
#### NVDA Analyst Recommendations
| Period | Strong Buy | Buy | Hold | Sell | Strong Sell |
| --- | --- | --- | --- | --- | --- |
| 0m | 12 | 46 | 5 | 0 | 0 |
| -1m | 12 | 48 | 4 | 0 | 0 |
| -2m | 12 | 48 | 4 | 0 | 0 |
| -3m | 11 | 48 | 3 | 0 | 1 |
### Comparison of Analyst Recommendations
TSLA has a more mixed set of analyst recommendations, with a significant number of
"Hold" and "Sell" ratings. In contrast, NVDA has a much more positive set of analyst
recommendations, with a large majority of "Strong Buy" and "Buy" ratings.
### Current Stock Prices
The current stock prices for TSLA and NVDA are:
* TSLA: $394.74
* NVDA: $135.91
### Fundamental Comparison
Without additional data, it's difficult to make a direct comparison of the
fundamentals of TSLA and NVDA. However, based on the analyst recommendations, it
appears that NVDA is currently viewed more favorably by analysts.
DEBUG **************** METRICS START ****************
DEBUG * Time to generate response: 2.3808s
DEBUG * Tokens per second: 169.6931 tokens/s
DEBUG * Input tokens: 699
DEBUG * Output tokens: 404
DEBUG * Total tokens: 1103
DEBUG * Completion time: 1.4691s
DEBUG * Prompt time: 0.0763s
DEBUG * Queue time: 0.0188s
DEBUG * Total time: 1.5454s
DEBUG **************** METRICS END ******************
DEBUG ---------- Groq Response End ----------
DEBUG Added 7 Messages to AgentMemory
DEBUG Added AgentRun to AgentMemory
DEBUG --**-- Logging Agent Run
DEBUG *********** Agent Run End: 3ccf1064-648a-4654-a6a4-06e111db6a1c ***********
┏━ Message ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ ┃
┃ Summarize and compare analyst recommendations and fundamentals for TSL and NVDA ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
┏━ Response (11.6s) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ ┃
┃ Running: ┃
┃ ┃
┃ • get_analyst_recommendations(symbol=TSLA) ┃
┃ • get_analyst_recommendations(symbol=NVDA) ┃
┃ • get_current_stock_price(symbol=TSLA) ┃
┃ • get_current_stock_price(symbol=NVDA) ┃
┃ ┃
┃ Analyst Recommendations for TSLA and NVDA ┃
┃ ┃
┃ The following tables summarize the analyst recommendations for TSLA and NVDA: ┃
┃ ┃
┃ TSLA Analyst Recommendations ┃
┃ ┃
┃ ┃
┃ Period Strong Buy Buy Hold Sell Strong Sell ┃
┃ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ┃
┃ 0m 6 14 15 9 4 ┃
┃ -1m 6 14 15 8 5 ┃
┃ -2m 5 13 17 8 5 ┃
┃ -3m 6 12 19 7 4 ┃
┃ ┃
┃ ┃
┃ NVDA Analyst Recommendations ┃
┃ ┃
┃ ┃
┃ Period Strong Buy Buy Hold Sell Strong Sell ┃
┃ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ┃
┃ 0m 12 46 5 0 0 ┃
┃ -1m 12 48 4 0 0 ┃
┃ -2m 12 48 4 0 0 ┃
┃ -3m 11 48 3 0 1 ┃
┃ ┃
┃ ┃
┃ Comparison of Analyst Recommendations ┃
┃ ┃
┃ TSLA has a more mixed set of analyst recommendations, with a significant number of "Hold" ┃
┃ and "Sell" ratings. In contrast, NVDA has a much more positive set of analyst ┃
┃ recommendations, with a large majority of "Strong Buy" and "Buy" ratings. ┃
┃ ┃
┃ Current Stock Prices ┃
┃ ┃
┃ The current stock prices for TSLA and NVDA are: ┃
┃ ┃
┃ • TSLA: $394.74 ┃
┃ • NVDA: $135.91 ┃
┃ ┃
┃ Fundamental Comparison ┃
┃ ┃
┃ Without additional data, it's difficult to make a direct comparison of the fundamentals ┃
┃ of TSLA and NVDA. However, based on the analyst recommendations, it appears that NVDA is ┃
┃ currently viewed more favorably by analysts.