Hi,
I’m using Azure OpenAI and Azure text-embedding-ada-2 models.
Below is the code
import os;
from crewai import Agent, Task, Crew, Process, LLM
from crewai.knowledge.source.string_knowledge_source import StringKnowledgeSource
Create a knowledge source
string_source = StringKnowledgeSource(
content=“Users name is John. He is 30 years old and lives in San Francisco.”
)
os.environ[‘AZURE_OPENAI_API_KEY’] =“azure_open_ai_key”
os.environ[‘AZURE_OPENAI_ENDPOINT’] =“azure open ai endpoint”
os.environ[‘AZURE_API_VERSION’] = “2024-08-01-preview”
Create an LLM with a temperature of 0 to ensure deterministic outputs
llm = LLM(
model=“azure/gpt-4o-mini”,
api_key=‘azure_open_ai_key’,
base_url=‘aisprdoai.openai.azure.com/’,
api_version=‘2024-08-01-preview’
)
embedder={
“provider”: “azure”,
“config”: {
“api_key”: “azure_open_ai_key”,
“api_base”: “aisprdoai.openai.azure.com”,
“api_version”: “2023-05-15”,
“model_name”: “aisprdoai-embedding-ada-2”
}
}
Create an agent with the knowledge store
agent = Agent(
role=“About User”,
goal=“You know everything about the user and provide the information from source only.”,
backstory=“”“You are a master at understanding people and their preferences.”“”,
verbose=True,
allow_delegation=False,
llm=llm,
knowledge_sources=[string_source],
embedder=embedder
)
task = Task(
description=“Answer the following questions about the user: {question}”,
expected_output=“An answer to the question.”,
agent=agent,
verbose=True
)
crew = Crew(
agents=[agent],
tasks=[task],
verbose=True,
process=Process.sequential,
)
result = crew.kickoff(inputs={“question”: “Who is john and how old is he?”})
when i run this getting below error.
File “C:\Users\xxxxx\latest_ai_development\src\latest_ai_development\knowledge1base.py”, line 54, in
agent = Agent(
File “C:\Users\xxxx\anaconda3\envs\crewai-env\lib\site-packages\pydantic\main.py”, line 214, in init
validated_self = self.pydantic_validator.validate_python(data, self_instance=self)
pydantic_core._pydantic_core.ValidationError: 1 validation error for Agent
Value error, Invalid Knowledge Configuration: APIStatusError.init() missing 2 required keyword-only arguments: ‘response’ and ‘body’ [type=value_error, input_value={‘role’: ‘About User’, ‘g…evai-embedding-ada-2’}}}, input_type=dict]
For further information visit errors.pydantic.dev/2.10/v/value_error