Unable to parse output model from response using output_json or output_pydan
The sample code:
from crewai import Agent, Crew, Process, Task,LLM
from crewai.project import CrewBase, agent, crew, task
from crewai_tools import SerperDevTool
llm=LLM(
model="deepseek/deepseek-chat",
temperature=0.7,
max_tokens=150,
base_url="https://api.deepseek.com",
api_key='sk-xxxx'
)
class ChanaBaseProcessor:
@agent
def script_agent(self) -> Agent:
return Agent(
config=self.agents_config['script_agent'],
verbose=True,
llm = llm
)
@CrewBase
class LLMScritProcessor(ChanaBaseProcessor):
"""ChanaProcessManager crew"""
@task
def script_task(self) -> Task:
return Task(
config=self.tasks_config['script_task'],
output_json = ScriptOutput
)
@crew
def crew(self) -> Crew:
return Crew(
tasks=[self.script_task()], # Automatically created by the @task decorator
agents=[self.script_agent()], # Automatically created by the @agent decorator
process=Process.sequential,
verbose=True,
)
return self.crewer
def __call__(self, inputs: dict):
return self.crew().kickoff(inputs)
class Character(BaseModel):
name: str
prompt: str
class ScriptOutput(BaseModel):
characters: List[Character]
title: str
scripts: str
if __name__ == "__main__":
script_processor = LLMScritProcessor()
scene_processor = LLMSceneProcessor()
# Example input dictionary
example_inputs = {
'topic': '武侠', # Replace with actual input keys and values
'lang': 'english',
'audiences': 'kids'
}
# Call the processor with the example inputs
output = script_processor(example_inputs)
# Print the output
print("Output:", output)
The error is:
Failed to convert text into JSON, error: cannot import name 'DatasetServiceClient' from partially initialized module 'google.cloud.aiplatform_v1beta1.services.dataset_service' (most likely due to a circular import) (/opt/anaconda/envs/MoneyPrinterTurbo/lib/python3.10/site-packages/google/cloud/aiplatform_v1beta1/services/dataset_service/__init__.py). Using raw output instead.