Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Running from Google Colab - Validation error for PlaygroundSettings. #2022

Open
PriyankaBiswas opened this issue Feb 5, 2025 · 7 comments
Labels
bug Something isn't working

Comments

@PriyankaBiswas
Copy link

Description

I am running from Colab, and everything works as per instructions, except connecting to the 7777 server.
As soon as I launch app = Playground(agents=[web_agent, finance_agent]).get_app() I encounter this validation error:

ValidationError: 1 validation error for PlaygroundSettings
env
  Value error, Invalid Playground Env: /root/.bashrc [type=value_error, input_value='/root/.bashrc', input_type=str]
    For further information visit https://errors.pydantic.dev/2.10/v/value_error


Steps to Reproduce

  1. Open Google Colab
!pip install -q condacolab
    import condacolab
    !pip install -q condacolab
    condacolab.install()
    !conda create -p venv #python=3.12
    !source activate /content/venv
    !pip install -r /content/venv/requirements.txt #requirements file - reads correctly
    import os
    from dotenv import load_dotenv
    load_dotenv(dotenv_path='/content/venv/.env') #.env file - reads correctly
  1. #Run Playground code
    ```
    from agno.agent import Agent
    from agno.models.openai import OpenAIChat
    from agno.playground import Playground, serve_playground_app
    from agno.storage.agent.sqlite import SqliteAgentStorage
    from agno.tools.duckduckgo import DuckDuckGoTools
    from agno.tools.yfinance import YFinanceTools

     agent_storage: str = "tmp/agents.db"
     
     web_agent = Agent(
         name="Web Agent",
         model=OpenAIChat(id="gpt-4o"),
         tools=[DuckDuckGoTools()],
         instructions=["Always include sources"],
         # Store the agent sessions in a sqlite database
         storage=SqliteAgentStorage(table_name="web_agent", db_file=agent_storage),
         # Adds the current date and time to the instructions
         add_datetime_to_instructions=True,
         # Adds the history of the conversation to the messages
         add_history_to_messages=True,
         # Number of history responses to add to the messages
         num_history_responses=5,
         # Adds markdown formatting to the messages
         markdown=True,
     )
     
     finance_agent = Agent(
         name="Finance Agent",
         model=OpenAIChat(id="gpt-4o"),
         tools=[YFinanceTools(stock_price=True, analyst_recommendations=True, company_info=True, company_news=True)],
         instructions=["Always use tables to display data"],
         storage=SqliteAgentStorage(table_name="finance_agent", db_file=agent_storage),
         add_datetime_to_instructions=True,
         add_history_to_messages=True,
         num_history_responses=5,
         markdown=True,
     )
     
     app = Playground(agents=[web_agent, finance_agent]).get_app()
    

## Expected Behavior
Local host connected to https://app.agno.com/playground

## Actual Behavior
Returned this Validation error. 

ValidationError Traceback (most recent call last)
in <cell line: 0>()
37 )
38
---> 39 app = Playground(agents=[web_agent, finance_agent]).get_app()

2 frames
/usr/local/lib/python3.11/site-packages/pydantic/main.py in init(self, **data)
212 # __tracebackhide__ tells pytest and some other tools to omit this function from tracebacks
213 tracebackhide = True
--> 214 validated_self = self.pydantic_validator.validate_python(data, self_instance=self)
215 if self is not validated_self:
216 warnings.warn(

ValidationError: 1 validation error for PlaygroundSettings
env
Value error, Invalid Playground Env: /root/.bashrc [type=value_error, input_value='/root/.bashrc', input_type=str]
For further information visit https://errors.pydantic.dev/2.10/v/value_error


## Screenshots or Logs (if applicable)
Include any relevant screenshots or error logs that demonstrate the issue.

## Environment
- OS: macOS
- Browser Chrome - latest
- Agno Version: (e.g. v1.0.0)
- External Dependency Versions: (e.g., yfinance 0.2.52)
- Additional Environment Details: (e.g., Python 3.10)

## Possible Solutions - what I already tried:
1. Setting ENV to local. 

Set new env as venv

os.environ["ENV"] = '/content/venv/.env'

2.  Manually set the valid playground environment 
`os.environ["ENV"] = "prd"`

3. I have the agents working from Colab, just the Playground is not working. 

Suggest any ideas you might have to fix or address the issue.

## Additional Context
Add any other context or details about the problem here.
@PriyankaBiswas PriyankaBiswas added the bug Something isn't working label Feb 5, 2025
@manthanguptaa
Copy link
Contributor

Hey @PriyankaBiswas! I was able to replicate the issue and resolve it. I am sharing the code with you

!pip install agno
!pip install fastapi
!pip install duckduckgo-search
!pip install yfinance
!pip install nest-asyncio
!pip install uvicorn

import os
os.environ["AGNO_API_KEY"] = "your key"

from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.playground import Playground, serve_playground_app
from agno.storage.agent.sqlite import SqliteAgentStorage
from agno.tools.duckduckgo import DuckDuckGoTools
from agno.tools.yfinance import YFinanceTools
from agno.playground.settings import PlaygroundSettings

agent_storage: str = "tmp/agents.db"
 
web_agent = Agent(
     name="Web Agent",
     model=OpenAIChat(id="gpt-4o"),
     tools=[DuckDuckGoTools()],
     instructions=["Always include sources"],
     # Store the agent sessions in a sqlite database
     storage=SqliteAgentStorage(table_name="web_agent", db_file=agent_storage),
     # Adds the current date and time to the instructions
     add_datetime_to_instructions=True,
     # Adds the history of the conversation to the messages
     add_history_to_messages=True,
     # Number of history responses to add to the messages
     num_history_responses=5,
     # Adds markdown formatting to the messages
     markdown=True,
)
 
finance_agent = Agent(
    name="Finance Agent",
    model=OpenAIChat(id="gpt-4o"),
    tools=[YFinanceTools(stock_price=True, analyst_recommendations=True, company_info=True, company_news=True)],
    instructions=["Always use tables to display data"],
    storage=SqliteAgentStorage(table_name="finance_agent", db_file=agent_storage),
    add_datetime_to_instructions=True,
    add_history_to_messages=True,
    num_history_responses=5,
    markdown=True,
)

settings = PlaygroundSettings(env="prd")
 
app = Playground(
    agents=[web_agent, finance_agent],
    settings=settings,
).get_app()

if __name__ == "__main__":
    serve_playground_app("Untitled0:app", reload=True)

let me know if this works for you

@PriyankaBiswas
Copy link
Author

@manthanguptaa Thank you for looking into this issue, but it's not working (see screenshot). I tried your code exactly as you shared. I get a executing command that times out after a long wait.

And, I had previously tried setting the ENV to values "dev" "prd" "stg" - the three env values accepted by the PlaygroundSettings original code. It didn't work. 2nd screenshot showing AGNO playground doesn't detect live server.

Image

Image

@dirkbrnd
Copy link
Contributor

Hi @PriyankaBiswas
Where is your server running?

@PriyankaBiswas
Copy link
Author

PriyankaBiswas commented Feb 12, 2025 via email

@dirkbrnd
Copy link
Contributor

So it would be running on localhost there, but the playground wouldn't be able to find the application since it isn't running on the same machine where you are accessing the playground. If you run your application locally and access the playground on your browser, then the playground can find the application.

@PriyankaBiswas
Copy link
Author

PriyankaBiswas commented Feb 12, 2025 via email

@dirkbrnd
Copy link
Contributor

dirkbrnd commented Feb 13, 2025

Hi @PriyankaBiswas
We are working on allowing users to deploy their agents via our Playground (i.e. in our cloud environment). We'll also look at cases like these which are really "BYO" agent, where you run it on an arbitrary server.

On your server it looks like the the app is unable to connect to the playground, as you say. Are you sure the outbound network settings allows? Also have you set your AGNO_API_KEY where it is running?
Once it is connected, you would have to select the public IP or URL where your service is running.
I think you might also have to update CORS settings in your api/settings.py file.

Thanks for raising.

@dirkbrnd dirkbrnd reopened this Feb 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants