This commit is contained in:
josc146
2024-03-22 15:33:48 +08:00
parent d53d8b8614
commit 9773a5d196
2 changed files with 3 additions and 3 deletions
@@ -3,10 +3,10 @@ import { cropText } from '../../../utils'
export default {
inputQuery: async () => {
try {
const title = document.querySelector('[id*="post-title"]').textContent
const title = document.querySelector('[id*="post-title"]')?.textContent
const description = document.querySelector(
'shreddit-post > div.text-neutral-content',
).textContent
)?.textContent
const texts = document.querySelectorAll('shreddit-comment div.md')
let answers = ''
for (let i = 0; i < texts.length; i++) {
+1 -1
View File
@@ -35,7 +35,7 @@ export async function cropText(
tiktoken = true,
) {
const userConfig = await getUserConfig()
const k = Models[userConfig.modelName].desc.match(/[- ]*([0-9]+)k/)?.[1]
const k = Models[userConfig.modelName].desc.match(/[- (]*([0-9]+)k/)?.[1]
if (k) {
maxLength = Number(k) * 1000
maxLength -= 100 + clamp(userConfig.maxResponseTokenLength, 1, maxLength - 1000)