Skip to content

Commit

Permalink
Merge pull request #498 from sambanova/crewai-app-demo
Browse files Browse the repository at this point in the history
Feature: Crewai Research Assistant Demo
  • Loading branch information
snova-kwasia authored Jan 8, 2025
2 parents a1677af + d04bad6 commit 468a6ab
Show file tree
Hide file tree
Showing 20 changed files with 6,378 additions and 0 deletions.
4 changes: 4 additions & 0 deletions integrations/crewai/edu_planner_crew_sambanova/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.env
__pycache__/
lib/
output/
82 changes: 82 additions & 0 deletions integrations/crewai/edu_planner_crew_sambanova/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<picture>
<a href="https://sambanova.ai/"\>
<source media="(prefers-color-scheme: dark)" srcset="../images/SambaNova-light-logo-1.png" height="60">
<img alt="SambaNova logo" src="../../../images/SambaNova-dark-logo-1.png" height="60">
</picture>
</a>

# Educational Research Crew

Questions? Just <a href="https://discord.gg/54bNAqRw" target="_blank">message us</a> on Discord <a href="https://discord.gg/54bNAqRw" target="_blank"><img src="https://github.com/sambanova/ai-starter-kit/assets/150964187/aef53b52-1dc0-4cbf-a3be-55048675f583" alt="Discord" width="22"/></a> or <a href="https://github.com/sambanova/ai-starter-kit/issues/new/choose" target="_blank">create an issue</a> in GitHub. We're happy to help live!
Welcome to the Edu-Research Crew project, a powerful collaboration between [crewAI](https://crewai.com) and [SambaNova Systems](https://sambanova.ai). This template demonstrates how to create sophisticated multi-agent AI systems for educational research, powered by SambaNova's state-of-the-art LLMs and crewAI's innovative framework. Our partnership aims to revolutionize educational content creation and research capabilities by combining SambaNova's powerful language models with crewAI's multi-agent orchestration.

## Installation
Ensure you have Python >=3.10 <=3.13 installed on your system. This project uses [UV](https://docs.astral.sh/uv/) for dependency management and package handling, offering a seamless setup and execution experience.


Clone the start kit repo.

```
git clone https://github.com/sambanova/ai-starter-kit.git
```


First, navigate to the *edu-planner-crew-sambanova* folder and pip install uv and crewai:

```bash
cd integrations/crewai/edu_planner_crew_sambanova
```


```bash
pip install uv crewai
```


Next, install the dependencies (this will create a .venv automatically via the crewai command line):
(Optional) Lock the dependencies and install them by using the CLI command:
```bash
crewai install
```

Next, activiate the .venv in the project repo that was created by the previous step, you should see an edu-flow env activated:
```bash
source .venv/bin/activate
```


### API Key Setup
**Before you begin Add your `SAMBANOVA_API_KEY` and `SERPER_API_KEY` into the `.env` file in the main starter kit repo folder**
- You can get your SambaNova API Key [here](https://docs.astral.sh/uv/)
- You can get your Serper API Key [here](https://serper.dev/)

### Customizing
- Modify `src/edu_flow/config/agents.yaml` to define your agents
- Modify `src/edu_flow/config/tasks.yaml` to define your tasks
- Modify `src/edu_flow/crew.py` to add your own logic, tools and specific args
- Modify `src/edu_flow/main.py` to add custom inputs for your agents and tasks

## Running the Project
You can run the project in two ways:
1. Command Line Interface (change config.py to set parameters):
```bash
crewai flow kickoff
```
2. Streamlit Interface (preferred):
```bash
streamlit run src/edu_flow/streamlit_app.py
```
Both methods will initialize the edu-flow Crew, assembling the SambaNova-powered agents and assigning them tasks as defined in your configuration.
This example, unmodified, will create a `report.md` file with the output of educational research in the root folder, leveraging SambaNova's advanced LLMs for comprehensive analysis.

## Understanding Your Crew
The edu-flow Crew combines SambaNova's powerful language models with crewAI's multi-agent framework to create an intelligent system specifically designed for educational research and content creation. Each agent, powered by SambaNova's LLMs, has unique roles, goals, and tools defined in `config/agents.yaml`. These agents collaborate on tasks outlined in `config/tasks.yaml`, working together to achieve complex educational objectives.

## Support
For support, questions, or feedback regarding the Edu-Research Crew:
- Visit the [crewAI documentation](https://docs.crewai.com)
- Check out [SambaNova's AI solutions](https://sambanova.ai)
- Reach out through our [GitHub repository](https://github.com/joaomdmoura/crewai)
- [Join our Discord](https://discord.com/invite/X4JWnZnxPb)
- [Chat with our docs](https://chatg.pt/DWjSBZn)
Experience the future of educational AI with the combined power of crewAI and SambaNova Systems.
202 changes: 202 additions & 0 deletions integrations/crewai/edu_planner_crew_sambanova/crewai_flow.html

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions integrations/crewai/edu_planner_crew_sambanova/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[project]
name = "edu_flow"
version = "0.1.0"
description = "edu-flow using crewAI"
authors = [{ name = "Your Name", email = "you@example.com" }]
requires-python = ">=3.10,<=3.13"
dependencies = [
"crewai[tools]>=0.76.9,<1.0.0",
"langtrace-python-sdk>=3.3.2",
"streamlit>=1.32.0",
]

[project.scripts]
kickoff = "edu_flow.main:kickoff"
plot = "edu_flow.main:plot"
sambanova-builder = "edu_flow.streamlit_app:main"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
crewai==0.76.9
crewai-tools==0.13.4
langchain-community==0.3.5
python-dotenv==1.0.1
streamlit==1.40.2

Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
"""
Configuration module for the educational content generation system.
This module defines all configuration settings, including available models,
provider configurations, and default settings for the content generation system.
It centralizes configuration management for the entire application.
"""

import os
from typing import Any, Dict, List, Optional

# Available SambaNova models configuration
SAMBANOVA_MODELS: List[str] = [
'Meta-Llama-3.1-70B-Instruct',
'Meta-Llama-3.1-8B-Instruct',
'Meta-Llama-3.1-405B-Instruct',
'Meta-Llama-3.2-1B-Instruct',
'Meta-Llama-3.2-3B-Instruct',
'Qwen2.5-Coder-32B-Insruct',
'Qwen2.5-72B-Instruct',
'LLama-3.2-11B-Vision-Instruct',
'LLama-3.2-90B-Vision-Instruct',
]

# Provider-specific model configurations
AVAILABLE_MODELS: Dict[str, List[str]] = {
'sambanova': SAMBANOVA_MODELS,
}

# Detailed provider configurations
PROVIDER_CONFIGS: Dict[str, Dict[str, Any]] = {
'sambanova': {
'model_prefix': 'sambanova/',
'api_key_env': 'SAMBANOVA_API_KEY',
'display_name': 'SambaNova',
'base_url': 'https://api.sambanova.ai/v1',
'models': SAMBANOVA_MODELS,
},
}

# Default configuration settings
DEFAULT_PROVIDER: str = 'sambanova'
DEFAULT_MODEL: str = PROVIDER_CONFIGS[DEFAULT_PROVIDER]['models'][6]

# LLM configuration settings
LLM_CONFIGS: Dict[str, Dict[str, Optional[str]]] = {
provider: {
'model': f"{config['model_prefix']}{config['models'][6]}",
'api_key': os.getenv(config['api_key_env']),
'base_url': config['base_url'],
}
for provider, config in PROVIDER_CONFIGS.items()
}

# Default LLM configuration
LLM_CONFIG: Dict[str, Optional[str]] = LLM_CONFIGS[DEFAULT_PROVIDER]

# Educational flow input variables
EDU_FLOW_INPUT_VARIABLES: Dict[str, str] = {
'audience_level': 'intermediate',
'topic': 'Speculative Decoding',
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
content_writer:
role: >
{topic} Educational Content Writer
goal: >
Create engaging and comprehensive educational content based on the research and content plan provided. The content should be
tailored specifically for a {audience_level} audience while maintaining technical accuracy. Ensure concepts are explained at
an appropriate level of complexity for the target audience.
backstory: >
You're an experienced educational content writer with a talent for breaking down complex topics into digestible content.
You excel at adapting your writing style to match different audience levels, from beginner to advanced. Your writing is known
for being both informative and perfectly calibrated to your readers' knowledge level.
editor:
role: >
{topic} Content Editor for {audience_level} Level Content
goal: >
Review and refine the educational content to ensure it meets quality standards, follows the content plan, and effectively
communicates the intended learning objectives. Verify that the language, examples, and explanations are appropriate for
{audience_level} level learners while maintaining technical accuracy.
backstory: >
You're a meticulous editor with years of experience in educational content across different expertise levels. You have a
sharp eye for detail and excel at ensuring content matches the intended audience level. Your expertise lies in making
sure complex topics are explained appropriately for {audience_level} learners without oversimplifying or overcomplicating.
quality_reviewer:
role: >
{topic} Educational Quality Assurance Specialist
goal: >
Evaluate the final content against educational best practices and ensure it perfectly aligns with {audience_level} level
expectations. Verify that all sections from the content plan are adequately covered, concepts build appropriately on each
other, and the content achieves its learning objectives without overwhelming or underwhelming the target audience.
backstory: >
You're a seasoned educational quality assurance specialist with extensive experience in reviewing technical content for
various skill levels. Your background in both education and technical subjects allows you to effectively assess whether
content meets both pedagogical standards and technical accuracy requirements while remaining accessible to {audience_level}
learners.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
writing_task:
description: >
Create detailed and comprehensive educational content for {topic} based on the provided research, your existing knowledge, and content plan. The content should be
tailored for a {audience_level} audience, explaining concepts thoroughly and at an appropriate level of complexity. Follow
the content plan structure while ensuring the writing is engaging, technically accurate, and in-depth. Thoroughness, completeness, and depth are key.
Section: {section}
expected_output: >
A well-structured and comprehensive section that will be part of a longer form content piece that follows the
content plan and effectively teaches {topic} to {audience_level} level learners. Completeness, thoroughness, and depth are key. Use analogies,
examples, and detailed explanations to help explain the content when appropriate.
Ensure the content is formatted with clear headings and subheadings, and use bullet points where appropriate to enhance readability.
No need to include summaries or conclusions of each section, just the content.
agent: content_writer

editing_task:
description: >
Review and refine the written educational content for {topic}. Ensure it maintains high quality standards, follows the
content plan precisely, and effectively communicates all learning objectives. Pay special attention to language level,
examples, and explanations to verify they are appropriate for {audience_level} learners while preserving technical accuracy.
Thoroughness, completeness, and depth are key.
Section: {section}
expected_output: >
A polished and comprehensive version of the educational content with improved clarity, appropriate complexity level, and enhanced readability
for {audience_level} learners. Ensure the content is formatted with clear headings and subheadings, and use bullet points where appropriate to enhance readability.
We only want the section content back, nothing else. Do not include the feedback.
agent: editor

quality_review_task:
description: >
Perform a comprehensive quality assessment of the final educational content for {topic}. Evaluate against educational best
practices and verify alignment with {audience_level} level expectations. Check that all sections from the content plan are
covered adequately, concepts build logically, and learning objectives are met effectively. Thoroughness, completeness, and depth are key.
Section: {section}
expected_output: >
I want an improved and comprehensive version of the section content that incorporates the feedback. Ensure the content is formatted with clear headings and subheadings, and use bullet points where appropriate to enhance readability.
Include references to the sources used in the summary created in @tasks.yaml. Additionally, ensure that references are included as inline citations or hyperlinks within the content where appropriate. Do not include the feedback itself, just the improved content.
agent: quality_reviewer
Loading

0 comments on commit 468a6ab

Please sign in to comment.