Reputation: 99
I am getting this error when trying to run Crewai
Traceback (most recent call last):
File "/Users/Souradipta_Roy/PycharmProjects/crewaitest/crewaitest.py", line 92, in <module>
result = crew.kickoff(inputs={'topic': 'Internal experts in mining technology'})
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/Souradipta_Roy/anaconda3/envs/crewai/lib/python3.12/site-packages/crewai/crew.py", line 526, in kickoff
self._interpolate_inputs(inputs)
File "/Users/Souradipta_Roy/anaconda3/envs/crewai/lib/python3.12/site-packages/crewai/crew.py", line 1018, in _interpolate_inputs
task.interpolate_inputs(
File "/Users/Souradipta_Roy/anaconda3/envs/crewai/lib/python3.12/site-packages/crewai/task.py", line 311, in interpolate_inputs
self.expected_output = self._original_expected_output.format(**inputs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: 'url'
Exception while exporting Span batch.
Traceback (most recent call last):
File "/Users/Souradipta_Roy/anaconda3/envs/crewai/lib/python3.12/site-packages/urllib3/connectionpool.py", line 789, in urlopen
response = self._make_request(
^^^^^^^^^^^^^^^^^^^
File "/Users/Souradipta_Roy/anaconda3/envs/crewai/lib/python3.12/site-packages/urllib3/connectionpool.py", line 490, in _make_request
raise new_e
File "/Users/Souradipta_Roy/anaconda3/envs/crewai/lib/python3.12/site-packages/urllib3/connectionpool.py", line 466, in _make_request
self._validate_conn(conn)
File "/Users/Souradipta_Roy/anaconda3/envs/crewai/lib/python3.12/site-packages/urllib3/connectionpool.py", line 1095, in _validate_conn
conn.connect()
File "/Users/Souradipta_Roy/anaconda3/envs/crewai/lib/python3.12/site-packages/urllib3/connection.py", line 730, in connect
sock_and_verified = _ssl_wrap_socket_and_match_hostname(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/Souradipta_Roy/anaconda3/envs/crewai/lib/python3.12/site-packages/urllib3/connection.py", line 909, in _ssl_wrap_socket_and_match_hostname
ssl_sock = ssl_wrap_socket(
^^^^^^^^^^^^^^^^
File "/Users/Souradipta_Roy/anaconda3/envs/crewai/lib/python3.12/site-packages/urllib3/util/ssl_.py", line 469, in ssl_wrap_socket
ssl_sock = _ssl_wrap_socket_impl(sock, context, tls_in_tls, server_hostname)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/Souradipta_Roy/anaconda3/envs/crewai/lib/python3.12/site-packages/urllib3/util/ssl_.py", line 513, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/Souradipta_Roy/anaconda3/envs/crewai/lib/python3.12/ssl.py", line 455, in wrap_socket
return self.sslsocket_class._create(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/Souradipta_Roy/anaconda3/envs/crewai/lib/python3.12/ssl.py", line 1041, in _create
self.do_handshake()
File "/Users/Souradipta_Roy/anaconda3/envs/crewai/lib/python3.12/ssl.py", line 1319, in do_handshake
self._sslobj.do_handshake()
ConnectionResetError: [Errno 54] Connection reset by peer
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/Souradipta_Roy/anaconda3/envs/crewai/lib/python3.12/site-packages/requests/adapters.py", line 667, in send
resp = conn.urlopen(
^^^^^^^^^^^^^
File "/Users/Souradipta_Roy/anaconda3/envs/crewai/lib/python3.12/site-packages/urllib3/connectionpool.py", line 843, in urlopen
retries = retries.increment(
^^^^^^^^^^^^^^^^^^
File "/Users/Souradipta_Roy/anaconda3/envs/crewai/lib/python3.12/site-packages/urllib3/util/retry.py", line 474, in increment
raise reraise(type(error), error, _stacktrace)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/Souradipta_Roy/anaconda3/envs/crewai/lib/python3.12/site-packages/urllib3/util/util.py", line 38, in reraise
raise value.with_traceback(tb)
File "/Users/Souradipta_Roy/anaconda3/envs/crewai/lib/python3.12/site-packages/urllib3/connectionpool.py", line 789, in urlopen
response = self._make_request(
^^^^^^^^^^^^^^^^^^^
File "/Users/Souradipta_Roy/anaconda3/envs/crewai/lib/python3.12/site-packages/urllib3/connectionpool.py", line 490, in _make_request
raise new_e
File "/Users/Souradipta_Roy/anaconda3/envs/crewai/lib/python3.12/site-packages/urllib3/connectionpool.py", line 466, in _make_request
self._validate_conn(conn)
File "/Users/Souradipta_Roy/anaconda3/envs/crewai/lib/python3.12/site-packages/urllib3/connectionpool.py", line 1095, in _validate_conn
conn.connect()
File "/Users/Souradipta_Roy/anaconda3/envs/crewai/lib/python3.12/site-packages/urllib3/connection.py", line 730, in connect
sock_and_verified = _ssl_wrap_socket_and_match_hostname(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/Souradipta_Roy/anaconda3/envs/crewai/lib/python3.12/site-packages/urllib3/connection.py", line 909, in _ssl_wrap_socket_and_match_hostname
ssl_sock = ssl_wrap_socket(
^^^^^^^^^^^^^^^^
File "/Users/Souradipta_Roy/anaconda3/envs/crewai/lib/python3.12/site-packages/urllib3/util/ssl_.py", line 469, in ssl_wrap_socket
ssl_sock = _ssl_wrap_socket_impl(sock, context, tls_in_tls, server_hostname)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/Souradipta_Roy/anaconda3/envs/crewai/lib/python3.12/site-packages/urllib3/util/ssl_.py", line 513, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/Souradipta_Roy/anaconda3/envs/crewai/lib/python3.12/ssl.py", line 455, in wrap_socket
return self.sslsocket_class._create(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/Souradipta_Roy/anaconda3/envs/crewai/lib/python3.12/ssl.py", line 1041, in _create
self.do_handshake()
File "/Users/Souradipta_Roy/anaconda3/envs/crewai/lib/python3.12/ssl.py", line 1319, in do_handshake
self._sslobj.do_handshake()
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(54, 'Connection reset by peer'))
The code I am trying to execute is
from typing import List
from crewai import Agent, Task, LLM, Crew
from crewai.tools import tool
llm = LLM(
model="gpt-4o",
base_url="https://openai.prod.ai-gateway.quantumblack.com/0b0e19f0-3019-4d9e-bc36-1bd53ed23dc2/v1",
api_key="5f393389-5fc3-4904-a597-dd56e3b00f42:7ggTi5OqYeCqlLm1PmJ9kkAVk69iWuWI"
)
ddagent = Agent(role="Assistant helping in executing due diligence steps",
goal="""To help an user performing due diligence to achieve a specified task or multiple tasks. "
Sometimes multiple tasks need to be performed. The tasks need not be in a sequence""",
backstory='You are aware about all the detail tasks of due diligence. You have access to the necessary content and best practices',
verbose=True,
memory=True,
llm=llm
)
@tool("get_experts")
def get_experts(topic: str) -> List[str]:
"""Tool returns a list of expert names."""
# Tool logic here
expert_list = []
expert_list.append("Souradipta Roy")
expert_list.append("Dushyant Agarwal")
return expert_list
@tool("get_documents")
def get_documents(topic: str) -> List[str]:
"""Tool returns a list of document names."""
# Tool logic here
documents_list = []
documents_list.append("document 1")
documents_list.append("document 2")
return documents_list
research_task = Task(
description="""
Respond withe appropriate output mentioned in the expected outputs when the user wants to create a survey
or wants to know anything about survey creation or survey analysis.
""",
expected_output="""
Respond with the following:
Great, to create surveys and drive analytics, there are currently two resources to utilize:
a. Survey Templates – Discover our collection of survey templates. The link for that tool is **https://privatecapital.mckinsey.digital/survey-templates**
b. Survey Navigator – Streamline survey creation, analysis, and reporting for client services team. The link for that tool is ** https://surveynavigator.intellisurvey.com/rel-9/admin/#/surveys**
""",
agent=ddagent,
verbose=True
)
internal_experts_task = Task(
description="""
Respond with an appropriate sentence output listing the firm experts based on the topic mentioned.
""",
expected_output="""
Respond with an appropriate sentence output listing the firm experts based on the topic mentioned.
The firm experts are retrieved from the tool get_experts.""",
agent=ddagent,
tools=[get_experts],
verbose=True
)
week_0_ramp_up_task = Task(
description="""
You are responsible for helping the user with Week 0 ramp up. There will be 6 sub-steps in this. If user chooses any of below sub-steps except document recommendations then provide details on respective option chosen.
""",
expected_output="""
If user chooses any of below sub-steps except document recommendations then provide details on respective option chosen.
a. Get transcript for pre-reads or generate an AI Report – “For transcript recommendations, please go to the Interview Insights (Transcript Library) solution to read up on transcripts relevant to the DD topic.” Here is the link for Interview Insights {url}. The Interview Insights platform includes AI-driven insights of thousands of searchable transcripts from prior ENS projects to generate AI Reports.
b. Get document recommendations – When this sub-step is chosen by user, do get_documents function calling to provide document recommendations based on the topic mentioned.
c. Look at past Due Diligences – “For past Due Diligence research, please go to the DD Credentials tools.” Here is the link for DD Credentials: **https://privatecapital.mckinsey.digital/dd-credentials** The DD Credentials tool can help you uncover past targets, outsmart competitors with our expertise, and connect with PE-qualified experts in seconds.
d. Review Past Interview Guides – “A comprehensive collection of modularized question banks for use in creating customer interview questionnaires.” Here is the link for the Interview Guides: **https://privatecapital.mckinsey.digital/interview-guide-templates**
e. Review Module Libraries – “Each Market Model folder includes a ppt overview, data sources, and an Excel model.” Here is the link for the Module Libraries: ** https://privatecapital.mckinsey.digital/market-models**
f. Private Capital Platform – “Resources and central hub for Private Capital and due diligence engagements.” Here is the link for the Private Capital Platform: **https://privatecapital.mckinsey.digital/**""",
agent=ddagent,
tools=[get_documents],
verbose=True
)
crew = Crew(
agents=[ddagent],
tasks=[research_task, internal_experts_task, week_0_ramp_up_task],
verbose=True
)
result = crew.kickoff(inputs={'topic': 'Internal experts in mining technology'})
print(result)
Getting this error in the second last line Any help is appreciated.
Upvotes: 0
Views: 373
Reputation: 21
it's an interpolation error. when calling kickoff()
, you are giving 'topic' as the only variable name to interpolate but have no reference to it (i.e. {topic}
), but in week_0_ramp_up_task
you are interpolating url
(item a. you have {url}
) but aren't passing it as an input in kickoff()
.
editing the code as follows resolved any errors for me:
from typing import List
from crewai import Agent, Task, LLM, Crew
from crewai.tools import tool
inputs={
'topic': 'Internal experts in mining technology',
'url': 'https://privatecapital.mckinsey.digital/survey-templates'
}
llm = LLM(
model="gpt-4o",
base_url="https://openai.prod.ai-gateway.quantumblack.com/0b0e19f0-3019-4d9e-bc36-1bd53ed23dc2/v1",
api_key="YOUR_API_KEY_HERE"
)
ddagent = Agent(role="Assistant helping in executing due diligence steps",
goal="""To help an user performing due diligence to achieve a specified task or multiple tasks. "
Sometimes multiple tasks need to be performed. The tasks need not be in a sequence""",
backstory='You are aware about all the detail tasks of due diligence. You have access to the necessary content and best practices',
verbose=True,
memory=True,
llm=llm
)
@tool("get_experts")
def get_experts(topic: str) -> List[str]:
"""Tool returns a list of expert names."""
# Tool logic here
expert_list = []
expert_list.append("Souradipta Roy")
expert_list.append("Dushyant Agarwal")
return expert_list
@tool("get_documents")
def get_documents(topic: str) -> List[str]:
"""Tool returns a list of document names."""
# Tool logic here
documents_list = []
documents_list.append("document 1")
documents_list.append("document 2")
return documents_list
research_task = Task(
description="""
Respond withe appropriate output mentioned in the expected outputs when the user wants
to create a survey or wants to know anything about survey creation or survey analysis.
""",
expected_output="""
Respond with the following:
Great, to create surveys and drive analytics, there are currently two resources to utilize:
a. Survey Templates - Discover our collection of survey templates. The link for that tool is **https://privatecapital.mckinsey.digital/survey-templates**
b. Survey Navigator - Streamline survey creation, analysis, and reporting for client services team. The link for that tool is ** https://surveynavigator.intellisurvey.com/rel-9/admin/#/surveys**
""",
agent=ddagent,
verbose=True
)
internal_experts_task = Task(
description=f"""
Respond with an appropriate sentence output listing the firm experts based on the {inputs["topic"]} mentioned.
""",
expected_output=f"""
Respond with an appropriate sentence output listing the firm experts based on the {inputs["topic"]} mentioned.
The firm experts are retrieved from the tool get_experts.""",
agent=ddagent,
tools=[get_experts],
verbose=True
)
week_0_ramp_up_task = Task(
description="""
You are responsible for helping the user with Week 0 ramp up. There will be 6 sub-steps in this. If user chooses any of below sub-steps except document recommendations then provide details on respective option chosen.
""",
expected_output=f"""
If user chooses any of below sub-steps except document recommendations then provide details on respective option chosen.
a. Get transcript for pre-reads or generate an AI Report - “For transcript recommendations, please go to the Interview Insights (Transcript Library) solution to read up on transcripts relevant to the DD topic.” Here is the link for Interview Insights {inputs["url"]}. The Interview Insights platform includes AI-driven insights of thousands of searchable transcripts from prior ENS projects to generate AI Reports.
b. Get document recommendations - When this sub-step is chosen by user, do get_documents function calling to provide document recommendations based on the topic mentioned.
c. Look at past Due Diligences - “For past Due Diligence research, please go to the DD Credentials tools.” Here is the link for DD Credentials: **https://privatecapital.mckinsey.digital/dd-credentials** The DD Credentials tool can help you uncover past targets, outsmart competitors with our expertise, and connect with PE-qualified experts in seconds.
d. Review Past Interview Guides - “A comprehensive collection of modularized question banks for use in creating customer interview questionnaires.” Here is the link for the Interview Guides: **https://privatecapital.mckinsey.digital/interview-guide-templates**
e. Review Module Libraries - “Each Market Model folder includes a ppt overview, data sources, and an Excel model.” Here is the link for the Module Libraries: ** https://privatecapital.mckinsey.digital/market-models**
f. Private Capital Platform - “Resources and central hub for Private Capital and due diligence engagements.” Here is the link for the Private Capital Platform: **https://privatecapital.mckinsey.digital/**""",
agent=ddagent,
tools=[get_documents],
verbose=True
)
crew = Crew(
agents=[ddagent],
tasks=[research_task, internal_experts_task, week_0_ramp_up_task],
verbose=True
)
result = crew.kickoff(inputs)
print(result)
Also, FWIW, you should revoke that api key and avoid exposing your keys in the future.
Upvotes: 0