GithubHelp home page GithubHelp logo

anse-app / chatgpt-demo Goto Github PK

View Code? Open in Web Editor NEW
8.0K 58.0 3.8K 2.16 MB

Minimal web UI for ChatGPT.

Home Page: https://chatgpt.ddiu.me

License: MIT License

JavaScript 5.61% Astro 21.17% TypeScript 63.01% CSS 5.91% Dockerfile 0.88% Shell 3.43%
chatgpt openai openai-api gpt-3 gpt-35 gpt-35-turbo astro chatgpt4

chatgpt-demo's People

Contributors

1wkk avatar ailoha avatar chen-jingjie avatar cnseniorious000 avatar curitis-tk avatar ddiu8081 avatar galaxyscitech avatar hswmartin avatar huandu avatar iredscarf avatar iwestlin avatar kricsleo avatar liusishan avatar ljnchn avatar lonr avatar lxxxv5 avatar nightwhite avatar pedoc avatar quzard avatar robin021 avatar shitoujianzibu avatar st6091741 avatar v2less avatar waterlemons2k avatar whatqiu avatar yangsijie666 avatar youhunwl avatar yzh990918 avatar zhangnew avatar zhullyb 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  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

chatgpt-demo's Issues

[Feature Request] Light mode

Clear and concise description of the problem

希望能跟ChatGPT 一样有深浅主题模式切换,现在的夜间模式白天看不太清楚

Suggested solution

希望能跟ChatGPT 一样有深浅主题模式切换,现在的夜间模式白天看不太清楚

Alternative

No response

Additional context

No response

Validations

npm run error: new TypeError(`${context} is not a ReadableStream.`

environment:
Linux instance-20211025-1400 5.15.0-1029-oracle #35~20.04.1-Ubuntu SMP Wed Jan 25 10:16:03 UTC 2023 aarch64 aarch64 aarch64 GNU/Linux
npm version v9.6.0
node version v16.19.1

error log :

root@instance:~/chatgpt/chatgpt-demo# npm run dev

> [email protected] dev
> astro dev

file:///root/chatgpt/chatgpt-demo/node_modules/node-fetch-native/dist/shared/node-fetch-native.2b047dc1.mjs:432
                            throw new TypeError(`${context} is not a ReadableStream.`);
                                  ^

TypeError: First parameter has member 'readable' that is not a ReadableStream.
    at assertReadableStream (file:///root/chatgpt/chatgpt-demo/node_modules/node-fetch-native/dist/shared/node-fetch-native.2b047dc1.mjs:432:21)
    at convertReadableWritablePair (file:///root/chatgpt/chatgpt-demo/node_modules/node-fetch-native/dist/shared/node-fetch-native.2b047dc1.mjs:3509:11)
    at ReadableStream.pipeThrough (file:///root/chatgpt/chatgpt-demo/node_modules/node-fetch-native/dist/shared/node-fetch-native.2b047dc1.mjs:3584:33)
    at fetchFinale (/root/chatgpt/chatgpt-demo/node_modules/undici/lib/fetch/index.js:973:52)
    at mainFetch (/root/chatgpt/chatgpt-demo/node_modules/undici/lib/fetch/index.js:773:5)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

Add a copy button to the code block

Clear and concise description of the problem

Add a copy button to the top right corner of the code block

Suggested solution

Add a copy button to the code block

When used on the official website, the code block has a copy button, hoping to add this function

Alternative

No response

Additional context

No response

Validations

Deploy on Vercel

Hello!

Thank you for creating this demonstration.

Could you please tell me the proper method for deploying it on Vercel? I attempted to do so but it did not work.

在centos上部署很复杂啊。403

在centos上部署很复杂啊。

设置和安装依赖项npm i
制作一个副本.env.example,然后将其重命名为.env

添加到.env OPENAI_API_KEY=sk-xxx...
运行应用 npm run dev

这四步成功了,打开网站,403

不合适小白一键部署,大佬出个完整教程吧,在centos上部署。

运行时,显示报错。When running, an error is displayed.

Describe the bug

error!How do I fix it?
image
image

Reproduction

error

System Info

Cause {   "errno": -4078,   "code": "ECONNREFUSED",   "syscall": "connect",   "address": "127.0.0.1",   "port": 7890 }

Used Package Manager

npm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

throw new TypeError(`${context} is not a ReadableStream.`);

Describe the bug

机器 Mac mini M1

❯ node -v
v16.13.2

❯ npm -v
8.3.0

按照 readme 操作之后,运行不起来

❯ npm run dev

[email protected] dev
astro dev

(node:55714) ExperimentalWarning: stream/web is an experimental feature. This feature could change at any time
(Use node --trace-warnings ... to show where the warning was created)
🚀 astro v2.0.17 started in 40ms

┃ Local http://localhost:3000/
┃ Network use --host to expose

file:///Users/ming/code/chatgpt-demo/node_modules/node-fetch-native/dist/shared/node-fetch-native.2b047dc1.mjs:432
throw new TypeError(${context} is not a ReadableStream.);
^

TypeError: First parameter has member 'readable' that is not a ReadableStream.
at assertReadableStream (file:///Users/ming/code/chatgpt-demo/node_modules/node-fetch-native/dist/shared/node-fetch-native.2b047dc1.mjs:432:21)
at convertReadableWritablePair (file:///Users/ming/code/chatgpt-demo/node_modules/node-fetch-native/dist/shared/node-fetch-native.2b047dc1.mjs:3509:11)
at ReadableStream.pipeThrough (file:///Users/ming/code/chatgpt-demo/node_modules/node-fetch-native/dist/shared/node-fetch-native.2b047dc1.mjs:3584:33)
at fetchFinale (/Users/ming/code/chatgpt-demo/node_modules/undici/lib/fetch/index.js:973:52)
at mainFetch (/Users/ming/code/chatgpt-demo/node_modules/undici/lib/fetch/index.js:773:5)
at processTicksAndRejections (node:internal/process/task_queues:96:5)

Reproduction

1

System Info

1

Used Package Manager

npm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

Hope the front end can add an exception handling mechanism

Clear and concise description of the problem

The front end will always show that the AI is Thinking instead of throwing an exception that exceeds the length limit. This interaction can easily confuse users.

Suggested solution

Determine whether the message length exceeds the limit, or handle the error message returned by openai.

Alternative

No response

Additional context

No response

Validations

一些反馈和需求

反馈

  1. 输出内容很长的时候,滚动条不会自往下滚
  2. 光标位置有问题,不能继续输入得点一下对话框

功能需求

  1. 能返回图片就好了
  2. 可否增加一个自定义API的功能

Why add the api for information collection in the code

https://stats.ddiu.io/app.js

!
function() {
    "use strict"; !
    function(t) {
        var e = t.screen,
        n = e.width,
        r = e.height,
        a = t.navigator.language,
        i = t.location,
        o = t.localStorage,
        c = t.document,
        u = t.history,
        s = i.hostname,
        f = i.pathname,
        l = i.search,
        d = c.currentScript;
        if (d) {
            var v, p = function(t, e) {
                return Object.keys(e).forEach((function(n) {
                    void 0 !== e[n] && (t[n] = e[n])
                })),
                t
            },
            h = function(t, e, n) {
                var r = t[e];
                return function() {
                    for (var e = [], a = arguments.length; a--;) e[a] = arguments[a];
                    return n.apply(null, e),
                    r.apply(t, e)
                }
            },
            m = function() {
                return o && o.getItem("umami.disabled") || E &&
                function() {
                    var e = t.doNotTrack,
                    n = t.navigator,
                    r = t.external,
                    a = "msTrackingProtectionEnabled",
                    i = e || n.doNotTrack || n.msDoNotTrack || r && a in r && r[a]();
                    return "1" == i || "yes" === i
                } () || A && !N.includes(s)
            },
            g = "data-",
            b = "false",
            y = d.getAttribute.bind(d),
            w = y(g + "website-id"),
            S = y(g + "host-url"),
            k = y(g + "auto-track") !== b,
            E = y(g + "do-not-track"),
            T = y(g + "css-events") !== b,
            A = y(g + "domains") || "",
            N = A.split(",").map((function(t) {
                return t.trim()
            })),
            j = (S ? S.replace(/\/$/, "") : d.src.split("/").slice(0, -1).join("/")) + "/api/collect",
            x = n + "x" + r,
            O = /^umami--([a-z]+)--([\w]+[\w-]*)$/,
            K = "[class*='umami--']",
            L = {},
            D = "" + f + l,
            P = c.referrer,
            $ = function() {
                return {
                    website: w,
                    hostname: s,
                    screen: x,
                    language: a,
                    url: D
                }
            },
            _ = function(t, e) {
                var n;
                if (!m()) return fetch(j, {
                    method: "POST",
                    body: JSON.stringify({
                        type: t,
                        payload: e
                    }),
                    headers: p({
                        "Content-Type": "application/json"
                    },
                    (n = {},
                    n["x-umami-cache"] = v, n))
                }).then((function(t) {
                    return t.text()
                })).then((function(t) {
                    return v = t
                }))
            },
            q = function(t, e, n) {
                return void 0 === t && (t = D),
                void 0 === e && (e = P),
                void 0 === n && (n = w),
                _("pageview", p($(), {
                    website: n,
                    url: t,
                    referrer: e
                }))
            },
            z = function(t, e, n, r) {
                return void 0 === n && (n = D),
                void 0 === r && (r = w),
                _("event", p($(), {
                    website: r,
                    url: n,
                    event_name: t,
                    event_data: e
                }))
            },
            C = function(t) {
                var e = t.querySelectorAll(K);
                Array.prototype.forEach.call(e, I)
            },
            I = function(t) {
                var e = t.getAttribute.bind(t); (e("class") || "").split(" ").forEach((function(n) {
                    if (O.test(n)) {
                        var r = n.split("--"),
                        a = r[1],
                        o = r[2],
                        c = L[n] ? L[n] : L[n] = function(n) {
                            "click" !== a || "A" !== t.tagName || n.ctrlKey || n.shiftKey || n.metaKey || n.button && 1 === n.button || e("target") ? z(o) : (n.preventDefault(), z(o).then((function() {
                                var t = e("href");
                                t && (i.href = t)
                            })))
                        };
                        t.addEventListener(a, c, !0)
                    }
                }))
            },
            J = function(t, e, n) {
                if (n) {
                    P = D;
                    var r = n.toString(); (D = "http" === r.substring(0, 4) ? "/" + r.split("/").splice(3).join("/") : r) !== P && q()
                }
            };
            if (!t.umami) {
                var M = function(t) {
                    return z(t)
                };
                M.trackView = q,
                M.trackEvent = z,
                t.umami = M
            }
            if (k && !m()) {
                u.pushState = h(u, "pushState", J),
                u.replaceState = h(u, "replaceState", J);
                var V = function() {
                    "complete" === c.readyState && (q(), T && (C(c), new MutationObserver((function(t) {
                        t.forEach((function(t) {
                            var e = t.target;
                            I(e),
                            C(e)
                        }))
                    })).observe(c, {
                        childList: !0,
                        subtree: !0
                    })))
                };
                c.addEventListener("readystatechange", V, !0),
                V()
            }
        }
    } (window)
} ();

这个js会向作者api发送域名,客户端分辨率等不算特别敏感的信息。虽然说不是很敏感,也明白可能是为了统计,但是这样做也是很不妥的吧。

[Feature suggestion] Add system role

Thanks for the great work.

According to https://platform.openai.com/docs/guides/chat/introduction

openai.ChatCompletion.create(
  model="gpt-3.5-turbo",
  messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Who won the world series in 2020?"},
        {"role": "assistant", "content": "The Los Angeles Dodgers won the World Series in 2020."},
        {"role": "user", "content": "Where was it played?"}
    ]
)

Seen like we can specify a "system role" to apply on the assistant role?
If that's so, maybe we can add a box in the beginning of the chat to let user write a role for the assistant?

保留、管理、继续历史会话

希望能实现类似openai官网的功能:保存和管理历史会话、继续历史会话
通过询问chatgpt,应该是可以实现的,具体包括:

  1. 在开始一个新会话时,使用UUID模块指定一个新的会话ID,并保存在本地数据库中
  2. 在数据库中保存每个会话ID对应的对话内容
  3. 如果想继续历史会话,在调用API接口时指定历史会话ID即可

[Feature Request] Multi chat support

Clear and concise description of the problem

增加类似官网的new chat功能,有个侧边栏可以保留历史聊天记录。

Suggested solution

增加类似官网的new chat功能,有个侧边栏可以保留历史聊天记录。

Alternative

No response

Additional context

No response

Validations

哪些因素和技术决定了回答的速度和回答的内容字数

作者的工作真的做的很棒!

访问作者贴出的demo链接,发现回答的速度特别快以及回答的内容都是完整的(chatgpt网页版总是会限制每次回答的字数)

想请问下作者哪些因素和技术决定了回答的速度和回答的内容字数呢?

还有作者的demo链接用的是您自己的api key吗,这样大家都可以访问的话,18美元的免费额度是不是很快就会用完呀😂

[Security] Replace Katex

Hello, it has come to my attention that Katext poses serious security vulnerabilities which have yet to be addressed. As a precaution, I advise using alternative, related packages that are consistently updated and maintained at a high level.

一些体验上修改

输入完文字回车以后ai 回答完可以自动focus 在输入框中,然后就是
image
输入框上的建议也可以屏蔽掉。

TypeError: fetch failed

TypeError: fetch failed
at Object.fetch (node:internal/deps/undici/undici:11413:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Module.post (D:\new_phpstudy_pro\WWW\chatgpt-demo-main\src\pages\api\generate.ts:14:22)
at async call (file:///D:/new_phpstudy_pro/WWW/chatgpt-demo-main/node_modules/astro/dist/core/endpoint/index.js:71:20)
at async call (file:///D:/new_phpstudy_pro/WWW/chatgpt-demo-main/node_modules/astro/dist/core/endpoint/dev/index.js:15:10)
at async handleRoute (file:///D:/new_phpstudy_pro/WWW/chatgpt-demo-main/node_modules/astro/dist/vite-plugin-astro-server/route.js:117:20)
at async run (file:///D:/new_phpstudy_pro/WWW/chatgpt-demo-main/node_modules/astro/dist/vite-plugin-astro-server/request.js:46:14)
at async runWithErrorHandling (file:///D:/new_phpstudy_pro/WWW/chatgpt-demo-main/node_modules/astro/dist/vite-plugin-astro-server/controller.js:65:5)
at async handleRequest (file:///D:/new_phpstudy_pro/WWW/chatgpt-demo-main/node_modules/astro/dist/vite-plugin-astro-server/request.js:40:3)

Cause:
ConnectTimeoutError: Connect Timeout Error
at onConnectTimeout (D:\new_phpstudy_pro\WWW\chatgpt-demo-main\node_modules\undici\lib\core\connect.js:182:24)
at D:\new_phpstudy_pro\WWW\chatgpt-demo-main\node_modules\undici\lib\core\connect.js:129:46
at Immediate._onImmediate (D:\new_phpstudy_pro\WWW\chatgpt-demo-main\node_modules\undici\lib\core\connect.js:168:33)
at process.processImmediate (node:internal/timers:476:21)

不会部署的,详细的部署步骤

frist: 非常感谢 developer 奉献了这么一个好的项目, 也为了节省大家的时间,提供一下部署的步骤:

# ---- Dependencies ----
FROM node:19.7.0 AS dependencies
WORKDIR /app
COPY package.json /app
RUN npm install

# ---- RUN ----
FROM dependencies AS RUN
WORKDIR /app
COPY . /app
COPY .env.example /app/.env
ENV PORT=3000
VOLUME ["./env"]
CMD [ "npm", "run", "dev", "--", "--port", "3000", "--host", "0.0.0.0"]

如果还是不会部署的话 这边帮忙部署环境;只需要提供域名即可;Q:1194191181

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.