37亿元。受益于金价上行,黄金股ETF工银、黄金股ETF国泰、黄金股ETF工银平安、黄金股ETF工银华安均上涨超10% 电网设备ETF成为上周行业主题中流入的重要方向。
),讨论 Anthropic 的 Fable 5 比开源模型贵了三倍,商业模式能不能撑住。
import OpenAI from 'openai'import type { LlmConfig, ChatMessage } from '../types'import { LLM_CONFIG } from '../constants'class LlmService { private openai: OpenAI | null = null private currentApiKey: string = '' private initClient(config: LlmConfig): void { if (this.currentApiKey === config.apiKey && this.openai) { return // 避免重复初始化 } const baseURL = config.baseURL || LLM_CONFIG.BASE_URL this.openai = new OpenAI({ apiKey: config.apiKey, dangerouslyAllowBrowser: true, // 允许浏览器端调用 baseURL: baseURL, // 确保使用 fetch API 赋能流式 fetch: (url, init) => { console.log('LLM请求URL:', url) console.log('LLM请求配置:', { method: init?.method, headers: init?.headers, body: init?.body }) return fetch(url, init) } }) this.currentApiKey = config.apiKey } // 普通对话模式 async sendMessage(config: LlmConfig, userMessage: string): Promise { this.initClient(config) if (!this.openai) { throw new Error('LLM客户端未初始化') } const messages: ChatMessage[] = [ { role: 'system', content: LLM_CONFIG.SYSTEM_PROMPT }, { role: 'user', content: userMessage } ] try { const completion = await this.openai.chat.completions.create({ messages, model: config.model }) const response = completion.choices[0]?.message?.content return response || null } catch (error) { console.error('LLM请求失败:', error) throw error } } // 流式对话模式(核心) async sendMessageWithStream(config: LlmConfig, userMessage: string): Promise { this.initClient(config) if (!this.openai) { throw new Error('LLM客户端未初始化') } const messages: ChatMessage[] = [ { role: 'system', content: LLM_CONFIG.SYSTEM_PROMPT }, { role: 'user', content: userMessage } ] try { const stream = await this.openai.chat.completions.create({ messages, model: config.model, stream: true // 开启流式输出 }) // 返回异步迭代器,逐字输出 return (async function* () { let chunkCount = 0 for await (const part of stream) { chunkCount++ const content = part.choices[0]?.delta?.content if (content) { yield content } } })() } catch (error) { console.error('流式请求失败:', error) throw error } }}export const llmService = new LlmService()设计要点:dangerouslyAllowBrowser: true:允许在浏览器端直接调用 LLM API,适用于 Demo 场景自定义 fetch:拦截请求用于日志追踪,便于调试流式信息sendMessageWithStream 返回 AsyncIterable:调用方可通过 for await 逐字消费,落地流式播报API Key 缓存:currentApiKey 避免重复初始化 OpenAI 客户端4.5 action-manager.ts - 流式播报动作队列流式播报是灵引的核心交互机制。当 LLM 流式返回文本时,需要将文本分段发送给数字人 SDK 进行语音合成和动作驱动。ActionManager 通过队列模式管理这些播报段落,确保按顺序播放。
3.tirth8205/code-review-graph 🏷️ 项目名称: tirth8205/code-review-graph🔗 项目地址: https://github.
一个看似简单的 RAG 查询,可能因为检索到大量知识库片段而导致 Prompt Token 数飙升。
HybridCompute/machines。两个 Resource 类型具有不同的语义和治理模型。
重新实现以提高性能。现在默认四舍五入到 17 位有效数字,而不是像之前所有版本那样保留 15 位。
IT之家 7 月 27 日消息,腾讯今日宣布,QQ 宠物全新升级归来。养宠玩法升级,熟悉日常更有沉浸感QQ 宠物升级为 3D 毛茸茸形象,保留喂食、洗澡、打工等经典玩法,沉浸式体验养宠,宠物也能养成当红巨星!