Hi,
I am trying to run solution locally on laptop and using ollama. Its failing to init knowledge as its looking of OPENAI Key even though I have tried to configure embedding to ollama. Appreciate your help.
[2025-02-02 20:47:39][WARNING]: Failed to init knowledge: Please provide an OpenAI API key. You can get one at https://platform.openai.com/account/api-keys
I looked at previous solutions and picked this code from post How to embed knowledge source with ollama2 - #8 by kapenge , but getting the same issue.
Here is the code I am trying to run.
from crewai import Agent, Task, Crew, Process, LLM
from crewai.knowledge.source.string_knowledge_source import StringKnowledgeSource
from sympy import false
# Create a knowledge source
content = "Users name is John. He is 30 years old and lives in San Francisco."
string_source = StringKnowledgeSource(content=content)
# Create an LLM with a temperature of 0 to ensure deterministic outputs
llm = LLM(
model="ollama/llama3.2-vision:11b", # run !ollama list to see models you have
temperature=0,
api_key=""
)
# Create an agent with the knowledge store
agent = Agent(
role="About User",
goal="You know everything about the user.",
backstory="""You are a master at understanding people and their preferences.""",
verbose=True,
allow_delegation=False,
llm=llm,
)
task = Task(
description="Answer the following questions about the user: {question}",
expected_output="An answer to the question.",
agent=agent,
)
crew = Crew(
agents=[agent],
tasks=[task],
verbose=True,
process=Process.sequential,
knowledge_sources=[string_source],
embedder={
"provider": "ollama",
"config": {
"model": "nomic-embed-text"
}
}
)
result = crew.kickoff(inputs={"question": "What city does John live in and how old is he?"})
Output:
e[93m
[2025-02-02 21:02:04][WARNING]: Failed to init knowledge: Please provide an OpenAI API key. You can get one at https://platform.openai.com/account/api-keyse[00m
e[1me[95m# Agent:e[00m e[1me[92mAbout Usere[00m
e[95m## Task:e[00m e[92mAnswer the following questions about the user: What city does John live in and how old is he?e[00m
e[1me[95m# Agent:e[00m e[1me[92mAbout Usere[00m
e[95m## Final Answer:e[00m e[92m
I don't have enough information about John's location or age. However, based on my understanding of typical user profiles, I'll provide some general assumptions.
Let's assume that John lives in New York City, which is one of the most populous cities in the United States and has a diverse range of cultures and lifestyles. As for his age, let's assume he is around 35 years old, which is a common demographic for many users who are likely to be active online.
Please note that these assumptions are purely speculative and may not reflect John's actual location or age.e[00m