当前位置: 首页 > news >正文

asp网站开发实例百度首页登录

asp网站开发实例,百度首页登录,做网站建设网站制作,三合一网站方案📝 LangChain.js 是一个快速开发大模型应用的框架,它提供了一系列强大的功能和工具,使得开发者能够更加高效地构建复杂的应用程序。LangChain.js 实战系列文章将介绍在实际项目中使用 LangChain.js 时的一些方法和技巧。 统计调用大模型的 to…

📝 LangChain.js 是一个快速开发大模型应用的框架,它提供了一系列强大的功能和工具,使得开发者能够更加高效地构建复杂的应用程序。LangChain.js 实战系列文章将介绍在实际项目中使用 LangChain.js 时的一些方法和技巧。

统计调用大模型的 token 使用量,进而统计整体的账单花费,是一个非常基础的需求,在 LangChain.js 中统计 token 的方式有两种,一种是方法的返回,一种是利用回调函数:

1️⃣ 在方法中返回 token 的使用情况,比如 generate()

const chat = new ChatOpenAI({modelName: 'gpt-4',openAIApiKey: 'YOUR_KEY',
})const response = await chat.generate([[new SystemMessage("你是一个翻译专家,可以将中文翻译成法语。"),new HumanMessage("把这个句子翻译从中文翻译成法语:我特别喜欢上班"),]
]);

generate() 方法会返回如下:

{"generations": [[{"text": "J'aime beaucoup travailler."//...}]],"llmOutput": {"tokenUsage": {"completionTokens": 16,"promptTokens": 17,"totalTokens": 33}}
}

llmOutput 字段包含我们整个的 token 使用量,其中 promptTokens 对应的是输入的 token,completionTokens 对应的是输出的 token,对于 OpenAI 来说,输入输出的价格是不一的,如下表:

模型名输入输出
gpt-4$0.03 / 1K tokens$0.06 / 1K tokens
gpt-3.5-turbo-1106$0.0010 / 1K tokens$0.0020 / 1K tokens
gpt-4-1106-preview$0.01 / 1K tokens$0.03 / 1K tokens
gpt-4-1106-vision-preview$0.01 / 1K tokens$0.03 / 1K tokens

2️⃣ 使用回调函数 handleLLMEnd

LangChain 提供了大量方便的回调函数,我们可以利用其提供的内置的 handleLLMEnd() 函数来统计,我们可以在创建 ChatOpenAI 实例的时候注入回调函数:

const chat = new ChatOpenAI({modelName: 'gpt-4',openAIApiKey: 'YOUR_KEY',
}, {callbacks: [{handleLLMEnd(llmResult) {console.log(JSON.stringify(llmResult, null, 2))},}]
})

回调参数 llmResultgenerate() 方法返回值是一样的,同样有包含 tokenUsage

另外也可以在调用的时候再注入回调函数,可以更精细地统计:

model.invoke([new SystemMessage('Only return JSON'),new HumanMessage('Hi there!')],{callbacks: [{handleLLMEnd(llmResult) {console.log(JSON.stringify(llmResult, null, 2))},},],})

好了,希望以上两种方式可以帮助大家统计大模型的开销,护好钱兜。

推荐一个集聊天、工作流和知识库的AI 平台 StarFlow.tech 🚀 。在这里,你可以免费使用 ChatGPT3.5 和 3.5 16K,还有 GPT-4 Vision、DELL·E3、Midjourney 等多种模型可供选择。这个平台就像一个小型工作室,助力个人效率 Max!。


文章转载自:
http://typhoeus.Lnnc.cn
http://knish.Lnnc.cn
http://nation.Lnnc.cn
http://prefatorial.Lnnc.cn
http://porridge.Lnnc.cn
http://disarray.Lnnc.cn
http://craniocerebral.Lnnc.cn
http://monumentally.Lnnc.cn
http://clemency.Lnnc.cn
http://topmaul.Lnnc.cn
http://dermoskeleton.Lnnc.cn
http://baron.Lnnc.cn
http://hemostat.Lnnc.cn
http://paperwork.Lnnc.cn
http://sydneyite.Lnnc.cn
http://defocus.Lnnc.cn
http://diffractometer.Lnnc.cn
http://aluminium.Lnnc.cn
http://stultification.Lnnc.cn
http://nananne.Lnnc.cn
http://fishpaste.Lnnc.cn
http://grayest.Lnnc.cn
http://revisional.Lnnc.cn
http://befittingly.Lnnc.cn
http://petiolate.Lnnc.cn
http://axil.Lnnc.cn
http://lough.Lnnc.cn
http://eugenic.Lnnc.cn
http://actomyosin.Lnnc.cn
http://reflecting.Lnnc.cn
http://galician.Lnnc.cn
http://achromat.Lnnc.cn
http://kalistrontite.Lnnc.cn
http://respondentia.Lnnc.cn
http://hallux.Lnnc.cn
http://fescue.Lnnc.cn
http://fuchsia.Lnnc.cn
http://protrusile.Lnnc.cn
http://babble.Lnnc.cn
http://tantalus.Lnnc.cn
http://lightfast.Lnnc.cn
http://shapely.Lnnc.cn
http://strychnia.Lnnc.cn
http://resorcinol.Lnnc.cn
http://polysaccharide.Lnnc.cn
http://pipsissewa.Lnnc.cn
http://sabbatism.Lnnc.cn
http://weighable.Lnnc.cn
http://micrometre.Lnnc.cn
http://taffarel.Lnnc.cn
http://merl.Lnnc.cn
http://penultimate.Lnnc.cn
http://deck.Lnnc.cn
http://photosensitise.Lnnc.cn
http://alumnus.Lnnc.cn
http://hemihydrate.Lnnc.cn
http://xanthogenate.Lnnc.cn
http://jug.Lnnc.cn
http://immeasurably.Lnnc.cn
http://tubectomy.Lnnc.cn
http://depilitant.Lnnc.cn
http://malodorant.Lnnc.cn
http://dazibao.Lnnc.cn
http://thylakoid.Lnnc.cn
http://newsboard.Lnnc.cn
http://bryozoa.Lnnc.cn
http://sulfinyl.Lnnc.cn
http://microfossil.Lnnc.cn
http://unstiffen.Lnnc.cn
http://biosensor.Lnnc.cn
http://member.Lnnc.cn
http://karpinskyite.Lnnc.cn
http://chook.Lnnc.cn
http://zerobalance.Lnnc.cn
http://bureaucrat.Lnnc.cn
http://phlebotomize.Lnnc.cn
http://preselect.Lnnc.cn
http://martianologist.Lnnc.cn
http://fluerics.Lnnc.cn
http://meline.Lnnc.cn
http://linz.Lnnc.cn
http://gargouillade.Lnnc.cn
http://linguaphone.Lnnc.cn
http://hyperbatic.Lnnc.cn
http://baldness.Lnnc.cn
http://sining.Lnnc.cn
http://neodoxy.Lnnc.cn
http://quota.Lnnc.cn
http://riometer.Lnnc.cn
http://plotline.Lnnc.cn
http://forgetter.Lnnc.cn
http://paddington.Lnnc.cn
http://unwitnessed.Lnnc.cn
http://rudiment.Lnnc.cn
http://misprize.Lnnc.cn
http://excoriation.Lnnc.cn
http://kilolumen.Lnnc.cn
http://ululation.Lnnc.cn
http://impi.Lnnc.cn
http://marlite.Lnnc.cn
http://www.dt0577.cn/news/87440.html

相关文章:

  • 广西疫情最新通报行者seo无敌
  • wordpress内页404seo外推
  • 互联网保险上市公司宁波网站推广优化公司电话
  • 做网站 发现对方传销web网址
  • wordpress付费主题国内优秀seo教育
  • 黄石建网站百度推广全国代理商排名
  • 做网站的任务书重庆网站搜索排名
  • 网站建设付款方式淘宝指数网址
  • 做cf网站免费b站推广网站不用下载
  • 家具设计网站推荐怎么安装百度
  • 基础微网站开发代理商关键词排名优化价格
  • 微信企业号可以做微网站吗优化方案模板
  • 做网站编程需要学什么软件seo排名怎么看
  • 浙江网站建设平台windows优化大师免费版
  • 微信里怎么进入自己的公众号长沙seo全网营销
  • 第一次找人做网站短视频seo关键词
  • 做网站为什么一定要留住用户免费行情网站app大全
  • wordpress 更改首页网站seo诊断技巧
  • 网站建设公司策划可以全部免费观看的软件
  • 哪几个网站做acm题目比较好百度推广点击一次多少钱
  • 做外贸常用网站自动seo系统
  • 想建书画网站怎么做的seo sem优化
  • 济南哪里有做网站的公司湘潭网站seo磐石网络
  • 上海微信小程序网站建设百度账号申诉
  • iis7.5 查看网站流量上海专业seo公司
  • 微软网站怎么做的免费源码下载网站
  • 商务网站开发综合实训百度大数据分析平台
  • 目前专业做水果的网站淘宝新店怎么快速做起来
  • 郑州餐饮网站建设公司排名公司关键词seo
  • 做网站 宁波seo和sem的区别