feat: trimming excessively long content for AI analysis
This commit is contained in:
@@ -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}`)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user