🎉 Feat: add PostChat AI support

This commit is contained in:
Cell
2024-12-18 16:39:39 +08:00
parent 0e7dc99319
commit 5931bf3786
3 changed files with 148 additions and 0 deletions
+47
View File
@@ -886,6 +886,53 @@ enableEmoji = true
# "corner-indicator", "fill-left", "flash", "flat-top", "loading-bar", "mac-osx", "material", "minimal"]
theme = "minimal"
# FixIt 0.3.17 | NEW PostChat AI config
# Summary AI, knowledge base search and knowledge base dialogue support
# Docs: https://postchat.zhheo.com/
[params.postChat]
enable = false
# Get PostChat Key from my invitation link, thanks for your support!
# https://ai.tianli0.top/?InviteID=IRE1S88Z
key = "ed872bf9336506bea545183089f5034f81fea6af"
# How users initiate chats: ["iframe", "magic"]
userMode = "magic"
addButton = true
defaultInput = false
left = ""
bottom = ""
width = ""
height = ""
fill = ""
backgroundColor = ""
upLoadWeb = true
showInviteLink = true
userTitle = ""
userDesc = ""
# dom container to be blacked out, e.g. [".aplayer"]
blackDom = []
# Only for iframe mode
frameWidth = "" # e.g. "375px"
frameHeight = "" # e.g. "600px"
# only for magic mode
userIcon = ""
defaultChatQuestions = []
defaultSearchQuestions = []
# FixIt 0.3.17 | NEW Summary AI config
# See https://postchat.zhheo.com/summary.html
[params.postSummary]
enable = false
# If you set `params.postChat.key`, you don't need to set `params.postSummary.key`
key = ""
title = ""
# themes options: ["", "simple", "yanzhi"]
theme = ""
postURL = ""
blacklist = ""
wordLimit = 1000
typingAnimate = true
beginningText = ""
# FixIt 0.3.10 | NEW Global Feed config for RSS, Atom and JSON feed.
[params.feed]
# The number of posts to include in the feed. If set to -1, all posts.
+98
View File
@@ -0,0 +1,98 @@
{{- /*
PostChat AI service for single page. (Only for type "posts")
PostChat: https://postchat.zhheo.com/addCode.html
PostSummary: https://postchat.zhheo.com/summary.html
*/ -}}
{{- $chatConfig := .Param "postChat" -}}
{{- $summaryConfig := .Param "postSummary" -}}
{{- $enable := $chatConfig.enable | or $summaryConfig.enable -}}
{{- $key := $chatConfig.key | default $summaryConfig.key -}}
{{- $sourcePrefix := "https://ai.tianli0.top/static/public/" -}}
{{- $jsMap := dict
"chat" "postChatUser.min.js"
"summary" "tianli_gpt.min.js"
"both" "postChatUser_summary.min.js"
-}}
{{- if $enable | and $key -}}
{{- $configJS := "" -}}
{{- $fingerprint := .Scratch.Get "fingerprint" -}}
{{- $sourceOpts := dict "Fingerprint" $fingerprint "Defer" true -}}
{{- /* PostSummary */ -}}
{{- if $summaryConfig.enable -}}
{{- $postChatCSS := "https://ai.tianli0.top/static/public/postChatUser_summary.min.css" -}}
{{- dict "Source" $postChatCSS "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/style.html" -}}
{{- $p := "tianliGPT" -}}
{{- $postSummaryConfig := printf "let %v_postSelector='#content';" $p -}}
{{- with $summaryConfig.title -}}
{{- $postSummaryConfig = add $postSummaryConfig (printf "let %v_Title='%v';" $p .) -}}
{{- end -}}
{{- with $summaryConfig.theme -}}
{{- $postSummaryConfig = add $postSummaryConfig (printf "let %v_theme='%v';" $p .) -}}
{{- end -}}
{{- with $summaryConfig.postURL -}}
{{- $postSummaryConfig = add $postSummaryConfig (printf "let %v_postURL='%v';" $p .) -}}
{{- end -}}
{{- with $summaryConfig.blacklist -}}
{{- $postSummaryConfig = add $postSummaryConfig (printf "let %v_blacklist='%v';" $p .) -}}
{{- end -}}
{{- with $summaryConfig.wordLimit -}}
{{- $postSummaryConfig = add $postSummaryConfig (printf "let %v_wordLimit='%v';" $p .) -}}
{{- end -}}
{{- if eq $summaryConfig.typingAnimate false -}}
{{- $postSummaryConfig = add $postSummaryConfig (printf "let %v_typingAnimate=false;" $p) -}}
{{- end -}}
{{- with $summaryConfig.beginningText -}}
{{- $postSummaryConfig = add $postSummaryConfig (printf "let %v_BeginningText='%v';" $p .) -}}
{{- end -}}
{{- if $chatConfig.enable -}}
{{- $postSummaryConfig = add $postSummaryConfig (printf "let %v_recommendation=true;" $p) -}}
{{- else -}}
{{- $postSummaryConfig = add $postSummaryConfig (printf "let %v_key='%v';" $p $key) -}}
{{- end -}}
{{- $configJS = add $configJS $postSummaryConfig -}}
{{- end -}}
{{- /* PostChat */ -}}
{{- if $chatConfig.enable -}}
{{- $sourceOpts = dict "Attr" (printf "data-postChat_key=%q" $key) | merge $sourceOpts -}}
{{- $postChatConfig := dict
"userMode" $chatConfig.userMode
"defaultInput" $chatConfig.defaultInput
"left" $chatConfig.left
"bottom" $chatConfig.bottom
"width" $chatConfig.width
"height" $chatConfig.height
"fill" $chatConfig.fill
"backgroundColor" $chatConfig.backgroundColor
"upLoadWeb" $chatConfig.upLoadWeb
"showInviteLink" $chatConfig.showInviteLink
"userTitle" $chatConfig.userTitle
"userDesc" $chatConfig.userDesc
"addButton" $chatConfig.addButton
"blackDom" $chatConfig.blackDom
"frameWidth" $chatConfig.frameWidth
"frameHeight" $chatConfig.frameHeight
"userIcon" $chatConfig.userIcon
"defaultChatQuestions" $chatConfig.defaultChatQuestions
"defaultSearchQuestions" $chatConfig.defaultSearchQuestions
-}}
{{- $configJS = add $configJS ($postChatConfig | jsonify | printf "var postChatConfig=%s") -}}
{{- end -}}
{{- /* Insert config */ -}}
{{- $configJS | dict "Content" | dict "Scratch" .Scratch "Data" | partial "scratch/script.html" -}}
{{- /* Insert script */ -}}
{{- $postChatJS := "" -}}
{{- if $chatConfig.enable | and $summaryConfig.enable -}}
{{- $postChatJS = add $sourcePrefix (index $jsMap "both") -}}
{{- else if $chatConfig.enable -}}
{{- $postChatJS = add $sourcePrefix (index $jsMap "chat") -}}
{{- else if $summaryConfig.enable -}}
{{- $postChatJS = add $sourcePrefix (index $jsMap "summary") -}}
{{- end -}}
{{- $sourceOpts = dict "Source" $postChatJS | merge $sourceOpts -}}
{{- $sourceOpts | dict "Scratch" $.Scratch "Data" | partial "scratch/script.html" -}}
{{- end -}}
+3
View File
@@ -166,6 +166,9 @@
{{- /* Expiration Reminder */ -}}
{{- partial "single/expiration-reminder.html" . -}}
{{- $content -}}
{{- /* PostChat */ -}}
{{- partial "single/post-chat-ai.html" . -}}
{{- end -}}
</div>