feat: trimming excessively long content for AI analysis

This commit is contained in:
DIYgod
2023-04-17 22:13:32 +01:00
parent 6d33e0e398
commit d70fe1cf87
2 changed files with 12 additions and 3 deletions
+5 -1
View File
@@ -6,7 +6,11 @@ import { cacheGet } from "~/lib/redis.server"
const getOriginalScore = async (cid: string) => {
try {
const { content } = await (await fetch(toGateway(`ipfs://${cid}`))).json()
let { content } = await (await fetch(toGateway(`ipfs://${cid}`))).json()
if (content?.length > 5000) {
content = content.slice(0, 5000)
}
if (content?.length > 200) {
console.time(`fetching score ${cid}`)
+7 -2
View File
@@ -21,9 +21,14 @@ const chains = new Map<string, AnalyzeDocumentChain>()
const getOriginalSummary = async (cid: string, lang: string) => {
try {
const { content } = await (await fetch(toGateway(`ipfs://${cid}`))).json()
let { content } = await (await fetch(toGateway(`ipfs://${cid}`))).json()
if (content) {
if (content?.length > 5000) {
content = content.slice(0, 5000)
}
if (content?.length < 200) {
return ""
} else if (content) {
console.time(`fetching summary ${cid}, ${lang}`)
let chain = chains.get(lang)