Skip to content

Commit

Permalink
add link in URL
Browse files Browse the repository at this point in the history
  • Loading branch information
BennyThink committed Jul 21, 2024
1 parent 7862746 commit 38b9695
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions ai_openai.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func encodeImageToBase64(filePath string) string {
return "data:image/jpeg;base64," + base64String
}

func imageToText(data string) string {
func imageToText(link, data string) string {
client := initAI()
const prompt = `This is a screenshot of a webpage, I want you to transcribe this page's main content into text.
Skip preamble and only return the result`
Expand Down Expand Up @@ -69,8 +69,7 @@ Skip preamble and only return the result`
}

var content = resp.Choices[0].Message.Content
const p = `This conversation is based on this text:\n\n`
return p + content
return fmt.Sprintf("Following text is a transcribe of %s:\n\n%s\n", link, content)
}

func askOpenAI(userID int64) string {
Expand Down
2 changes: 1 addition & 1 deletion database.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func enableAI(userID int64, link string, data string) *User {
db.Save(&user)
}
// OCR the text
text := imageToText(data)
text := imageToText(link, data)
addChat(userID, systemRole, text)
return user
}
Expand Down

0 comments on commit 38b9695

Please sign in to comment.