Bladeren bron

Update default AI prompt and image suggestions

master
nano 4 dagen geleden
bovenliggende
commit
f7f0f9d825
1 gewijzigde bestanden met toevoegingen van 35 en 1 verwijderingen
  1. +35
    -1
      app/controllers/AdminController.asp

+ 35
- 1
app/controllers/AdminController.asp Bestand weergeven

@@ -290,6 +290,9 @@ Class AdminController_Class
If parsed.data.Exists("summary") Then generatedSummary = Trim(CStr(parsed.data.Item("summary")))
If parsed.data.Exists("body") Then generatedBody = Trim(CStr(parsed.data.Item("body")))
If parsed.data.Exists("image_prompt") Then generatedImagePrompt = Trim(CStr(parsed.data.Item("image_prompt")))
If Len(Trim(generatedImagePrompt)) = 0 And parsed.data.Exists("images") Then
generatedImagePrompt = BuildImagePromptFromSuggestions(parsed.data.Item("images"))
End If
End Sub

Private Sub UpdateCommentApproval(ByVal id, ByVal isApproved, ByVal successMessage)
@@ -340,12 +343,43 @@ Class AdminController_Class
If Len(altText) = 0 Then altText = Trim(CStr(titleText))
If Len(altText) = 0 Then altText = "Feature image"

imageUrl = AiImageUrl(promptText)
imageUrl = GetOrCreateAiImageUrl(promptText)
BuildGeneratedImageHtml = "<figure class=""post-feature-image mb-4"">" & _
"<img class=""img-fluid rounded-4"" src=""" & Server.HTMLEncode(imageUrl) & """ alt=""" & Server.HTMLEncode(altText) & """ />" & _
"</figure>"
End Function

Private Function BuildImagePromptFromSuggestions(ByVal imagesData)
Dim key, imageItem, textParts, part, candidate
candidate = ""

On Error Resume Next
If TypeName(imagesData) = "Dictionary" Then
For Each key In imagesData.Keys
Set imageItem = imagesData.Item(key)
candidate = ""
If TypeName(imageItem) = "Dictionary" Then
If imageItem.Exists("search_query") Then candidate = Trim(CStr(imageItem.Item("search_query")))
If Len(candidate) = 0 And imageItem.Exists("caption") Then candidate = Trim(CStr(imageItem.Item("caption")))
If Len(candidate) = 0 And imageItem.Exists("alt_text") Then candidate = Trim(CStr(imageItem.Item("alt_text")))
If Len(candidate) > 0 Then Exit For
Else
candidate = Trim(CStr(imageItem))
If Len(candidate) > 0 Then Exit For
End If
Next
Else
candidate = Trim(CStr(imagesData))
End If
On Error GoTo 0

If Len(candidate) = 0 Then
BuildImagePromptFromSuggestions = ""
Else
BuildImagePromptFromSuggestions = candidate
End If
End Function

Private Function ExtractJsonObject(ByVal text)
Dim startPos, endPos
startPos = InStr(text, "{")


Laden…
Annuleren
Opslaan

Powered by TurnKey Linux.