frdel / agent-zero

Agent Zero AI framework
Other
3.26k stars 767 forks source link

getting tool not found to run python code #39

Open deepanshu-sagar opened 1 month ago

deepanshu-sagar commented 1 month ago

initial prompt create a python flask application with UI, this page have the option to add what i ate today. in a sqllite database as backend, and retrieve when i ask for it. also need to see my eating history on a flask page with interactive date time filters

`(.venv) (base) deepanshusagar@L1879 agent-zero % python main.py Initializing framework...

User message ('e' to leave):

create a python flask application with UI, this page have the option to add what i ate today. in a sqllite database as backend, and retrieve when i ask for it. also need to see my eating history on a flask page with interactive date time filters

Agent 0: Starting a message: Based on the provided specification, I will guide you through creating a Python Flask application that meets your requirements.

Step 1: Create a new SQLite database

First, we'll create a new SQLite database using the sqlite3 module in Python. We'll name it eating_history.db.

import sqlite3

# Connect to the SQLite database
conn = sqlite3.connect('eating_history.db')
cursor = conn.cursor()

# Create a table for storing eating history
cursor.execute('''
    CREATE TABLE IF NOT EXISTS eating_history (
        id INTEGER PRIMARY KEY,
        date TEXT,
        time TEXT,
        food TEXT
    )
''')

# Commit the changes and close the connection
conn.commit()
conn.close()

Step 2: Create a Flask application

Next, we'll create a new Flask application using the flask module.

from flask import Flask, render_template, request

app = Flask(__name__)

# Load the SQLite database
conn = sqlite3.connect('eating_history.db')
cursor = conn.cursor()

Step 3: Create a route for adding food

We'll create a new route /add-food that allows users to add their food intake.

@app.route('/add-food', methods=['GET', 'POST'])
def add_food():
    if request.method == 'POST':
        date = request.form['date']
        time = request.form['time']
        food = request.form['food']

        # Insert the data into the SQLite database
        cursor.execute('INSERT INTO eating_history (date, time, food) VALUES (?, ?, ?)', (date, time, food))
        conn.commit()

        return 'Food added successfully!'
    else:
        return render_template('add_food.html')

Step 4: Create a route for viewing eating history

We'll create a new route /eating-history that allows users to view their eating history.

@app.route('/eating-history', methods=['GET'])
def eating_history():
    # Retrieve the data from the SQLite database
    cursor.execute('SELECT * FROM eating_history')
    rows = cursor.fetchall()

    return render_template('eating_history.html', rows=rows)

Step 5: Create templates for adding food and viewing eating history

We'll create two new templates add_food.html and eating_history.html.

add_food.html:

<!DOCTYPE html>
<html>
<head>
    <title>Add Food</title>
</head>
<body>
    <h1>Add Food</h1>
    <form method="POST">
        <label for="date">Date:</label>
        <input type="date" id="date" name="date"><br><br>
        <label for="time">Time:</label>
        <input type="time" id="time" name="time"><br><br>
        <label for="food">Food:</label>
        <input type="text" id="food" name="food"><br><br>
        <input type="submit" value="Add Food">
    </form>
</body>
</html>

eating_history.html:

<!DOCTYPE html>
<html>
<head>
    <title>Eating History</title>
</head>
<body>
    <h1>Eating History</h1>
    <table border="1">
        <tr>
            <th>Date</th>
            <th>Time</th>
            <th>Food</th>
        </tr>
        {% for row in rows %}
        <tr>
            <td>{{ row[1] }}</td>
            <td>{{ row[2] }}</td>
            <td>{{ row[3] }}</td>
        </tr>
        {% endfor %}
    </table>
</body>
</html>

Step 6: Run the Flask application

Finally, we'll run the Flask application using the run method.

if __name__ == '__main__':
    app.run(debug=True)

This will start the development server and make the application available at http://localhost:5000.

You can access the /add-food route by visiting http://localhost:5000/add-food, and the /eating-history route by visiting http://localhost:5000/eating-history.

Agent 0: Using tool '':

Agent 0: Response from tool '': { "system_warning": "Tool not found. Available tools: \n## Tools available:

response:

Final answer for user. Ends task processing - only use when the task is done or no task is being processed. Place your result in "text" argument. Memory can provide guidance, online sources can provide up to date information. Always verify memory by online. Example usage: {`

frdel commented 1 month ago

Seems like the model is chatting instead of providing JSON response with tool usage. This happens with smaller models that are not trained to provide technical structured output. You can try to convince the model by editing the system prompt, or switch to another model. Gemma2 models are not bad for their sizes for example.