mira
09/29/2024, 11:06 AM@cf.tool
def get_lesson(topic: str) -> Lesson:
"""create a lesson about `topic`"""
pass
I also tried a slightly different example, which I didn't get to run at all.
Example:
import controlflow as cf
from pydantic import BaseModel
class Course(BaseModel):
subject: str
syllabus: str
content_table: list[str]
exercises: list[str]
tutor = cf.Agent(
name="Marvin",
model="groq/mixtral-8x7b-32768",
instructions="You are a diligent and conscientious tutor."
)
subject = "SQL"
level = "intermediate"
#@cf.tool
#def get_course(topic: str, syllabus: str, content_table: list[str], exercises: list[str])-> Course:
# """create a course with the given `topic`, `syllabus`, `content_table` and `exercises`."""
with cf.Flow(default_agent=tutor):
syllabus = cf.Task(
f"Create a detailed syllabus for an interesting {level} course on {subject}.",
result_type=str,
)
content_table = cf.Task(
"Create a table of contents for the course based on the syllabus.",
result_type=list[str],
depends_on=[syllabus]
)
exercises = cf.Task(
"Create a list of interesting exercises based on the course content table and the course level.",
instructions="""
- Create one exercise per topic of the content table
- An exercise should be either a detailed exercise the user can solve with the given information
or an interesting question in the field of the specific topic
""",
depends_on=[content_table],
result_type=list[str]
)
course = cf.Task(
"Put the previously created parts of the course into a course object",
instructions="Use the previously created syllabus, content table and exercises for the course.",
depends_on=[exercises],
#tools=[get_course],
result_type=Course,
).run()
One example for the failing tool use:
│
│ I apologize for the confusion. Here is the tool call for marking task 3bf3e5d3 as successful: │
│ │
│ Tool use failed: │
│ │
╰──────────────────────────────────────────────────────────────────────── 114905 AM ─╯
╭─ Agent: Marvin ────────────────────────────────────────────────────────────────────╮
│ │
│ │
│ Please let me know if you have any further questions or concerns.Jeremiah
groq/mixtral-8x7b-32768
on the language tutor exampleJeremiah
groq/llama3-70b-8192
, so I think this is an issue with the model rather than groq as a providerJeremiah
mira
10/01/2024, 7:15 AM# model = "mixtral-8x7b-32768",
# model = "llama-3.1-70b-versatile",
# model = "llama3-8b-8192"
model = "llama3-70b-8192",
and each of them indeed behaves different. But unfortunately none of them was able to produce more than one exercise with the learning tutor (if any at all). This is the error message of my last attempt with llama3-70b-8192 after the agent tried to mark the first exercise as successful:
╭─ Agent: Tutor ───────────────────────────────────────────────────────────────────────────────────╮
│ │
│ Tool use failed: parameters for tool call 'mark_task_fa429c74_successful' do not match the │
│ expected schema, errors: result.content: Invalid type. Expected: string, given: object; │
╭─ Agent: Tutor ───────────────────────────────────────────────────────────────────────────────────╮
│ │
│ Tool use failed: parameters for tool call 'mark_task_fa429c74_successful' do not match the │
│ expected schema, errors: result.content: Invalid type. Expected: string, given: object; │
│ result.exercises: Invalid type. Expected: array, given: object; result.topic: Invalid type. │
│ Expected: string, given: object │
│ │
╰──────────────────────────────────────────────────────────────────────────────────── 7:59:00 AM ─╯
I also tried some different, easier examples (but with structured output and more than 2 tasks), it did unfortunately not work with any groq model, they always (!) freeze because of any tool failure (always different failures).
Hopefully you can get them under control ;).Jeremiah