Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dreamberd does not support WebAssembly #277

Closed
olliebun opened this issue Jul 24, 2023 · 5 comments
Closed

Dreamberd does not support WebAssembly #277

olliebun opened this issue Jul 24, 2023 · 5 comments

Comments

@olliebun
Copy link

I want to deploy my high performance dreamberd applications as WASM bundles to get the best experience for my developers. They want to read about OpenGL instead of using the DOM or the canvas API and I say good on them.

Dreamberd does not support webassembly.

Please add this feature to unblock my team.

@abb128
Copy link

abb128 commented Aug 7, 2023

I am the CEO of a new AI startup looking for series A investment and we are soon launching our new service Webassembly C which is open-source, self-hostable, and leverages open source AI to do exactly this, here is an example use:

$ wc hello.c
$ ls hello.wasm
hello.wasm

Note: The open source part only consists of the wc application which is a bash script to send a slack message to one of our team members, who will put your code through the ChatGPT 4 interface together with our special proprietary prompt, and respond with the output which will be written by the script. We are currently looking to outsource this work

Note: You can also self-host the service by changing the slack API key to your own

@abb128
Copy link

abb128 commented Aug 7, 2023

I am also happy to announce we are hiring. Our current stack consists of Auth0, OpenAI, Google Cloud, Stripe, Next.js Web App, Node.js + Express Web API, Python + FastAPI AI API, Django, PostgresQL, Redis, Heroku, Terraform, AWS are all used for our landing page. Although we may not necessarily have any other pages,

@AquaQuokka
Copy link

These PRs never fail to make me chuckle

@lunaneff
Copy link

this code should work, hopefully:

use common_macros::hash_map;
use gloo_net::http::Request;
use wasm_bindgen::prelude::*;

#[wasm_bindgen]
extern "C" {
    #[wasm_bindgen(js_namespace = console, js_name = log)]
    fn console_log(s: &str);
}

macro_rules! log {
    ($($t:tt)*) => (console_log(&format_args!($($t)*).to_string()))
}

#[wasm_bindgen(start)]
pub async fn main() -> Result<(), JsValue> {
    let c = include_str!(env!("C_DOCS"));
    let code = include_str!(env!("C_SRC"));
    let prompt = format!(
        "{}\n\n{}\n\n{}",
        c, "What would you expect this program to log to the console?", code
    );
    let Ok(output) = chatgpt(&prompt).await else { return Err(JsValue::from_str("Failed to get response from API")); };
    log!("{}", output);
    Ok(())
}

async fn chatgpt(input: &str) -> Result<String, gloo_net::Error> {
    Ok(
        Request::get("https://api.openai.com/v1/engines/davinci-codex/completions")
            .header("Authorization", env!("OPENAI_API_KEY"))
            .json(&hash_map! {
                "prompt" => input,
                "max_tokens" => "100",
            })?
            .send()
            .await?
            .text()
            .await?,
    )
}

set C_DOCS to point to the documentation for C, C_SRC to point to your source file, and OPENAI_API_KEY to your API key at compile time

@olliebun
Copy link
Author

OCaml is the future now - see #730.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants