Skip to content

Commit

Permalink
Merge pull request #47 from Doriandarko/flask-integration
Browse files Browse the repository at this point in the history
Integrate Flask app with maestro-anyapi.py
  • Loading branch information
Doriandarko authored May 30, 2024
2 parents 293a233 + 4c0a244 commit 0d455c6
Show file tree
Hide file tree
Showing 6 changed files with 169 additions and 0 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,28 @@ This script is released under the MIT License.

- Anthropic for providing the AI models and API.
- Rich for the beautiful console formatting.

## Flask App Integration

We have now integrated a Flask app to provide a user-friendly interface for interacting with the Maestro framework. This addition allows users to input objectives and view results through a web interface, enhancing the overall usability of the tool.

### Setting Up and Running the Flask App

To set up and run the Flask app, follow these steps:

1. Ensure Flask is installed by running `pip install Flask` or by adding Flask to the `requirements.txt` file and running `pip install -r requirements.txt`.
2. Navigate to the directory containing the Flask app files (`app.py`, `templates/`, and `static/`).
3. Run the Flask app by executing `python app.py` in your terminal or command prompt.
4. Access the web interface by opening a web browser and navigating to `http://localhost:5000/`.

The Flask app supports all features of the Maestro framework, allowing users to input objectives and view the orchestrated task breakdown and execution results in a structured and easy-to-read format.

### UI Features

The Flask app includes the following UI features:

- A form for inputting objectives.
- A results display area where the orchestrated task breakdown and execution results are shown.
- Basic styling for improved readability and user experience.

This integration aims to make the Maestro framework more accessible and user-friendly, providing an intuitive way for users to leverage the power of AI-assisted task breakdown and execution.
21 changes: 21 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from flask import Flask, render_template, request, redirect, url_for
import os
import maestro_anyapi

app = Flask(__name__)

@app.route('/', methods=['GET', 'POST'])
def index():
if request.method == 'POST':
objective = request.form.get('objective')
if objective:
results = maestro_anyapi.run_maestro(objective)
return render_template('results.html', objective=objective, results=results)
return render_template('index.html')

@app.route('/results')
def results():
return "This page will display the results."

if __name__ == '__main__':
app.run(debug=True)
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ tavily-python
ollama
groq
openai
Flask
64 changes: 64 additions & 0 deletions static/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/* Basic styling for the Flask app UI */
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f4f4f4;
}

.container {
width: 80%;
margin: auto;
overflow: hidden;
}

header {
background: #50a3a2;
color: #ffffff;
padding-top: 30px;
min-height: 70px;
border-bottom: #076585 3px solid;
}

header h1 {
text-align: center;
margin: 0;
padding-bottom: 10px;
}

nav {
background: #444;
color: #ffffff;
text-align: center;
padding: 5px;
}

nav ul {
margin: 0;
padding: 0;
}

nav ul li {
display: inline;
margin-right: 10px;
}

nav ul li a {
color: white;
text-decoration: none;
}

main {
padding: 20px;
}

footer {
background: #444;
color: white;
text-align: center;
padding: 10px;
position: fixed;
left: 0;
bottom: 0;
width: 100%;
}
29 changes: 29 additions & 0 deletions templates/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Maestro Task Orchestrator</title>
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
</head>
<body>
<div class="container">
<header>
<h1>Maestro Task Orchestrator</h1>
</header>
<nav>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/about">About</a></li>
</ul>
</nav>
<main>
{% block content %}
{% endblock %}
</main>
<footer>
<p>&copy; 2023 Maestro Task Orchestrator</p>
</footer>
</div>
</body>
</html>
29 changes: 29 additions & 0 deletions templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Maestro Task Orchestrator</title>
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
</head>
<body>
<div class="container">
<header>
<h1>Maestro Task Orchestrator</h1>
</header>
<main>
<form action="/" method="post">
<label for="objective">Enter your objective:</label>
<textarea id="objective" name="objective" rows="4" required></textarea>
<button type="submit">Submit</button>
</form>
{% if results %}
<section id="results">
<h2>Results</h2>
<p>{{ results }}</p>
</section>
{% endif %}
</main>
</div>
</body>
</html>

0 comments on commit 0d455c6

Please sign in to comment.