feat: updated teaching agent team code

This commit is contained in:
ShubhamSaboo 2025-01-11 02:00:52 -06:00
parent 4b578dc92c
commit 2905974487
3 changed files with 51 additions and 52 deletions

View file

@ -4,25 +4,25 @@ A Streamlit application that brings together a team of specialized AI teaching a
## 🪄 Meet your AI Teaching Agent Team ## 🪄 Meet your AI Teaching Agent Team
#### 🧠 KnowledgeBuilder Agent #### 🧠 Professor Agent
- Creates fundamental knowledge base in Google Docs - Creates fundamental knowledge base in Google Docs
- Organizes content with proper headings and sections - Organizes content with proper headings and sections
- Includes detailed explanations and examples - Includes detailed explanations and examples
- Output: Comprehensive knowledge base document with table of contents - Output: Comprehensive knowledge base document with table of contents
#### 🗺️ RoadmapArchitect Agent #### 🗺️ Academic Advisor Agent
- Designs learning path in a structured Google Doc - Designs learning path in a structured Google Doc
- Creates progressive milestone markers - Creates progressive milestone markers
- Includes time estimates and prerequisites - Includes time estimates and prerequisites
- Output: Visual roadmap document with clear progression paths - Output: Visual roadmap document with clear progression paths
#### 📚 ResourceCurator Agent #### 📚 Research Librarian Agent
- Compiles resources in an organized Google Doc - Compiles resources in an organized Google Doc
- Includes links to academic papers and tutorials - Includes links to academic papers and tutorials
- Adds descriptions and difficulty levels - Adds descriptions and difficulty levels
- Output: Categorized resource list with quality ratings - Output: Categorized resource list with quality ratings
#### ✍️ PracticeDesigner Agent #### ✍️ Teaching Assistant Agent
- Develops exercises in an interactive Google Doc - Develops exercises in an interactive Google Doc
- Creates structured practice sections - Creates structured practice sections
- Includes solution guides - Includes solution guides

View file

@ -43,9 +43,9 @@ except Exception as e:
st.error(f"Error initializing ComposioToolSet: {e}") st.error(f"Error initializing ComposioToolSet: {e}")
st.stop() st.stop()
# Create the KnowledgeBuilder agent # Create the Professor agent
knowledge_agent = Agent( professor = Agent(
name="KnowledgeBuilder", name="Professor",
role="Research and Knowledge Specialist", role="Research and Knowledge Specialist",
model=OpenAIChat(id="gpt-4o", api_key=st.session_state['openai_api_key']), model=OpenAIChat(id="gpt-4o", api_key=st.session_state['openai_api_key']),
tools=[google_docs_tool], tools=[google_docs_tool],
@ -59,9 +59,9 @@ knowledge_agent = Agent(
markdown=True, markdown=True,
) )
# Create the RoadmapArchitect agent # Create the Academic Advisor agent
roadmap_agent = Agent( advisor = Agent(
name="RoadmapArchitect", name="Academic Advisor",
role="Learning Path Designer", role="Learning Path Designer",
model=OpenAIChat(id="gpt-4o", api_key=st.session_state['openai_api_key']), model=OpenAIChat(id="gpt-4o", api_key=st.session_state['openai_api_key']),
tools=[google_docs_tool], tools=[google_docs_tool],
@ -71,15 +71,14 @@ roadmap_agent = Agent(
"Include estimated time commitments for each section.", "Include estimated time commitments for each section.",
"Present the roadmap in a clear, structured format. DONT FORGET TO CREATE THE GOOGLE DOCUMENT.", "Present the roadmap in a clear, structured format. DONT FORGET TO CREATE THE GOOGLE DOCUMENT.",
"Open a new Google Doc and write down the response of the agent neatly with great formatting and structure in it. **Include the Google Doc link in your response.**", "Open a new Google Doc and write down the response of the agent neatly with great formatting and structure in it. **Include the Google Doc link in your response.**",
], ],
show_tool_calls=True, show_tool_calls=True,
markdown=True markdown=True
) )
# Create the ResourceCurator agent # Create the Research Librarian agent
resource_agent = Agent( librarian = Agent(
name="ResourceCurator", name="Research Librarian",
role="Learning Resource Specialist", role="Learning Resource Specialist",
model=OpenAIChat(id="gpt-4o", api_key=st.session_state['openai_api_key']), model=OpenAIChat(id="gpt-4o", api_key=st.session_state['openai_api_key']),
tools=[google_docs_tool, ArxivToolkit(), DuckDuckGo(fixed_max_results=10)], tools=[google_docs_tool, ArxivToolkit(), DuckDuckGo(fixed_max_results=10)],
@ -95,9 +94,9 @@ resource_agent = Agent(
markdown=True, markdown=True,
) )
# Create the PracticeDesigner agent # Create the Teaching Assistant agent
practice_agent = Agent( assistant = Agent(
name="PracticeDesigner", name="Teaching Assistant",
role="Exercise Creator", role="Exercise Creator",
model=OpenAIChat(id="gpt-4o", api_key=st.session_state['openai_api_key']), model=OpenAIChat(id="gpt-4o", api_key=st.session_state['openai_api_key']),
tools=[google_docs_tool, DuckDuckGo(fixed_max_results=10)], tools=[google_docs_tool, DuckDuckGo(fixed_max_results=10)],
@ -106,7 +105,7 @@ practice_agent = Agent(
"Use the DuckDuckGo search tool to find example problems and real-world applications.", "Use the DuckDuckGo search tool to find example problems and real-world applications.",
"Include progressive exercises, quizzes, hands-on projects, and real-world application scenarios.", "Include progressive exercises, quizzes, hands-on projects, and real-world application scenarios.",
"Ensure the materials align with the roadmap progression.", "Ensure the materials align with the roadmap progression.",
"Provide detailed solutions and explanations for all practice materials.DONT FORGET TO CREATE THE GOOGLE DOCUMENT.", "Provide detailed solutions and explanations for all practice materials. DONT FORGET TO CREATE THE GOOGLE DOCUMENT.",
"Open a new Google Doc and write down the response of the agent neatly with great formatting and structure in it. **Include the Google Doc link in your response.**", "Open a new Google Doc and write down the response of the agent neatly with great formatting and structure in it. **Include the Google Doc link in your response.**",
], ],
show_tool_calls=True, show_tool_calls=True,
@ -130,78 +129,78 @@ if st.button("Start"):
else: else:
# Display loading animations while generating responses # Display loading animations while generating responses
with st.spinner("Generating Knowledge Base..."): with st.spinner("Generating Knowledge Base..."):
knowledge_response: RunResponse = knowledge_agent.run( professor_response: RunResponse = professor.run(
f"the topic is: {st.session_state['topic']},Don't forget to add the Google Doc link in your response.", f"the topic is: {st.session_state['topic']},Don't forget to add the Google Doc link in your response.",
stream=False stream=False
) )
with st.spinner("Generating Learning Roadmap..."): with st.spinner("Generating Learning Roadmap..."):
roadmap_response: RunResponse = roadmap_agent.run( advisor_response: RunResponse = advisor.run(
f"the topic is: {st.session_state['topic']},Don't forget to add the Google Doc link in your response.", f"the topic is: {st.session_state['topic']},Don't forget to add the Google Doc link in your response.",
stream=False stream=False
) )
with st.spinner("Curating Learning Resources..."): with st.spinner("Curating Learning Resources..."):
resource_response: RunResponse = resource_agent.run( librarian_response: RunResponse = librarian.run(
f"the topic is: {st.session_state['topic']},Don't forget to add the Google Doc link in your response.", f"the topic is: {st.session_state['topic']},Don't forget to add the Google Doc link in your response.",
stream=False stream=False
) )
with st.spinner("Creating Practice Materials..."): with st.spinner("Creating Practice Materials..."):
practice_response: RunResponse = practice_agent.run( assistant_response: RunResponse = assistant.run(
f"the topic is: {st.session_state['topic']},Don't forget to add the Google Doc link in your response.", f"the topic is: {st.session_state['topic']},Don't forget to add the Google Doc link in your response.",
stream=False stream=False
) )
# Extract Google Doc links from the responses # Extract Google Doc links from the responses
def extract_google_doc_link(response_content): def extract_google_doc_link(response_content):
# Assuming the Google Doc link is embedded in the response content
# You may need to adjust this logic based on the actual response format
if "https://docs.google.com" in response_content: if "https://docs.google.com" in response_content:
return response_content.split("https://docs.google.com")[1].split()[0] return response_content.split("https://docs.google.com")[1].split()[0]
return None return None
knowledge_doc_link = extract_google_doc_link(knowledge_response.content) professor_doc_link = extract_google_doc_link(professor_response.content)
roadmap_doc_link = extract_google_doc_link(roadmap_response.content) advisor_doc_link = extract_google_doc_link(advisor_response.content)
resource_doc_link = extract_google_doc_link(resource_response.content) librarian_doc_link = extract_google_doc_link(librarian_response.content)
practice_doc_link = extract_google_doc_link(practice_response.content) assistant_doc_link = extract_google_doc_link(assistant_response.content)
# Display Google Doc links at the top of the Streamlit UI # Display Google Doc links at the top of the Streamlit UI
st.markdown("### Google Doc Links:") st.markdown("### Google Doc Links:")
if knowledge_doc_link: if professor_doc_link:
st.markdown(f"- **KnowledgeBuilder Document:** [View Document](https://docs.google.com{knowledge_doc_link})") st.markdown(f"- **Professor's Document:** [View Document](https://docs.google.com{professor_doc_link})")
if roadmap_doc_link: if advisor_doc_link:
st.markdown(f"- **RoadmapArchitect Document:** [View Document](https://docs.google.com{roadmap_doc_link})") st.markdown(f"- **Academic Advisor's Document:** [View Document](https://docs.google.com{advisor_doc_link})")
if resource_doc_link: if librarian_doc_link:
st.markdown(f"- **ResourceCurator Document:** [View Document](https://docs.google.com{resource_doc_link})") st.markdown(f"- **Research Librarian's Document:** [View Document](https://docs.google.com{librarian_doc_link})")
if practice_doc_link: if assistant_doc_link:
st.markdown(f"- **PracticeDesigner Document:** [View Document](https://docs.google.com{practice_doc_link})") st.markdown(f"- **Teaching Assistant's Document:** [View Document](https://docs.google.com{assistant_doc_link})")
# Display responses in the Streamlit UI using pprint_run_response # Display responses in the Streamlit UI using pprint_run_response
st.markdown("### KnowledgeBuilder Response:") st.markdown("### Professor's Response:")
st.markdown(knowledge_response.content) st.markdown(professor_response.content)
pprint_run_response(knowledge_response, markdown=True) pprint_run_response(professor_response, markdown=True)
st.divider() st.divider()
st.markdown("### RoadmapArchitect Response:")
st.markdown(roadmap_response.content) st.markdown("### Academic Advisor's Response:")
pprint_run_response(roadmap_response, markdown=True) st.markdown(advisor_response.content)
pprint_run_response(advisor_response, markdown=True)
st.divider() st.divider()
st.markdown("### ResourceCurator Response:") st.markdown("### Research Librarian's Response:")
st.markdown(resource_response.content) st.markdown(librarian_response.content)
pprint_run_response(resource_response, markdown=True) pprint_run_response(librarian_response, markdown=True)
st.divider() st.divider()
st.markdown("### PracticeDesigner Response:") st.markdown("### Teaching Assistant's Response:")
st.markdown(practice_response.content) st.markdown(assistant_response.content)
pprint_run_response(practice_response, markdown=True) pprint_run_response(assistant_response, markdown=True)
st.divider() st.divider()
# Information about the agents # Information about the agents
st.markdown("---") st.markdown("---")
st.markdown("### About the Agents:") st.markdown("### About the Agents:")
st.markdown(""" st.markdown("""
- **KnowledgeBuilder**: Researches the topic and creates a detailed knowledge base. - **Professor**: Researches the topic and creates a detailed knowledge base.
- **RoadmapArchitect**: Designs a structured learning roadmap for the topic. - **Academic Advisor**: Designs a structured learning roadmap for the topic.
- **ResourceCurator**: Curates high-quality learning resources. - **Research Librarian**: Curates high-quality learning resources.
- **PracticeDesigner**: Creates practice materials, exercises, and projects. - **Teaching Assistant**: Creates practice materials, exercises, and projects.
""") """)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 MiB