Code Monkey home page Code Monkey logo

codemotion-x0's Introduction

Create your own v0 exploiting generative AI

Setup

  1. Install backend project dependencies
    cd backend
    pnpm i
  2. Install frontend project dependencies
    cd ../frontend
    pnpm i
  3. Copy backend/sample.env in backend/config.env
  4. Paste the OpenAI API key from the chat into backend/config.env

Workshop checkpoints

Start from the main branch and checkout the following branches to see the code changes for each step:

  • 1-design-step-simple
  • 2-design-step-structured-output
  • 3-code-generation-step
  • 4-fix-errors-step
  • 5-fix-errors-iteratively-step

Pipeline prototype

The generation pipeline flow diagram

Design Step

Generative Task

  • A preliminary ideation step where no code is involved
  • The user's request is enriched and converted into a list of components from our component library to be used
import { DesignNewComponentOutput, PipelineInputs } from '../utils/types';

export async function designStep(inputs: PipelineInputs): Promise<DesignNewComponentOutput> {
  // Retrieve context
  // Prepare prompt messages
  // Invoke llm
  // Parse/format output
}

Code Generation Step

Generative Task

  • Code generation step where the user's request is converted into code
  • The components listed in the previous step are used to generate the code
import { DesignNewComponentOutput } from '../utils/types';

export async function codeGenerationStep(inputs: DesignNewComponentOutput): Promise<string> {
  // Retrieve context
  // Prepare prompt messages
  // Invoke llm
  // Parse/format output
}

Validation Step

Deterministic Task

  • Sometimes llm can generate code that is not valid, this step is used to ensure that the generated code is valid
  • The TypeScript source code is checked and transpiled to JSX to be rendered with react-dom/server API
import { ValidationOutput } from '../utils/validation';

export function validationStep(sourceCode: string): ValidationOutput {
  // Validate and transpile TypeScript source code to JavaScript
  // Test JSX rendering
  // Return validation output
}

Fix Errors Step

Generative Task

  • If the generated code is not valid, this step is used to fix the errors
export async function fixErrorsStep(sourceCode: string, errors: string[]): Promise<string> {
  // Prepare prompt messages
  // Invoke llm
  // Parse/format output
}

Who we are?

A proudly ๐Ÿ‡ฎ๐Ÿ‡น digital products and AI startup.
We consider ourselves a family of talented and passionate people building their own products and powerful solutions for our clients. Get to know us more on xtreamers.io or follow us on LinkedIn.

codemotion-x0's People

Contributors

zoncrd avatar rams23 avatar

Stargazers

Lucio Bordonaro avatar

Watchers

 avatar Emanuele Fabbiani avatar Alberto Di Gioacchino avatar Simone Colucci avatar  avatar

Forkers

perronemirko

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.