BillionMail gives you open-source MailServer, NewsLetter, Email Marketing — fully self-hosted, dev-friendly, and free from monthly fees. Join the discord: https://discord.gg/asfXzBUhZr
Adjust the prompt words to ensure that the generated email is complete
hwliang5f8038d4b815
diff --git a/core/internal/service/askai/chat.go b/core/internal/service/askai/chat.goindex 1b284d7a..e20ac9ac 100644--- a/core/internal/service/askai/chat.go+++ b/core/internal/service/askai/chat.go@@ -6,6 +6,7 @@ import ("encoding/json""errors""os"+ "strings""github.com/gogf/gf/v2/frame/g")@@ -240,10 +241,16 @@ func GetChatInfo(chatId string) (*ChatInfo, error) {}func Chat(ctx context.Context, chatId string, supplierName string, modelId string, content string, isText bool) error {+ content = strings.TrimSpace(content)+ if content == "" {+ return errors.New("Content cannot be empty")+ }+supplierInfo, err := GetSupplierConfig(supplierName)if err != nil {return errors.New("Supplier not found")}+modelInfo := GetModelInfo(supplierName, modelId)if modelInfo == nil {return errors.New("Model not found")diff --git a/core/internal/service/askai/openai.go b/core/internal/service/askai/openai.goindex 316bc15d..967a34ba 100644--- a/core/internal/service/askai/openai.go+++ b/core/internal/service/askai/openai.go@@ -609,7 +609,8 @@ func (o *OpenAI) CreateChatCompletionStream(request *ghttp.Request, req openai.C}if err != nil {fmt.Println("Error receiving stream:", err)- return err+ // return err+ break}// Check if the response contains tool callsif len(response.Choices[0].Delta.ToolCalls) > 0 {diff --git a/core/internal/service/askai/prompts.go b/core/internal/service/askai/prompts.goindex 2ec2ba44..fc60c452 100644--- a/core/internal/service/askai/prompts.go+++ b/core/internal/service/askai/prompts.go@@ -17,7 +17,7 @@ Functions:Requirements for Email Generation (only used when generating emails):1. Please use HTML to generate an exquisite marketing promotion email. On the premise of focusing on the beautiful and delicate design of the email interface, meet the following requirements: The email content must include an eye-catching subject, a clear brand logo, an attractive product/activity introduction (including core selling points, preferential information, etc.), clear call-to-action buttons (such as "Buy Now", "Learn More", etc.), necessary contact information and unsubscribe options. In terms of visual design, the color matching should pay attention to layering and harmony. The matching mode of main color + auxiliary color + accent color can be adopted, with the main color accounting for 60%, the auxiliary color 30%, and the accent color 10%. The color saturation and lightness are moderate to avoid being too dazzling or dark. In terms of layout, the art of white space should be used to have reasonable spacing between elements to create a sense of breath. At the same time, strengthen the layering through alignment, grouping and other methods. The combination of pictures and texts should be natural and appropriate. The pictures should be high-definition and highly relevant to the content. You can appropriately add design elements such as shadows and rounded corners to enhance the three-dimensional sense. The font selection should match the overall style. The title font can be more designed, and the text font should be clear and easy to read. The font size and spacing should be reasonably distinguished according to the importance of the content to improve reading comfort. The overall style should be simple, professional and vibrant according to the characteristics of the target audience (urban white-collar workers aged 25-40), and at the same time incorporate exquisite detail designs, such as the hover effect of buttons, subtle gradients of borders, creative design of dividing lines, etc.- 2. The generated HTML email must have good compatibility, be compatible with mainstream email clients (such as Gmail, Outlook, NetEase Mail, QQ Mail, etc.), and display normally on different devices (computers, mobile phones, tablets) to avoid problems such as layout disorder, inability to load pictures, and text overlap. The code should be concise and standardized, and avoid using JavaScript scripts.+ 2. The generated HTML email must have good compatibility, be compatible with mainstream email clients (such as Gmail, Outlook, NetEase Mail, QQ Mail, etc.), and display normally on different devices (computers, mobile phones, tablets) to avoid problems such as layout disorder, inability to load pictures, and text overlap. The code should be concise and standardized, and avoid using JavaScript scripts, Avoid complex CSS styles, pay attention to controlling code length to reduce token overhead.3. Regarding the use of pictures: only use pictures from reliable sources, and it is forbidden to fabricate false pictures.4. The email subject should be concise and clear, able to accurately convey the email theme and attract users' attention, and put the subject into the HTML <title> tag. The main body of the email must contain a clear brand logo (such as a logo), and provide contact information (such as customer service phone number, email address, etc.) at the beginning or end of the email, so that users can easily contact you if they have any questions or need further information.5. Note: If there is a QR code for contact information, use it as much as possible, but note that the size of the QR code should not be less than 80x80px. When you need to use icons in the main text, you can use emojis or Unicode characters instead of icons to avoid using pictures with uncertain purposes.