Code Monkey home page Code Monkey logo

dot-agent / nextpy Goto Github PK

View Code? Open in Web Editor NEW
2.2K 27.0 154.0 57.98 MB

๐Ÿค–Self-Modifying Framework from the Future ๐Ÿ”ฎ World's First AMS

Home Page: https://dotagent.ai

License: Apache License 2.0

Python 94.26% Shell 0.05% Jupyter Notebook 2.58% JavaScript 1.88% Dockerfile 0.02% Jinja 0.25% CSS 0.03% Batchfile 0.01% Mako 0.01% Handlebars 0.35% HTML 0.21% Vue 0.37%
agent agi ai autogpt gpt llmops mlops ai-agents fastapi fullstack-development

nextpy's Introduction

Note

Hey there, Friend!

This project is still in the "just for friends" stage. If you want to see what we're messing with and have some thoughts, take a look at the code. We'd love your feedback or contributions.

image

What is Nextpy?

Nextpy is a framework for building self-modifying software.

Key Features

๐Ÿšง Guardrails

  • Set clear boundaries: Users can precisely define what the AI system can and cannot do. This safeguard ensures that the AI system remains a dynamic, self-improving system without overstepping established limits.

๐Ÿ—๏ธ Greater control with structured outputs

  • More effective than chaining or prompting: The prompt engine unlocks the next level of prompt engineering, offering significantly greater control over LLMs compared to few-shot prompting or traditional chaining methods.

  • Superpowers to prompt engineers: It gives full power of prompt engineering, aligning with how LLMs actually process text. This understanding enables you to precisely control the output, defining the exact response structure and instructing LLMs on how to generate responses.

๐Ÿญ Powerful prompt engine

The philosophy is to handle more processing at compile time and maintain better sessions with LLMs.

  • Pre-compiling prompts: By handling basic prompt processing at compile time, unnecessary redundant LLM processing is eliminated.

  • Session state with LLMs: Maintaining state with LLMs and reusing KV caches can eliminate many redundant generations and significantly speed up the process for longer and more complex prompts. (only for open-source models)

  • Optimized tokens: The engine can transform many output tokens into prompt token batches, which are cheaper and faster. The structure of the template can dynamically guide the probabilities of subsequent tokens, ensuring alignment with the template and optimized tokenization. (only for open-source models)

  • Speculative sampling (WIP): You can enhance token generation speed in a large language model by using a smaller model as an assistant. The method relies on an algorithm that generates multiple tokens per transformer call using a faster draft model. This can lead to up to a 3x speedup in token generation.

๐Ÿค– 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.

๐Ÿงฑ Modularity

  • Multiplatform: The AI system does not have to run on a single location or machine. Different components can run across various platforms, including the cloud, personal computers, or mobile devices.

  • Extensible: If you know how to do something in Python or plain English, you can integrate it with Nextpy.

โค๏ธ Developer-First: โค๏ธ

  • ๐Ÿ“˜ Transferable Knowledge - Learning Next.py teaches you framework-agnostic fundamentals and the best Python libraries, improving your python development expertise and enabling you to excel across any framework.

๐Ÿ“ฆ Containerized & scalable

  • .๐Ÿค– files: The underlying agents can be effortlessly exported into a simple .agent or .๐Ÿค– file, allowing them to run in any environment.

  • Agentbox (optional): The AI system should be able to optimize computing resources inside a sandbox. You can use Agentbox locally or on a cloud with a simple API, with cloud Agentbox offering additional control and safety.

Performance

  • โšก 4-10x faster than your Streamlit app: Our compiled software achieves a staggering 4-10x performance leap over Streamlit. See the difference for yourself at nextpy.org, boasting a PageSpeed score of 99/100.

image

๐Ÿ™ Thanks

NextPy Framework is a cutting-edge software development framework optimized for AI-based code generation, built on the spirit of cooperation within the open-source community. It seamlessly integrates key components from landmark projects like Guidance, DSPy, Llama-Index, FastAPI-Mail, LangChain, ReactPy, Reflex, Chakra, Radix, NumPy, and Next.js, while also drawing insights from the React and Rust ecosystems.

One of the interesting modules is the generative UI module, which currently uses a forked version of Reflex, Reacton, and Solara.

We are deeply grateful to the open-source creators, contributors, and maintainers whose work has provided the foundation for NextPy. Your commitment to innovation and openness has been vital in 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.

nextpy's People

Contributors

abhi06027 avatar anubrag avatar aumjavalgikar avatar d21it185bapodrarajsatish avatar niikkhilsharma avatar noobpook avatar ooooo-create avatar pradeepsaini384 avatar pravin-jalodiya avatar raj4646 avatar shravya-34 avatar siddhantojha17 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nextpy's Issues

Enhance xt.input attribute

def index() -> xt.Component:
    layout = xt.form(xt.vstack(
        xt.input(
            placeholder="Paste YAML code here",
            on_change=State.on_yaml_input_change,
            width="30%",
            height="300px",
        ), ),
        xt.button("Convert to Python", on_click=State.handle_conversion),
        xt.text(State.python_data, font_size="2em"),
        spacing="1em",
        align_items="center",
        justify_content="center",
        height="100vh",
    )
    return layout

Problem statement

when I type inside the input it shows
image

Feature

When I press enter it should go to next line

Benchmark Nextpy vs Streamlit performance

Recreate the Streamlit roadmap page using Nextpy. This will serve as a practical demonstration of Nextpyโ€™s performance in a real-world application scenario. Use this recreation as a benchmark to quantify the performance differences between Streamlit and Nextpy.

Attribute to upload the file

def index() -> xt.Component:
    layout = xt.box(
        # xt.title("Resume Search App"),
        xt.file_uploader("Upload your resume", on_change=on_file_upload),
        xt.text_input("Enter the text which you want to search: ", bind="search_text"),
        xt.button("Search", on_click=search_resume),
        xt.stack(
            [xt.box(result, style={"margin_bottom": "10px"}) for result in xt.bind("search_results")]
        ),
    )
    return layout

May I kindly request that someone inform me of the appropriate attribute to upload the pdf or document file?

Migrate Nextpy to Pydantic v2 for Enhanced Performance and Compatibility

It's time to upgrade Nextpy to Pydantic v2. This migration is crucial to leverage the latest performance improvements and ensure compatibility with other libraries that are also moving to Pydantic v2.

Expected Benefits

  • Performance Improvements: Pydantic v2 comes with significant enhancements in performance, which can positively impact the overall efficiency of Nextpy.
  • Better Compatibility: Keeping up with the latest version ensures that Nextpy remains compatible with other tools and libraries in the ecosystem that rely on Pydantic.
  • Access to New Features: Pydantic v2 introduces new features and improvements, which can be beneficial for future development and feature enhancements in Nextpy.

Potential Challenges & Blockers

  • Dependencies on Other Libraries: Some dependencies like sqlmodel might have compatibility issues that need to be addressed.
  • Internal API Changes: Pydantic v2 has made changes to some of its internal APIs (e.g., ModelField no longer exists). We need to find suitable alternatives or workarounds for these changes.

Call for Contributions

We invite contributors to join in on this upgrade process. Whether you have experience with Pydantic internals or are new to it, your input and help would be valuable.

  • If you have experience with Pydantic v2 or its internals, your guidance can help overcome specific challenges.
  • For those who are new, this could be a great learning opportunity and a way to contribute significantly to the Nextpy project.

Progress Tracking

  • Assess the impact of migration on existing codebase
  • Identify and resolve dependencies issues with sqlmodel
  • Update the Nextpy codebase to adapt to Pydantic v2 API changes
  • Thorough testing to ensure stability post-migration
  • Update documentation to reflect changes

Collaboration and Updates

  • For ongoing discussions, please refer to this thread.
  • Contributors working on related tasks are encouraged to share updates and findings here.
  • Any significant breakthroughs or challenges can be discussed in follow-up comments.

Conclusion

Migrating to Pydantic v2 is an important step for the future of Nextpy. It ensures that our framework stays up-to-date with the latest advancements and continues to integrate smoothly within the broader Python ecosystem.

Refactor GridX Portfolio Code for Beginner Friendliness

The current implementation of the GridX portfolio code, while functional and well-tested, presents a level of complexity that may be challenging for beginners to understand. To make the codebase more accessible, especially for those new to programming or the specific technologies used, a simplification is needed.

When I click on image, it's not opening the link

xt.button(
                # xt.link("https://github.com/anirudh-hegde", ),
                # on_click=lambda : open_github),
                xt.image(
                    src="/github.svg",
                    height="30px",
                    width="30px",
                    padding_right='1px',
                    target="https://github.com/anirudh-hegde"
                ),
            ),

Improved logging in multiagent_manager

The issue:

Logging in MultiagentManager currently uses print statements with a conditional variable passed as a parameter "debug" with the default value False. This is a temporary solution.

The solution:

Whenever the conditional variable "debug" is checked, simply store the current logging level in a variable, set current logging to DEBUG, log the statement, then set the logging level back to its original state. This way if a user has previously not set the logging, they do not need to manually do it in their code, they can simply pass "debug"=True. This is also helpful when you have multiple managers but you only want to debug one of them.

mood switcher app error

this almost like the doc ,but hava a error.
ๅพฎไฟกๆˆชๅ›พ_20240105122546
There are also some codes written according to the official documentation that just don't work, and I can't fix the problem.

Unknown instruction CMD["nextpy","init","&&","nextpy","run"]

FROM python:3.8-alpine
WORKDIR /app
COPY Casper.py .
COPY requirements.txt .
RUN pip install -r requirements.txt
CMD["nextpy","init","&&","nextpy","run"]

When I try to build, it shows the error: ERROR: failed to solve: dockerfile parse error on line 7: unknown instruction: CMD["nextpy","run"]

Enhance Tailwind CSS Plugin Support

Currently, integrating certain Tailwind CSS plugins into Nextpy projects presents a significant challenge. This is primarily due to the limited customization options available within the tailwind.config.js setup. This limitation hinders the ability to fully exploit the capabilities of the Tailwind CSS ecosystem, consequently restricting design and functionality enhancements in Nextpy projects.

Specific Challenges:

  • Difficulty in integrating Tailwind CSS plugins that require more complex setup than a simple require in tailwind.config.js.
  • The current setup within the Nextpy framework offers limited flexibility, particularly in terms of customizing the Tailwind CSS configuration.

Suggested Solutions:

  1. Template Customization:

    • Enhance the flexibility of the Jinja template (tailwind.config.js.jinja2) used in Nextpy.
    • The enhancement should aim to accommodate a variety of plugin integration scenarios, allowing for more complex plugin configurations.
  2. Custom Configuration Support:

    • Enable users to provide their own tailwind.config.js file.
    • Alternatively, allow the use of a custom Jinja template for tailwind.css.
    • This would grant users greater control and versatility in terms of plugin integration and configuration.

Expected Outcome:
Implementing these solutions will significantly improve the ease of integrating diverse Tailwind CSS plugins into Nextpy projects. This enhancement is anticipated to unlock more design and functionality options, aligning Nextpy more closely with the broader Tailwind CSS ecosystem and community practices.

Introduce @xt.method Decorator for AI Code Generation Compatibility

We could introduce @xt.method decorator in Nextpy for defining event handlers within state classes. This feature is intended to enhance code readability, standardize the declaration of methods handling state changes, and align with AI code generation practices.

Current Behavior

Currently, Nextpy requires methods within state classes to be defined directly, without specific decorators. This approach is functional but does not distinguish between regular methods and event handlers explicitly designed to modify the state.

Proposed Behavior

The introduction of the @xt.method decorator would allow developers to clearly mark methods in the state class as event handlers. This not only improves code readability but also aligns with AI code generation patterns, where such decorators are often included by default. It could also facilitate additional framework optimizations or checks.

For example:

@xt.method(ToDoState)
def delete_todo(state, todo):
    state.todos.remove(todo)

Benefits

  • Improved Code Readability and Maintainability: Clearly distinguishes state-modifying methods from regular class methods.
  • Alignment with AI Code Generation: Aligns with default practices of AI code generation tools, which often include method decorators in their outputs.

Set text and image in same order

xt.box(


                xt.center(xt.text("YAML-2-PYTHON",
                        # margin_top="20px",
                        font_size="39px",
                        text_align="center",

                        color="violet",
                        ),),
                xt.link(
                    xt.image(src="/github.svg",
                             height="57px",
                             width="57px",
                             text_align="center",
                             align_items="center",
                             justify_content="center",
                             flex_direction="column",
                             margin_left="98em",
                             ),
                    is_external=True,
                    href="https://github.com/anirudh-hegde"
                ),
                bg="black",
                height="100%",
                align_items="center",
                justify_content="center",

        ),

It's showing
image
Set text and image in appropriate order

OpenAgent not working on 3.9 of python

  • Figure out the versions on which the script fails and due to what dependencies and fix those
  • Update the documentation for support on latest version
  • Update root pytoml file

:3000 ERR_CONNECTION_REFUSED.

:3000 ERR_CONNECTION_REFUSED.
And I do not know why.

โ€œโ€โ€œ
Starting Nextpy App
Compiling: โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” 100% 15/15 0:00:00
Compiling takes time, but the compiled app is super fastโšก:
โ€โ€œโ€

Refactor `App` Class in `app.py` for Streamlined Code and Maintenance

GitHub Issue: Refactoring the App Class in app.py for Enhanced Readability and Maintainability

Overview

The App class in app.py is central to our Nextpy application but currently handles an extensive range of functionalities, leading to complexity and potential maintainability issues. This issue aims to refactor App by effectively leveraging existing modules (admin.py, event.py, state.py) and improving code organization.

Current State

  • The App class is multifaceted, combining numerous functionalities which complicates the codebase.

Objective

  • Streamline the App class to efficiently utilize admin.py, event.py, and state.py.
  • Reduce redundancy and enhance code clarity.

Proposal Details

1. Integration with Existing Modules:

  • Thoroughly review and integrate admin.py, event.py, and state.py to offload respective functionalities from App.
  • Eliminate duplicate implementations in App that are already handled by these modules.

2. Streamlining Event Handling:

  • Refine event handling in App using the structured approach defined in event.py.
  • Create a more intuitive interface between App and the event module for cleaner and more maintainable code.

3. State Management Refinement:

  • Centralize state management responsibilities in state.py, and modify App to interact seamlessly with this module.
  • Simplify and clarify the state management processes within App.

4. Admin Dashboard Integration Enhancement:

  • Extract and relocate admin dashboard setup (e.g., setup_admin_dash) to a dedicated class within admin.py.
  • Ensure this class handles all admin-related functionalities, providing a clean interface with App.

5. Code Cleanup and Optimization:

  • Identify and refactor complex or redundant sections in App.
  • Focus on enhancing readability and execution efficiency.

TODO:

  • Step 1: Module Integration Review

    • Assess overlaps and interactions between App and the modules (admin.py, event.py, state.py), documenting the findings.
  • Step 2: Event Handling Refinement

    • Revise App's event handling, aligning and integrating changes with event.py.
  • Step 3: State Management Enhancement

    • Overhaul App's state management in coordination with modifications in state.py.
  • Step 4: Admin Dashboard Integration Refinement

    • Reorganize admin dashboard functionality from App to admin.py.
  • Step 5: Code Cleanup and Refactoring

    • Execute comprehensive code refinement in App, focusing on simplification and optimization.
  • Step 6: Testing and Validation

    • Confirm that refactoring retains existing functionality.
    • Implement extensive testing to verify new code structures and performance.

Expected Outcomes:

  • A more streamlined and readable App class.
  • Reduced code redundancy and improved integration with existing modules.
  • A well-organized and efficient codebase, facilitating future development and maintenance.

Additional Notes:

  • Ensure backward compatibility and maintain core functionality post-refactoring.

This issue aims to significantly enhance the Nextpy framework's app.py file, focusing on structural improvements and efficient use of existing resources. The end goal is a more maintainable, clear, and efficient codebase that continues to deliver robust functionality.

Improve state management.

The goal of this feature request is to integrate SQLSync into the Nextpy framework. SQLSync is a collaborative, offline-first wrapper around SQLite, aimed at synchronizing web application state across various users, devices, and the edge. The integration of SQLSync will enable Nextpy to efficiently manage application state in a distributed environment, enhancing its capabilities in terms of data consistency, offline functionality, and real-time collaboration.

Feature Proposal: Enhanced Single-File Execution in Any Directory Structure

Current State

  • nextpy's run command requires a predefined directory structure for execution.

Objective

  • Enable users to execute individual files with nextpy run, regardless of the directory structure, similar to tools like Streamlit .

Proposal Details

1. Command Enhancement:

  • Modify nextpy run to primarily accept a file path:
    • -f or --file: Path to the target file (relative or absolute).
    • -t or --theme: Optional theme (defaults to standard if not provided).

2. Operational Logic:

  • Ensure the file's existence at the given path.
  • Determine the file type (e.g., .mdx, .py) and execute accordingly.
  • For .mdx files, use the default MDX viewer, or apply the specified theme.
  • For .py files, execute the script in an isolated or appropriate environment.
  • Provide error messages and graceful exits for unsupported file types or execution errors.

3. Environment Independence:

  • Eliminate dependency on a specific project structure.
  • Set up the necessary minimal environment based on the file type.
  • Allow environment variables or configurations to be specified via command line or external config files for flexibility.

4. Theme Integration and Default Viewer:

  • Same as previously proposed.

Sample Usage:

Run a File in Any Directory:

$ nextpy run -f /path/to/file.mdx
$ nextpy run -f ./relative/path/to/script.py

With Custom Theme:

$ nextpy run -f /path/to/file.mdx -t bespoke_theme

Resultant Execution:

  • Executing this command will focus on the specified file only, setting up a minimal environment as required.
  • The command will be independent of the directory structure, allowing flexibility in file organization.

Advantages:

  • Streamlines the process of running individual files, making it more accessible and flexible.
  • Reduces the necessity for a comprehensive initial setup, facilitating quick testing and prototyping.
  • Enhances the user experience, particularly beneficial for new users and in educational contexts.

Implementation Considerations:

  • Robust error handling and informative messaging for user guidance.
  • Extensive testing with various file locations and types to ensure reliability.
  • Documentation updates to guide users on new command usage and capabilities.

Potential Directory Structure Post-Execution:

.any_directory
โ”œโ”€โ”€ executed_file.mdx (or .py, etc.)
โ”œโ”€โ”€ .web (if necessary for execution)
โ””โ”€โ”€ other_files_or_directories (unrelated to nextpy execution)

TODO

Step 1: Requirements Analysis

  • Analyze the current functionality of the nextpy run command.
  • Identify the limitations with respect to directory structure dependence.

Step 2: Design Command Enhancements

  • Design the new command line interface to accept a file path (-f or --file) and an optional theme (-t or --theme).
  • Plan how the command will handle different file types (e.g., .mdx, .py).

Step 3: Update Command Line Interface

  • Modify the run command in Typer to accept the file path as a primary argument.
  • Implement the logic to parse and handle the optional theme argument.

Step 4: Implement File Detection and Execution Logic

  • Develop a function to validate the existence of the specified file.
  • Create a function to determine the file type based on the file extension or content.
  • Implement the execution logic for .mdx files, including using the default MDX viewer or the specified theme.
  • Implement the execution logic for .py files, ensuring they run correctly irrespective of the directory structure.

Step 5: Environment Setup

  • Establish a minimal environment setup required for the execution of the specified file.
  • Ensure environment variable or configuration can be set externally if required.

Step 6: Testing and Quality Assurance

  • Conduct unit testing for new functionalities.
  • Perform integration testing to ensure the new command works seamlessly with existing features.
  • Test the command with various file types and in different directory structures.

Step 7: Error Handling and User Feedback

  • Implement robust error handling for unsupported file types, missing files, and execution errors.
  • Develop user-friendly error messages and guidance for troubleshooting.

Step 8: Documentation and Examples

  • Update the project documentation to include the new command usage.
  • Provide example use cases and command line inputs in the documentation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.