瀏覽代碼

fix: LLM may not return `<think>` tag, cause thinking time keep increase (#13962)

tags/1.0.0
NFish 8 月之前
父節點
當前提交
ece25bce1a
沒有連結到貢獻者的電子郵件帳戶。
共有 2 個檔案被更改,包括 7 行新增6 行删除
  1. 3
    3
      web/.env.example
  2. 4
    3
      web/app/components/base/markdown.tsx

+ 3
- 3
web/.env.example 查看文件

# console or api domain. # console or api domain.
# example: http://udify.app/api # example: http://udify.app/api
NEXT_PUBLIC_PUBLIC_API_PREFIX=http://localhost:5001/api NEXT_PUBLIC_PUBLIC_API_PREFIX=http://localhost:5001/api
# The APIFREX for MARKETPLACE
NEXT_PUBLIC_MARKETPLACE_API_PREFIX=http://localhost:5002/api
# The API PREFIX for MARKETPLACE
NEXT_PUBLIC_MARKETPLACE_API_PREFIX=https://marketplace.dify.ai/api/v1
# The URL for MARKETPLACE # The URL for MARKETPLACE
NEXT_PUBLIC_MARKETPLACE_URL_PREFIX=
NEXT_PUBLIC_MARKETPLACE_URL_PREFIX=https://marketplace.dify.ai


# SENTRY # SENTRY
NEXT_PUBLIC_SENTRY_DSN= NEXT_PUBLIC_SENTRY_DSN=

+ 4
- 3
web/app/components/base/markdown.tsx 查看文件

} }


const preprocessThinkTag = (content: string) => { const preprocessThinkTag = (content: string) => {
if (!content.trim().startsWith('<think>\n'))
if (!(content.trim().startsWith('<think>\n') || content.trim().startsWith('<details style=')))
return content return content


return flow([ return flow([
(str: string) => str.replace('<think>\n', '<details>\n'),
(str: string) => str.replace('\n</think>', '\n[ENDTHINKFLAG]</details>'),
(str: string) => str.replaceAll('<think>\n', '<details>\n'),
(str: string) => str.replaceAll('\n</think>', '\n[ENDTHINKFLAG]</details>'),
(str: string) => str.replaceAll('\n</details>', '\n[ENDTHINKFLAG]</details>'),
])(content) ])(content)
} }



Loading…
取消
儲存