我遇到一个持续存在的问题,即模型(在 Groq 上运行的 Llama 3 8B)无法处理作为参数传递的 JSON 字符串。此外,在更广泛的范围内,CrewAI 系统似乎无法将多个参数传递给函数。
在过去的 10 天里,我尝试了多种方法,包括将输入解析为字典、JSON 字符串,甚至使用 Pydantic 模型。尽管我付出了努力,问题仍然存在,让我感到沮丧并且不确定如何继续。
# Agent: Academic Research Explorer
## Thought: Let's do it correctly. I'll perform the action and then give the final answer.
Thought: I need to formulate a search strategy to gather relevant papers on the mathematical foundations of AGI and its implications on the P vs NP problem.
## Using tool: arxiv_research_tool
## Tool Input:
"{\"author\": \"\", \"title\": \"\", \"category\": \"cs.AI\", \"keywords\": [\"Artificial General Intelligence\", \"P vs NP\", \"mathematical foundations\"], \"max_results\": 10, \"sort_by\": \"lastUpdatedDate\", \"sort_order\": \"descending\", \"extract_text\": true}"
## Tool Output:
Error: the Action Input is not a valid key, value dictionary.
Error parsing LLM output, agent will retry: I did it wrong. Invalid Format: I missed the 'Action:' after 'Thought:'. I will do right next, and don't use a tool I have already used.
If you don't need to use any more tools, you must give your best complete final answer, make sure it satisfy the expect criteria, use the EXACT format below:
Thought: I now can give a great answer
Final Answer: my best complete final answer to the task.
Error parsing LLM output, agent will retry: I did it wrong. Tried to both perform Action and give a Final Answer at the same time, I must do one or the other
Error parsing LLM output, agent will retry: I did it wrong. Tried to both perform Action and give a Final Answer at the same time, I must do one or the other
# Agent: Academic Research Explorer
## Final Answer:
下面是我尝试实现的任务的示例。
def task_research(self, agent, conversation: Dict[str, str], research_papers: Dict[str, Any]) -> Task:
research_template = """
RESEARCH PROTOCOL:
CONTEXT:
{conversation_text}
{research_papers}
REQUIRED STEPS:
1. Research Analysis:
- Extract key findings
- Document methodology
- Record empirical results
- Note implementation details
2. Content Organization:
- Background/Current State
- Methodology Analysis
- Empirical Evidence
3. Content Extraction:
- Use load_document for PDFs
4. Final Synthesis:
- Abstract
- Literature Review
- Methodology Comparison
- Results Analysis
- Conclusions
- References
"""
unrolled_research_papers = self.unroll_results(research_papers)
conversation_text = self.format_input_dict(conversation)
return Task(
description=research_template.format(
conversation_text=conversation_text,
research_papers=unrolled_research_papers
),
expected_output="A structured dictionary with keys: 'abstract', 'literature_review', 'analysis', 'conclusion', 'references'",
agent=agent,
async_execution=True,
output_json=ResearchOutComeModel
)
def research_paper_agent(self):
return Agent(
llm=self.llm,
role="Academic Research Explorer",
goal="""Identify and analyze relevant research papers ...""",
backstory="""You are an expert Academic Research Explorer specialized in discovering relevant scholarly work ...""",
allow_delegation=False,
tools=[ArxivResearchTool()],
verbose=True,
max_iter=3,
)
class ArxivResearchInput(BaseModel):
argument: str = Field(
description='JSON string containing search parameters',
example='{"author": "Alan Turing", "title": "Computing Machinery", "category": "cs.AI", "max_results": 4, "sort_by": "relevance", "sort_order": "descending", "extract_text": true}'
)
class ArxivResearchTool(BaseTool):
name: str = 'arxiv_research_tool'
description: str = """Useful to search the arXiv academic database ..."""
args_schema: Type[BaseModel] = ArxivResearchInput
def _run(self, argument: str) -> Dict:
try:
params = json.loads(argument)
return ResearchTool.arxiv_research_tool(argument)
except Exception as e:
return {"error": str(e)}
系统应该:
如何解决这个问题?
预期的行为是代理能够正确地将 JSON 字符串作为参数传递给工具并取回研究论文
Windows 11
Python 3.10
crewAI 0.80.0
crewAI Tools 0.14.0
Venv
由于您使用的法学硕士,可能会发生此类错误。不幸的是,规模较小的法学硕士有时很难与 CrewAI 合作。 尝试将LLM转为更有能力的LLM。
正如 CrewAI 首席执行官在 GitHub 上所说:
嘿伙计们,终于赶上了!
确实,较小的模型确实难以使用某些工具,特别是更多 复杂的,我觉得我们还有优化人员的空间 也许会提示一点,我会调查一下,但最终 较小的模型确实在认知方面存在困难。
我正在收集数据以将这些模型微调为代理模型 将被训练得更像特工,这应该提供方法 即使是小型型号也具有更高的可靠性。
我认为下一步最好的行动可能是提到最好的模型 我们的新文档,并做了一些稍微改变提示的测试 较小的模型,我会看一下,同时我正在关闭它 一个,但如果有请求,可以重新打开:)