Hi , I wanted to use Snowflake Cortex LLM in Crew AI but did not find any way how do I do it , kindly help me with a short implementation example , because , Snowflake cortex LLMs are approved for us and we can only use those , so need help in setting up Crew AI agents which use Snowflake cortex LLMs
Following is the custom Langchain class code I tried
class SnowflakeCortexLLM:
def init(self, sp_session, model=โclaude-3-5-sonnetโ):
self.sp_session = sp_session
self.model = model
def call(self, prompt, **kwargs):
"""This method will be called by CrewAI"""
try:
# Properly escape single quotes in the prompt
# This is critical for SQL injection prevention
safe_prompt = prompt.replace("'", "''")
# Execute Cortex function
result_df = self.sp_session.sql(
f"SELECT complete('{self.model}', '{safe_prompt}')"
).collect()
# Extract response from result
return result_df[0][0] if result_df else "No response from Cortex."
except Exception as e:
print(f"Error in Snowflake Cortex LLM: {e}")
return f"Error: {str(e)}"
chat = SnowflakeCortexLLM(sp_session = session)
I used this chat in Crew AI agents ,
data_analyst_agent = Agent(
role=โData Analystโ,
goal="Monitor and analyze market data in real-time "
โto identify trends and predict market movements.โ,
backstory="Specializing in financial markets, this agent "
"uses statistical modeling and machine learning "
"to provide crucial insights. With a knack for data, "
"the Data Analyst Agent is the cornerstone for "
โinforming trading decisions.โ,
verbose=True,
allow_delegation=True,
llm = {
โproviderโ: โcustomโ,
โconfigโ: chat
},
tools = [ simple_search_tool , web_scraper]
)
I have already added the connection parameters and authentication part to form connection with snowflake , I get the following error on using it
After authentication got the following error
Crew: crew
โโโ Task: b8b498ad-76ee-49ec-8a60-705aeafe29b7
Status: Executing Taskโฆ
Crew: crew
โโโ Task: b8b498ad-76ee-49ec-8a60-705aeafe29b7
Status: Executing Taskโฆ
โโโ Agent: Crew Manager
Status: In Progress
Agent: Crew Manager
Task: Continuously monitor and analyze market data for the selected stock (AAPL). Use statistical modeling and machine learning to identify trends and predict market movements.
Crew: crew
โโโ Task: b8b498ad-76ee-49ec-8a60-705aeafe29b7
Status: Executing Taskโฆ
โโโ Agent: Crew Manager
Status: In Progress
โโโ Thinkingโฆ
Crew: crew
โโโ Task: b8b498ad-76ee-49ec-8a60-705aeafe29b7
Status: Executing Taskโฆ
โโโ Agent: Crew Manager
Status: In Progress
โโโ LLM Failed
โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ LLM Error โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ โ
โ LLM Call Failed โ
โ Error: litellm.BadRequestError: LLM Provider NOT provided. Pass in the LLM provider you are trying to call. You passed model=claude-3-5-sonnet โ
โ Pass model as E.g. For โHuggingfaceโ inference endpoints pass in completion(model='huggingface/starcoder',..)
Learn more: h โ
โ โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
2025-03-19 19:09:56,229 - 16588 - llm.py-llm:751 - ERROR: LiteLLM call failed: litellm.BadRequestError: LLM Provider NOT provided. Pass in the LLM provider you are trying to call. You passed model=claude-3-5-sonnet
Pass model as E.g. For โHuggingfaceโ inference endpoints pass in completion(model='huggingface/starcoder',..)
Learn more:
Error during LLM call: litellm.BadRequestError: LLM Provider NOT provided. Pass in the LLM provider you are trying to call. You passed model=claude-3-5-sonnet
Pass model as E.g. For โHuggingfaceโ inference endpoints pass in completion(model='huggingface/starcoder',..)
Learn more: Providers | liteLLM
An unknown error occurred. Please check the details below.
Error details: litellm.BadRequestError: LLM Provider NOT provided. Pass in the LLM provider you are trying to call. You passed model=claude-3-5-sonnet
Pass model as E.g. For โHuggingfaceโ inference endpoints pass in completion(model='huggingface/starcoder',..)
Learn more:
Crew: crew
โโโ Task: b8b498ad-76ee-49ec-8a60-705aeafe29b7
Assigned to: Crew Manager
Status: Failed
โโโ Agent: Crew Manager
Status: In Progress
โโโ LLM Failed
โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ Task Failure โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ โ
โ Task Failed โ
โ Name: b8b498ad-76ee-49ec-8a60-705aeafe29b7 โ
โ Agent: Crew Manager โ
โ โ
โ โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ Crew Failure โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ โ
โ Crew Execution Failed โ
โ Name: crew โ
โ ID: e03e7942-8e81-497d-9d3c-205c6fc891ac โ
โ โ
โ โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
Traceback (most recent call last):
TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond