Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks.
The script is unable to connect to the OpenAI API because the server is using a self-signed SSL certificate. This certificate cannot be verified by the script, resulting in a connection error.
import os
import ssl
from crewai import Agent, Task, Crew, Process
from langchain_community.tools import DuckDuckGoSearchRun
researcher = Agent(
role='Senior Research Analyst',
goal='Uncover cutting-edge developments in AI and data science',
backstory="""You work at a leading tech think tank.
Your expertise lies in identifying emerging trends.
You have a knack for dissecting complex data and presenting actionable insights.""",
verbose=True,
allow_delegation=False,
tools=[search_tool]
)
writer = Agent(
role='Tech Content Strategist',
goal='Craft compelling content on tech advancements',
backstory="""You are a renowned Content Strategist, known for your insightful and engaging articles.
You transform complex concepts into compelling narratives.""",
verbose=True,
allow_delegation=True,
)
task1 = Task(
description="""Conduct a comprehensive analysis of the latest advancements in AI in 2024.
Identify key trends, breakthrough technologies, and potential industry impacts.
Your final answer MUST be a full analysis report""",
agent=researcher
)
task2 = Task(
description="""Using the insights provided, develop an engaging blog
post that highlights the most significant AI advancements.
Your post should be informative yet accessible, catering to a tech-savvy audience.
Make it sound cool, avoid complex words so it doesn't sound like AI.
Your final answer MUST be the full blog post of at least 4 paragraphs.""",
agent=writer
)
Hey guy! Any workaround for this?
The script is unable to connect to the OpenAI API because the server is using a self-signed SSL certificate. This certificate cannot be verified by the script, resulting in a connection error.
import os import ssl from crewai import Agent, Task, Crew, Process from langchain_community.tools import DuckDuckGoSearchRun
os.environ["OPENAI_API_KEY"] = "api_key"
ssl_context = ssl.create_default_context()
ssl_context = ssl._create_unverified_context
ssl_context.check_hostname = False
ssl_context.verify_mode = ssl.CERT_NONE
search_tool = DuckDuckGoSearchRun()
ssl._create_default_https_context = ssl._create_unverified_context
researcher = Agent( role='Senior Research Analyst', goal='Uncover cutting-edge developments in AI and data science', backstory="""You work at a leading tech think tank. Your expertise lies in identifying emerging trends. You have a knack for dissecting complex data and presenting actionable insights.""", verbose=True, allow_delegation=False, tools=[search_tool] ) writer = Agent( role='Tech Content Strategist', goal='Craft compelling content on tech advancements', backstory="""You are a renowned Content Strategist, known for your insightful and engaging articles. You transform complex concepts into compelling narratives.""", verbose=True, allow_delegation=True, )
task1 = Task( description="""Conduct a comprehensive analysis of the latest advancements in AI in 2024. Identify key trends, breakthrough technologies, and potential industry impacts. Your final answer MUST be a full analysis report""", agent=researcher )
task2 = Task( description="""Using the insights provided, develop an engaging blog post that highlights the most significant AI advancements. Your post should be informative yet accessible, catering to a tech-savvy audience. Make it sound cool, avoid complex words so it doesn't sound like AI. Your final answer MUST be the full blog post of at least 4 paragraphs.""", agent=writer )
crew = Crew( agents=[researcher, writer], tasks=[task1, task2], verbose=2, )
result = crew.kickoff()
print("######################") print(result)
ERROR:
File /opt/homebrew/Caskroom/miniconda/base/envs/crew_ai/lib/python3.11/site-packages/httpx/_transports/default.py:86, in map_httpcore_exceptions() 85 message = str(exc) ---> 86 raise mapped_exc(message) from exc
ConnectError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1006)
The above exception was the direct cause of the following exception:
APIConnectionError Traceback (most recent call last) Cell In[1], line 57 42 task2 = Task( 43 description="""Using the insights provided, develop an engaging blog 44 post that highlights the most significant AI advancements. (...) 48 agent=writer 49 ) 51 crew = Crew( 52 agents=[researcher, writer], 53 tasks=[task1, task2], 54 verbose=2, 55 ) ---> 57 result = crew.kickoff() 59 print("######################") 60 print(result)
File /opt/homebrew/Caskroom/miniconda/base/envs/crew_ai/lib/python3.11/site-packages/openai/_base_client.py:952, in SyncAPIClient._request(self, cast_to, options, remaining_retries, stream, stream_cls) 942 return self._retry_request( 943 options, 944 cast_to, (...) 948 response_headers=None, 949 ) 951 log.debug("Raising connection error") --> 952 raise APIConnectionError(request=request) from err 954 log.debug( 955 'HTTP Request: %s %s "%i %s"', request.method, request.url, response.status_code, response.reason_phrase 956 ) 958 try:
APIConnectionError: Connection error.