Skip to main content

Overview

Canvas provides a persistent text document system that allows you to create, edit, and manage text content with AI assistance. Without Canvas, text editing requires manual file management and lacks intelligent content organization. With Canvas, you can:
  • Create persistent documents - Build and maintain text documents that persist across sessions
  • Intelligent editing - Use AI to intelligently update and modify document sections
  • Automatic organization - Let AI handle content placement and document structure
  • Clean formatting - Automatically remove code blocks and maintain clean text
  • Flexible content management - Add, update, or replace sections as needed

Quick Start

Your First Canvas

from upsonic import Canvas, Task, Agent

# Create a canvas with a name
canvas = Canvas("My Project Notes")

# Get current state (starts empty)
current_content = canvas.get_current_state_of_canvas()
print(current_content)  # "Empty Canvas"

# Add initial content
await canvas.change_in_canvas(
    new_text_of_part="# Project Overview\nThis is my project documentation",
    part_definition="overview"
)

Using Canvas with Agent and Task

from upsonic import Canvas, Task, Agent

# Create canvas and agent
canvas = Canvas("Meeting Notes")
agent = Agent("openai/gpt-4o")

# Task to create meeting notes
task = Task("""
Create comprehensive meeting notes for our weekly team standup including:
- Attendees and their roles
- Key discussion points
- Action items with owners
- Next meeting agenda
""")

# Execute task and update canvas
result = agent.do(task)
await canvas.change_in_canvas(
    new_text_of_part=result,
    part_definition="weekly standup"
)

Document Updates with AI

from upsonic import Canvas, Task, Agent

canvas = Canvas("Project Documentation")
agent = Agent("openai/gpt-4o")

# Update existing document
task = Task("""
Review and update the project documentation with:
- Latest technical specifications
- Updated API endpoints
- New deployment procedures
- Security best practices
""")

result = agent.do(task)
await canvas.change_in_canvas(
    new_text_of_part=result,
    part_definition="technical updates"
)

Configuration Guide

Basic Canvas Setup

from upsonic import Canvas, Task, Agent

# Simple canvas with default model
canvas = Canvas("My Document")

# Canvas with custom model
canvas = Canvas("Technical Notes", model_provider="openai/gpt-4o")

# Using canvas with agent
agent = Agent("openai/gpt-4o")
task = Task("Create a project summary document")
result = agent.do(task)
await canvas.change_in_canvas(result, "project summary")

Real-World Examples

Meeting Notes with Agent

from upsonic import Canvas, Task, Agent

canvas = Canvas("Weekly Standup")
agent = Agent("openai/gpt-4o")

task = Task("""
Create meeting notes for our weekly standup including:
- Team updates and blockers
- Action items with owners
- Next week priorities
""")

result = agent.do(task)
await canvas.change_in_canvas(result, "weekly standup")

Technical Documentation

from upsonic import Canvas, Task, Agent

canvas = Canvas("API Documentation")
agent = Agent("openai/gpt-4o")

task = Task("""
Create comprehensive API documentation for our user management endpoints:
- Authentication methods
- Request/response examples
- Error handling
- Rate limiting
""")

result = agent.do(task)
await canvas.change_in_canvas(result, "API docs")

Tips and Best Practices

  • Use descriptive canvas names - “Project Documentation” vs “Doc1”
  • Structure content logically - Use clear section headers
  • Update incrementally - Build documents progressively
  • Use appropriate models - Choose models that fit your content complexity
I