litegraph.js调用gpt3 api接口效果代码

代码语言:html

所属分类:其他

代码描述:litegraph.js调用gpt3 api接口效果代码

代码标签: litegraph.js 调用 gpt3 api 接口

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">



    <link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/litegraph.css">
    <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/litegraph.js"></script>


</head>



<body style='width:100%; height:100%'>
    GPT3 API Key (click into canvas to update): <input id="api_key" type="text" , value="<API>">
    <div>
        <canvas id='mycanvas' width='2048' height='720' style='border: 1px solid'></canvas>
        <script>
            // Define new nodes
            function dummy_complete(prompt) {
              return document.getElementById("api_key").value + "Hello" + prompt;
            }
            
            const memoize = (fn) => {
              let cache = {};
              return (...args) => {
                //console.log(args)
                let n = args[0];  // just taking one argument here
                if (n in cache) {
                  //console.log('Fetching from cache');
                  return cache[n];
                }
                else {
                  console.log('Calculating result');
                  let result = fn(n);
                  cache[n] = result;
                  return result;
                }
              }
            }
             
            function complete(prompt) {
              
            fetch("https://api.openai.com/v1/engines/ada/completions", {
            headers: {
            "Content-Type": "application/json",
            "Authorization": "Bearer " + document.getElementById("api_key").value
            },
            method: ".........完整代码请登录后点击上方下载按钮下载查看

网友评论0