Skip to content

Commit

Permalink
drawboard AI
Browse files Browse the repository at this point in the history
SQUASHED: AUTO-COMMIT-demos-javascript-double-import.js,AUTO-COMMIT-demos-markdown-full-height.md,AUTO-COMMIT-demos-openai-drawboard-ai.js,AUTO-COMMIT-demos-openai-drawboard-ai.md,AUTO-COMMIT-src-external-eslint-eslint-lint.js,
  • Loading branch information
JensLincke committed May 15, 2024
1 parent 061eb6c commit 5ebdb77
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 0 deletions.
6 changes: 6 additions & 0 deletions demos/javascript/double-import.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import {value} from "./a.js"


var foo =3

lively.notify("double import! " + value)
27 changes: 27 additions & 0 deletions demos/markdown/full-height.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<script>
var div = <div style="position: absolute; top: 0px; left: 0px; width:calc(100% - 0px); height:calc(100% - 0px); background: gray">
<div style="position: relative; width:100px; height:200px; background: GREEN">


</div>

</div>

// lively.query(this, "lively-markdown")


// lively.query(this, "#content").style.border= "2px solid blue"

// lively.query(this, "#content").style.height = "500px"
// lively.query(this, "#content").style.width = "700px"
// lively.query(this, "#content").style.position = "relative"


// this.style.border= "2px solid green"
// this.style.height = "300px"
// this.style.width = "700px"
// this.style.position = "relative"


div
</script>
61 changes: 61 additions & 0 deletions demos/openai/drawboard-ai.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
```javascript
import OpenAI from "demos/openai/openai.js"

// let drawboard = that

let input = "Can you make the line fat?"


let originalSVG = drawboard.innerHTML

let prompt = {
"model": "gpt-4o", // gpt-4o
"max_tokens": 500,
"temperature": 0.1,
"top_p": 1,
"n": 1,
"stream": false,
"stop": "VANILLA",
"messages": [
{ "role": "system", "content": "You are an SVG editor help!" },
{ "role": "user", "content": [
{
"type": "text",
"text": "Here is some svg: "
},
{
"type": "text",
"text": originalSVG
},
{
"type": "text",
"text":input
},
// {
// "type": "image_url",
// "image_url": {
// "url": image,
// "detail": "low" // high
// }
// }
]}
]
}
var json = await OpenAI.openAIRequest(prompt).then(r => r.json())
let generatedSVG =

json.choices[0].message.content.replace(/(.|\n)*<svg/g,"<svg").replace(/```(.|\n)*/,"")

/*
drawboard.innerHTML = originalSVG
drawboard.initSVGInteraction()
*/


drawboard.innerHTML = generatedSVG
drawboard.initSVGInteraction()


lively.notify("completed", generatedSVG)
```
4 changes: 4 additions & 0 deletions src/external/eslint/eslint-lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,12 +323,16 @@ import {parse} from "./eslint-parser.js";
}

function validator(text, options) {

var result = [], config = defaultConfig;
var linter = new eslint();
linter.defineParser("babel-parser", {parse});
config.parser = "babel-parser";
try {
var errors = linter.verify(text, config);

// lively.notify("validator ", text.slice(0,100), 2000, () => lively.openInspector(errors))

} catch(err) {
lively.warn("BUG error during linting ")
// console.error("ESLINT ERROR during linting", err, "source: " + text)
Expand Down

0 comments on commit 5ebdb77

Please sign in to comment.