Spaces:
Runtime error
Runtime error
vivekprojects-GIT commited on
Commit ·
03971e4
1
Parent(s): b7650c3
Added CrewAI, Gradio MCP server, and Modal integration
Browse files- __pycache__/modal_app.cpython-313.pyc +0 -0
- agents.yaml +24 -0
- app.py +16 -0
- crew.py +12 -0
- modal_agents.py +19 -0
- modal_app.py +44 -0
- requirements.txt +4 -0
- tasks.yaml +19 -0
__pycache__/modal_app.cpython-313.pyc
ADDED
|
Binary file (3.35 kB). View file
|
|
|
agents.yaml
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
- role: Repository Cloner Agent
|
| 2 |
+
goal: Clone the GitHub repository.
|
| 3 |
+
backstory: The fastest fetcher of code.
|
| 4 |
+
tools: [repository_cloner_agent]
|
| 5 |
+
|
| 6 |
+
- role: Code Analysis Agent
|
| 7 |
+
goal: Analyze code for issues and improvements.
|
| 8 |
+
backstory: A bug hunter with sharp eyes.
|
| 9 |
+
tools: [code_analysis_agent]
|
| 10 |
+
|
| 11 |
+
- role: Metadata Agent
|
| 12 |
+
goal: Extract lines of code, languages, stars.
|
| 13 |
+
backstory: A stats wizard.
|
| 14 |
+
tools: [metadata_agent]
|
| 15 |
+
|
| 16 |
+
- role: Documentation Agent
|
| 17 |
+
goal: Review README and docstrings.
|
| 18 |
+
backstory: A language wizard.
|
| 19 |
+
tools: [documentation_agent]
|
| 20 |
+
|
| 21 |
+
- role: Orchestrator Agent
|
| 22 |
+
goal: Combine all findings into a final report.
|
| 23 |
+
backstory: The conductor of the orchestra.
|
| 24 |
+
tools: [orchestrator_agent]
|
app.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from crew import run_crew
|
| 3 |
+
|
| 4 |
+
def process_query(user_input):
|
| 5 |
+
return run_crew(user_input)
|
| 6 |
+
|
| 7 |
+
iface = gr.Interface(
|
| 8 |
+
fn=process_query,
|
| 9 |
+
inputs=gr.Textbox(label="Enter GitHub repo URL for analysis"),
|
| 10 |
+
outputs=gr.Textbox(label="Analysis report"),
|
| 11 |
+
title="🎶 Distributed Mistral Orchestra",
|
| 12 |
+
description="Analyze a GitHub repo using a multi-agent AI team powered by Mistral models on Modal."
|
| 13 |
+
)
|
| 14 |
+
|
| 15 |
+
if __name__ == "__main__":
|
| 16 |
+
iface.launch(mcp_server=True)
|
crew.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from crewai import Crew
|
| 2 |
+
|
| 3 |
+
crew = Crew.from_yaml(
|
| 4 |
+
agents_file='agents.yaml',
|
| 5 |
+
tasks_file='tasks.yaml',
|
| 6 |
+
process='sequential'
|
| 7 |
+
)
|
| 8 |
+
|
| 9 |
+
def run_crew(github_url):
|
| 10 |
+
for task in crew.tasks:
|
| 11 |
+
task.description += f"\nUser GitHub URL: {github_url}"
|
| 12 |
+
return crew.kickoff()
|
modal_agents.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import modal
|
| 2 |
+
|
| 3 |
+
client = modal.Client()
|
| 4 |
+
app = client.get("distributed-mistral-orchestra")
|
| 5 |
+
|
| 6 |
+
def repository_cloner_agent(github_url):
|
| 7 |
+
return app.repository_cloner_agent.call(github_url)
|
| 8 |
+
|
| 9 |
+
def code_analysis_agent(prompt):
|
| 10 |
+
return app.code_analysis_agent.call(prompt)
|
| 11 |
+
|
| 12 |
+
def metadata_agent(prompt):
|
| 13 |
+
return app.metadata_agent.call(prompt)
|
| 14 |
+
|
| 15 |
+
def documentation_agent(prompt):
|
| 16 |
+
return app.documentation_agent.call(prompt)
|
| 17 |
+
|
| 18 |
+
def orchestrator_agent(summary):
|
| 19 |
+
return app.orchestrator_agent.call(summary)
|
modal_app.py
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import modal
|
| 2 |
+
|
| 3 |
+
app = modal.App("distributed-mistral-orchestra") # <--- app, not stub
|
| 4 |
+
@app.function(gpu="A100")
|
| 5 |
+
def repository_cloner_agent(github_url):
|
| 6 |
+
import subprocess
|
| 7 |
+
subprocess.run(["git", "clone", github_url, "/root/repo"], check=True)
|
| 8 |
+
return f"Cloned repository: {github_url}"
|
| 9 |
+
|
| 10 |
+
@app.function(gpu="A100")
|
| 11 |
+
def code_analysis_agent(prompt):
|
| 12 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 13 |
+
tokenizer = AutoTokenizer.from_pretrained("mistralai/Mistral-Large")
|
| 14 |
+
model = AutoModelForCausalLM.from_pretrained("mistralai/Mistral-Large").to("cuda")
|
| 15 |
+
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
|
| 16 |
+
outputs = model.generate(**inputs, max_new_tokens=300)
|
| 17 |
+
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 18 |
+
|
| 19 |
+
@app.function(gpu="H100")
|
| 20 |
+
def metadata_agent(prompt):
|
| 21 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 22 |
+
tokenizer = AutoTokenizer.from_pretrained("mistralai/Mixtral-8x7B-Instruct-v0.1")
|
| 23 |
+
model = AutoModelForCausalLM.from_pretrained("mistralai/Mixtral-8x7B-Instruct-v0.1").to("cuda")
|
| 24 |
+
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
|
| 25 |
+
outputs = model.generate(**inputs, max_new_tokens=250)
|
| 26 |
+
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 27 |
+
|
| 28 |
+
@app.function(gpu="T4")
|
| 29 |
+
def documentation_agent(prompt):
|
| 30 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 31 |
+
tokenizer = AutoTokenizer.from_pretrained("mistralai/Mistral-7B-Instruct-v0.2")
|
| 32 |
+
model = AutoModelForCausalLM.from_pretrained("mistralai/Mistral-7B-Instruct-v0.2").to("cuda")
|
| 33 |
+
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
|
| 34 |
+
outputs = model.generate(**inputs, max_new_tokens=200)
|
| 35 |
+
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 36 |
+
|
| 37 |
+
@app.function(gpu="A100")
|
| 38 |
+
def orchestrator_agent(summary):
|
| 39 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 40 |
+
tokenizer = AutoTokenizer.from_pretrained("mistralai/Mistral-Large")
|
| 41 |
+
model = AutoModelForCausalLM.from_pretrained("mistralai/Mistral-Large").to("cuda")
|
| 42 |
+
inputs = tokenizer(summary, return_tensors="pt").to("cuda")
|
| 43 |
+
outputs = model.generate(**inputs, max_new_tokens=400)
|
| 44 |
+
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio[mcp]
|
| 2 |
+
crewai
|
| 3 |
+
requests
|
| 4 |
+
modal
|
tasks.yaml
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
- description: Clone the user's GitHub repo.
|
| 2 |
+
expected_output: Repo cloned for analysis.
|
| 3 |
+
agent: Repository Cloner Agent
|
| 4 |
+
|
| 5 |
+
- description: Analyze the codebase for bugs and improvements.
|
| 6 |
+
expected_output: Code analysis report.
|
| 7 |
+
agent: Code Analysis Agent
|
| 8 |
+
|
| 9 |
+
- description: Extract metadata like lines of code and languages.
|
| 10 |
+
expected_output: Repo metadata report.
|
| 11 |
+
agent: Metadata Agent
|
| 12 |
+
|
| 13 |
+
- description: Review documentation for clarity.
|
| 14 |
+
expected_output: Documentation analysis.
|
| 15 |
+
agent: Documentation Agent
|
| 16 |
+
|
| 17 |
+
- description: Compile all findings into a final report.
|
| 18 |
+
expected_output: Comprehensive analysis report.
|
| 19 |
+
agent: Orchestrator Agent
|