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]: Can't run Agentops in .ipynb whereas the same code works in a .py file. #875

Open
3 tasks
Niharrrrrr opened this issue Mar 21, 2025 · 3 comments
Open
3 tasks
Labels
bug Something isn't working

Comments

@Niharrrrrr
Copy link

Contact Details

[email protected]

πŸ“¦ Package Version

0.4.4

🎞️ Framework Version

CrewAI : 0.100.0

πŸ”Ž Describe the Bug

I am running the code :

`import agentops
from crewai import Agent, Crew, Process, Task,LLM
import openai
from openai import OpenAI
import os
from langchain_openai import ChatOpenAI
from dotenv import load_dotenv
from agentops import track_tool
load_dotenv()

agentops.init(api_key=os.getenv("AGENTOPS_API_KEY"),default_tags=['crewai'],auto_start_session=True)
OPENAI_API_KEY=os.getenv("OPENAI_API_KEY")
llm=LLM(api_key=OPENAI_API_KEY,model='gpt-4o')

Create specialized agents

researcher = Agent(
role="Market Research Specialist",
goal="Find comprehensive market data on emerging technologies",
backstory="You are an expert at discovering market trends and gathering data.",
llm=llm
)

analyst = Agent(
role="Market Analyst",
goal="Analyze market data and identify key opportunities",
backstory="You excel at interpreting market data and spotting valuable insights.",
llm=llm
)

Define their tasks

research_task = Task(
description="Research the current market landscape for AI-powered healthcare solutions",
expected_output="Comprehensive market data including key players, market size, and growth trends",
agent=researcher
)

analysis_task = Task(
description="Analyze the market data and identify the top 3 investment opportunities",
expected_output="Analysis report with 3 recommended investment opportunities and rationale",
agent=analyst,
context=[research_task]
)

Create the crew

market_analysis_crew = Crew(
agents=[researcher, analyst],
tasks=[research_task, analysis_task],
process=Process.sequential,
verbose=True
)

Run the crew

result = market_analysis_crew.kickoff()
print(result.raw)
`

When I run this in .py file it works I can see everything but I want to use this in my notebook itself. Agentops is not initializing in notebook , why is this happening and how to resolve?

🀝 Contribution

  • Yes, I'd be happy to submit a pull request with these changes.
  • I need some guidance on how to contribute.
  • I'd prefer the AgentOps team to handle this update.
@Niharrrrrr Niharrrrrr added the bug Something isn't working label Mar 21, 2025
@areibman
Copy link
Contributor

Crew version 0.100 is kinda buggy, can you try upgrading that and try again? @Niharrrrrr

@Niharrrrrr
Copy link
Author

Yes I upgraded to 0.108 the latest of crew still doesn't work

@areibman
Copy link
Contributor

I'm having difficulties replicating the issue @Niharrrrrr

Here's my notebook run:

Image

.py file run:


<img width="521" alt="Image" src="https://github.com/user-attachments/assets/6ac950b3-8ee1-4a43-8f8c-e645fa5e730f" />

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

2 participants