Skip to main content

⚡The Pure Python Framework for Web Apps, Meticulously Optimized for 🤖AI agents🤖. World's first AMS🥇

Project description

Nextpy Logo

Pythonic Web App framework: For Humans & LLMs

Simple like Streamlit + Fast and Flexible like Next.js

+ 🤖 Searching for 'OpenAMS' or 'OpenAgent'? They're now seamlessly integrated into Nextpy. +

Q: Is it production-ready?

Congratulations on discovering Nextpy before its public launch! 🧭 While the documented features are production-ready (powering our own systems!), some undocumented ones might have quirks. We're actively smoothing them out, and live Discord support is just a ping away!

Ready to Dive In?

Ahoy, adventurer! 🏴‍☠️ We're thrilled to have you aboard. Let's create something extraordinary together! ✨

-----------------------------------------------------

⚡ What is Next.py ?

Nextpy is a Python Web App Framework designed for the Age of AI Agents. Built on the best ideas from prior frameworks, it's simple like Streamlit but has the perfomance and flexibility of Next.js.

💡 Key Features

Simplifying App Development:🧩

  • 🐍 Unleash Python's Full Potential - Eliminate complexities and build everything—frontend and backend—in Python, seamlessly integrating any Python library.
  • 🎨 Rich UI Library - Over 100 fully customizable built-in components for rapid UI development.
  • ⚛️ Tap into React's Power with Pythonic Wrappers - Harness the vast React ecosystem directly within Python, utilizing any React library without JavaScript knowledge.
  • 🚀 Built-in Performance Optimizations - Deliver exceptional user experiences with automatic image, font, and script optimizations for lightning-fast loading speeds and responsiveness. See the difference for yourself at nextpy.org.

Better AI Generations: ‍🤖

  • 🧠 More Effective Than Chaining or Prompt Engineering - Next.py aligns with LLM processing patterns, enabling precise output control and optimal model utilization.
  • 💡 Optimized for Code Generation - Regardless of the LLMs, prompts, or fine-tuning used, the underlying app framework significantly impacts the efficiency of code generation. Next.py's architecture is specifically engineered to maximize efficiency.
  • 💾 Session State with LLM - Efficiently maintain state with LLMs, leveraging KV caches to convert multiple output tokens into prompt token batches. This approach reduces redundant generations, accelerating the handling of lengthy and intricate prompts. (only for open-source models)
  • 🧪 Detect Syntax Errors: Test LLM-generated code, identifying and correcting LLM hallucinations, invalid Nextpy methods, and automatically generating prompts for seamless fixes.

Developer-First: ❤️

  • 📘 Transferable Knowledge - Learning Next.py instills framework-agnostic fundamentals, enhancing your app development expertise and enabling you to excel across any frameworks.
  • 🛠️ Extensible - If you know how to do something in Python or plain English, you can integrate it with nextpy.

-----------------------------------------------------

🚀 Quick Start (2 mins)

1. Installing Nextpy

Open your terminal and prepare for an adventure of a lifetime!

pip install nextpy

(Remember, Python 3.7 or later is required.)

2. Initializing Your App

Navigate to the desired directory for your project in the terminal. Use the nextpy init command to initialize a template app in your new directory.

nextpy init

3. Choose your template:

For now, just press enter to automatically default to the blank template.

    Blank Template: A simple single page template
    Base Template: A multi-page app with a sidebar

4. Running the App

In the same directory where you previously ran nextpy init, enter the following command:

nextpy run

5. View the App:

Check out your app by visiting http://localhost:3000

[!NOTE] Your application is now fully functional. To view the frontend, navigate to localhost:3000. The backend server is accessible at localhost:8000. While it's unlikely you'll ever directly interact with it, the backend API documentation can be found at localhost:8000/docs, and the openapi.json file is located at localhost:8000/openapi.json.

🎨 Start with a template!

We speedup your development with a ever growing list of community templates. Some examples:

Powerful tables Portfolio Sites Interactive Charts AI chat Crud Apps Onboarding

Setting Up the Template

  1. Copy the template files to your local folder.
  2. Install necessary dependencies with pip install -r requirements.txt.
  3. Initialize your app by running nextpy init.
  4. Launch the app with nextpy run to see it in action. To check the site visit localhost:3000

➖ or ➖


🤣 Building a Joke Generator App (5 mins)

Edit myapp/myapp.py to create your app.

1. Import Libraries

import nextpy as xt
import pyjokes

Start by importing nextpy for development and pyjokes for random jokes.

2. Set Up the App State

class State(xt.State):
    joke: str = "Click the button to get a joke!"

    def generate_joke(self):
        self.joke = pyjokes.get_joke()

Create a State class with a joke variable. Use generate_joke to fetch new jokes.

3. Design the Main Page

def index():
    layout = xt.vstack(
        xt.text(State.joke, font_size="2em"),
        xt.button("Generate Joke", on_click=State.generate_joke),
    )
    return layout

The index function arranges a joke display and a button. vstack is used to stack components vertically, while hstack is used to stack components horizontally.

4. Optional Styling

def index():
    layout = xt.vstack(
        xt.text(State.joke, font_size="2em"),
        xt.button("Generate Joke", on_click=State.generate_joke),

        spacing="1em",
        align_items="center",
        justify_content="center",
        height="100vh",
   )
    return layout

The spacing attribute adds space between the text and button elements, while align_items and justify_content ensure that these elements are centered. The stack's height is set to 100% of the Viewport Height (100vh), which allows the vertical stack to fill the entire height of your screen.

5. Setup the app

app = xt.App()
app.add_page(index)

Set up the app, add the main page. To view the frontend, navigate to localhost:3000.

-----------------------------------------------------

Why another framework?

In our quest to create self-writing applications, we delved deep into a labyrinth of coding tools, frameworks, and libraries. Our experiments spanned all major large language models (LLMs), thousands of prompts, and every major web development framework, from React to Streamlit.

[!TIP] We discovered that the choice of the underlying app framework can greatly influence the efficiency of code generation, regardless of the LLMs, prompts, or fine-tuning techniques employed.

Initially, reflex's flexibility seemed promising, aligning with several of our requirements. However, as we expremented with different web apps, crucial feature gaps emerged. Bridging these gaps necessitated extensive "glue code," which dramatically slowed down development.

For months, we resisted reinventing the wheel, piecing together disparate tools to forge our vision. But eventually, the ROI no longer justified this approach. Consequently, we began selectively integrating the best features from existing frameworks to craft a superior web app framework. This new framework combines Streamlit's simplicity with the speed and adaptability of Next.js. For the backend, we've chosen FastAPI for its straightforwardness, coupled with Pydantic for its robust type-checking. We've also embraced SQLModel for database connectivity. Our frontend was constructed using a customized version of the Reflex library, into which we've incorporated new components. We are currently in the process of rewriting the core Python-to-JavaScript compiler to maximize speed. Moreover, we have developed a simple, JSON-based database that leverages JSON as the data storage medium while providing SQL-like capabilities.

Our mission is to make Next.py the most efficient app framework, empowering both humans and AI agents.

🙏 Thanks

Nextpy Framework is a state-of-the-art app development framerwork optimized for AI-based code generation, built on the open-source community’s spirit of cooperation. It integrates key components from landmark projects like Guidance, Llama-Index, FastAPI-Mail, LangChain, ReactPy, Reflex, Chakra, Radix, Numpy and Next.js, while also drawing insights from the React and Rust ecosystems. This fusion ideas has been pivotal in shaping Nextpy into a framework that's not just AI-friendly but also a trailblazer in generative web development tools.

We are deeply grateful to the open-source creators, contributors, and maintainers whose work has provided the basis for Nextpy. Your commitment to innovation and openness has been vital for shaping this framework. Your contributions have not only enhanced Nextpy but are also advancing the new era of AI-powered software development. Thank you for being the catalysts and enablers of this transformational journey.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nextpy-0.0.3.tar.gz (1.1 MB view hashes)

Uploaded Source

Built Distribution

nextpy-0.0.3-py3-none-any.whl (1.8 MB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page