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

How to use "Draw" #100

Open
oleteacher opened this issue Jun 9, 2023 · 6 comments
Open

How to use "Draw" #100

oleteacher opened this issue Jun 9, 2023 · 6 comments

Comments

@oleteacher
Copy link

"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.

@xy3xy3
Copy link

xy3xy3 commented Jun 24, 2023

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

@xy3xy3
Copy link

xy3xy3 commented Jun 24, 2023

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

@oleteacher
Copy link
Author

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

@xy3xy3
Copy link

xy3xy3 commented Jun 24, 2023

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…]()

@xy3xy3
Copy link

xy3xy3 commented Jun 24, 2023

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

@oleteacher
Copy link
Author

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!

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

2 participants