dirk1983 / chatgpt

演示站现在可以免费使用ChatGPT对话和画图了。全网最易部署,响应速度最快的ChatGPT环境。PHP版调用OpenAI接口进行问答和画图,采用Stream流模式通信,一边生成一边输出。前端采用EventSource,支持Markdown格式解析,支持公式显示,代码有着色处理,支持画图。页面UI简洁,支持上下文连续会话。源码只有几个文件,没用任何框架,支持所有PHP版本,全部开源,极易二开。保姆级教程,账号等周边资源,欢迎进群交流,一切全免费。

Home Page:https://mm1.ltd

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to use "Draw"

oleteacher opened this issue · comments

commented

"Support calling the official OpenAI interface to draw pictures, and the first word of the question is "draw" to generate pictures."

Pictures is a wonderful addition; kids will love it. I was trying it out on the latest release and cannot get it to work?

I assume that you enter "Draw" into prompt area? Like: Draw photo on a unicorn

Thanks in advance for input.

commented

可能因为作者只适配了中文的画图功能,你可能需要修改js和php文件搜索'画'来修改相关代码并且改成draw这个单词

commented

Perhaps because the author only adapted the Chinese drawing function, you may need to modify the js and php files to search for '画' to modify the relevant code and change to the word draw

commented

Thank you @xy3xy3 for response. Providing the '画" help me much. Still cannot get it to work after changing to english word: draw:

I’m sorry, as an AI language model, I don’t have the ability to provide images. Can I assist you with anything else?

I assume you simply use like: draw unicorn

commented

you should also change setsession.php
<?php $context = json_decode($_POST['context'] ?: "[]") ?: []; if (mb_substr($_POST["message"], 0, 1, 'UTF-8') === '画'||mb_substr($_POST["message"], 0, 4, "UTF-8") === "draw") { $postData = [ "prompt" => $_POST['message'], "n" => 1, "size" => "1024x1024" ]; } else { $postData = [ "model" => "gpt-3.5-turbo", "temperature" => 0, "stream" => true, "messages" => [], ]; if (!empty($context)) { $context = array_slice($context, -5); foreach ($context as $message) { $postData['messages'][] = ['role' => 'user', 'content' => str_replace("\n", "\\n", $message[0])]; $postData['messages'][] = ['role' => 'assistant', 'content' => str_replace("\n", "\\n", $message[1])]; } } $postData['messages'][] = ['role' => 'user', 'content' => $_POST['message']]; } $postData = json_encode($postData); session_start(); $_SESSION['data'] = $postData; if ((isset($_POST['key'])) && (!empty($_POST['key']))) { $_SESSION['key'] = $_POST['key']; } echo '{"success":true}'; ![Uploading Screenshot_2023-06-25-00-07-04-581_com.kiwibrowser.browser.jpg…]()

commented

Screenshot_2023-06-25-00-07-04-581_com kiwibrowser browser

commented

I think on my first try there was caching issues. After waiting some time, the "draw" seems to work but no picture returning. I used "draw a cat". Processing took some time and then return success message but no picture. Error in dev console is:

Uncaught TypeError: Cannot read properties of undefined (reading '0')
    at es.onmessage (chat.js?v2.8:320:33)

Looks like I have some troubleshooting to do.

Thank you @xy3xy3 for your help!