feat: add url ranking

This commit is contained in:
Han Xiao
2025-03-04 16:51:53 +08:00
parent 51ad77d302
commit ae95d74ca0
2 changed files with 3 additions and 4 deletions

View File

@@ -137,8 +137,7 @@ ${learnedStrategy}
urlList = (weightedURLs)
.filter(r => 'url' in r)
.sort((a, b) => (b.boostedWeight || 0) - (a.boostedWeight || 0))
.slice(0, 10) // save context window and reduce noise, only keep top 10 urls
.map(r => ` + weight: ${r.boostedWeight.toFixed(3)} "${r.url}": "${r.title}"`)
.map(r => ` + weight: ${r.boostedWeight.toFixed(2)} "${r.url}": "${r.title}"`)
.join('\n');
}
@@ -147,7 +146,7 @@ ${learnedStrategy}
- Access and read full content from URLs
- Must check URLs mentioned in <question> if any
${urlList ? `
- Choose and visit relevant URLs below for more knowledge. higher weight means more relevant and you should visit first:
- Choose and visit relevant URLs below for more knowledge. higher weight suggests more relevant:
<url-list>
${urlList}
</url-list>

View File

@@ -3,7 +3,7 @@ import {TokenTracker} from "../utils/token-tracker";
import {JINA_API_KEY} from "../config";
const JINA_API_URL = 'https://api.jina.ai/v1/embeddings';
const SIMILARITY_THRESHOLD = 0.888; // Adjustable threshold for cosine similarity
const SIMILARITY_THRESHOLD = 0.86; // Adjustable threshold for cosine similarity
const JINA_API_CONFIG = {
MODEL: 'jina-embeddings-v3',