Skip to content

Notebook samples outdated?? #245

Closed
Closed
@biggikalli

Description

I tried Autogen with a Github Codespace, straight from the repo and a fresh Openai API key for GPT-4.
Every single notebook I tried resulted in errors while it burned through $20 in API calls.

What is the most likley reason for this?

See below sample results from two of the notebooks I ran.

The "agentchat_teaching.ipynb" notebook:

`--------------------------------------------------------------------------------

EXECUTING CODE BLOCK 0 (inferred language is python)...
user_proxy (to assistant):

exitcode: 0 (execution succeeded)
Code output:


assistant (to user_proxy):

I apologize for the inconvenience. It seems like there are no papers on arXiv that match the search queries "trust calibration in AI" or "trust in AI".

This could be due to a few reasons:

  1. The topic is very specific and there might not be many papers on it yet.
  2. The papers on this topic might not be on arXiv. They could be on other databases or journals.
  3. The terminology used in the papers might be different. For example, they might use terms like "confidence in AI" or "reliability of AI" instead of "trust".

I recommend trying to search for papers on other databases or journals, or using different search queries.

TERMINATE
`

The "agentchat_auto_feedback_from_code_execution" notebook:

`user_proxy (to assistant):

exitcode: 1 (execution failed)
Code output:
Traceback (most recent call last):
File "", line 20, in
meta_start_price = get_stock_price("FB", start_date)
File "", line 16, in get_stock_price
return float(data["Time Series (Daily)"][date.strftime("%Y-%m-%d")]["4. close"])
KeyError: 'Time Series (Daily)'


assistant (to user_proxy):

I apologize for the confusion. The error message suggests that the Alpha Vantage API response does not contain the "Time Series (Daily)" key. This could be due to a variety of reasons, such as an invalid API key, an invalid stock symbol, or issues with the Alpha Vantage API.

Unfortunately, without more information, it's difficult to determine the exact cause of the problem. However, I can suggest a modification to the code to print the API response. This can help us understand what's going wrong.

Here's the modified code:

# python code
import datetime
import requests
import json

# Get the current date
current_date = datetime.date.today()

# Define the Alpha Vantage API key
api_key = "YOUR_ALPHA_VANTAGE_API_KEY"

# Define the function to get the stock price
def get_stock_price(symbol, date):
    response = requests.get(f"https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol={symbol}&apikey={api_key}")
    data = json.loads(response.text)
    print(data)  # Print the API response
    return float(data["Time Series (Daily)"][date.strftime("%Y-%m-%d")]["4. close"])

# Get the stock prices at the start of the year
start_date = datetime.date(current_date.year, 1, 1)
meta_start_price = get_stock_price("FB", start_date)
tesla_start_price = get_stock_price("TSLA", start_date)

# Get the current stock prices
meta_current_price = get_stock_price("FB", current_date)
tesla_current_price = get_stock_price("TSLA", current_date)

# Calculate the YTD gain
meta_ytd_gain = ((meta_current_price - meta_start_price) / meta_start_price) * 100
tesla_ytd_gain = ((tesla_current_price - tesla_start_price) / tesla_start_price) * 100

print("META (FB) YTD gain:", meta_ytd_gain, "%")
print("TESLA YTD gain:", tesla_ytd_gain, "%")

Please replace "YOUR_ALPHA_VANTAGE_API_KEY" with your actual Alpha Vantage API key. If you don't have an API key, you can get one for free by signing up on the Alpha Vantage website.

Please note that the Alpha Vantage free API has a limit of 5 API requests per minute and 500 API requests per day. If you exceed these limits, you may need to wait for a while before you can make more API requests.


EXECUTING CODE BLOCK 0 (inferred language is python)...
user_proxy (to assistant):

exitcode: 1 (execution failed)
Code output:
Traceback (most recent call last):
File "", line 21, in
meta_start_price = get_stock_price("FB", start_date)
File "", line 17, in get_stock_price
return float(data["Time Series (Daily)"][date.strftime("%Y-%m-%d")]["4. close"])
KeyError: 'Time Series (Daily)'

--------------------------------------------------------------------------------`

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions