mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-10 16:48:30 +00:00
fixed issue for smaller models due to instructions prompt
This commit is contained in:
@@ -23,7 +23,7 @@ class Converter(OutputConverter):
|
|||||||
if self.is_gpt:
|
if self.is_gpt:
|
||||||
return self._create_instructor().to_pydantic()
|
return self._create_instructor().to_pydantic()
|
||||||
else:
|
else:
|
||||||
return self._create_chain().invoke({"query": self.text})
|
return self._create_chain().invoke({})
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if current_attempt < self.max_attempts:
|
if current_attempt < self.max_attempts:
|
||||||
return self.to_pydantic(current_attempt + 1)
|
return self.to_pydantic(current_attempt + 1)
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ class CrewPydanticOutputParser(PydanticOutputParser):
|
|||||||
|
|
||||||
# Treating edge case of function calling llm returning the name instead of tool_name
|
# Treating edge case of function calling llm returning the name instead of tool_name
|
||||||
json_object = json.loads(result[0].text)
|
json_object = json.loads(result[0].text)
|
||||||
|
if "tool_name" not in json_object:
|
||||||
|
json_object["tool_name"] = json_object.get("name", "")
|
||||||
result[0].text = json.dumps(json_object)
|
result[0].text = json.dumps(json_object)
|
||||||
|
|
||||||
json_object = super().parse_result(result)
|
json_object = super().parse_result(result)
|
||||||
|
|||||||
@@ -66,11 +66,11 @@ class TaskEvaluator:
|
|||||||
"- Entities extracted from the task output, if any, their type, description, and relationships"
|
"- Entities extracted from the task output, if any, their type, description, and relationships"
|
||||||
)
|
)
|
||||||
|
|
||||||
instructions = "I'm gonna convert this raw text into valid JSON."
|
instructions = "Convert this raw text into valid JSON."
|
||||||
|
|
||||||
if not self._is_gpt(self.llm):
|
if not self._is_gpt(self.llm):
|
||||||
model_schema = PydanticSchemaParser(model=TaskEvaluation).get_schema()
|
model_schema = PydanticSchemaParser(model=TaskEvaluation).get_schema()
|
||||||
instructions = f"{instructions}\n\nThe json should have the following structure, with the following keys:\n{model_schema}"
|
instructions = f"{instructions}\n\nYou must return json with the following schema:\n{model_schema}"
|
||||||
|
|
||||||
converter = Converter(
|
converter = Converter(
|
||||||
llm=self.llm,
|
llm=self.llm,
|
||||||
|
|||||||
Reference in New Issue
Block a user