feat: 修改Langfuse配置
All checks were successful
Egg Server MIflow / build-image (push) Successful in 49s
All checks were successful
Egg Server MIflow / build-image (push) Successful in 49s
This commit is contained in:
parent
c2088c586f
commit
c7adc6f76b
@ -32,9 +32,23 @@ const getDeepseekApiKey = async () => get("deepseek_api_key")
|
||||
*/
|
||||
const getOpenAIApiKey = async () => get("openai_api_key")
|
||||
|
||||
/**
|
||||
* 获取Langfuse的pk
|
||||
* @returns {string} pk
|
||||
*/
|
||||
const getLangfusePk = async () => get("langfuse_pk")
|
||||
|
||||
/**
|
||||
* 获取Langfuse的sk
|
||||
* @returns {string} sk
|
||||
*/
|
||||
const getLangfuseSk = async () => get("langfuse_sk")
|
||||
|
||||
const appConfig = {
|
||||
getOpenAIApiKey,
|
||||
getDeepseekApiKey,
|
||||
getLangfusePk,
|
||||
getLangfuseSk,
|
||||
}
|
||||
|
||||
export default appConfig
|
||||
|
13
test/llm.ts
Normal file
13
test/llm.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { Langfuse } from "langfuse-langchain"
|
||||
|
||||
const langfuseParams = {
|
||||
publicKey: "pk-lf-7328c2f1-595a-4023-994b-78762d3dde9e",
|
||||
secretKey: "sk-lf-bdf20cd5-ff2c-45c3-9021-8292dbb1bef3",
|
||||
baseUrl: "https://langfuse.yingbo.im:333",
|
||||
}
|
||||
|
||||
const langfuse = new Langfuse(langfuseParams)
|
||||
|
||||
const prompt = await langfuse.getPrompt("summary")
|
||||
|
||||
console.log(prompt)
|
23
utils/llm.ts
23
utils/llm.ts
@ -4,16 +4,22 @@ import { z } from "zod"
|
||||
|
||||
import db from "../db"
|
||||
|
||||
const langfuseParams = {
|
||||
publicKey: "pk-lf-7328c2f1-595a-4023-994b-78762d3dde9e",
|
||||
secretKey: "sk-lf-bdf20cd5-ff2c-45c3-9021-8292dbb1bef3",
|
||||
baseUrl: "https://langfuse.yingbo.im:333",
|
||||
/**
|
||||
* 获取Langfuse
|
||||
* @returns
|
||||
*/
|
||||
const getLangfuse = async () => {
|
||||
const langfuseParams = {
|
||||
publicKey: await db.appConfig.getLangfusePk(),
|
||||
secretKey: await db.appConfig.getLangfuseSk(),
|
||||
baseUrl: "https://langfuse.yingbo.im:333",
|
||||
}
|
||||
return {
|
||||
langfuseHandler: new CallbackHandler(langfuseParams),
|
||||
langfuse: new Langfuse(langfuseParams),
|
||||
}
|
||||
}
|
||||
|
||||
const langfuseHandler = new CallbackHandler(langfuseParams)
|
||||
|
||||
const langfuse = new Langfuse(langfuseParams)
|
||||
|
||||
/**
|
||||
* 获取Deepseek模型
|
||||
* @param temperature 温度
|
||||
@ -65,6 +71,7 @@ const invokeLLM4ChatHistory = async (
|
||||
promptType: LlmPromptType,
|
||||
chatHistory: string
|
||||
) => {
|
||||
const { langfuseHandler, langfuse } = await getLangfuse()
|
||||
const prompt = await langfuse.getPrompt(promptType)
|
||||
const compiled_prompt = prompt.compile({
|
||||
chatHistory,
|
||||
|
Loading…
x
Reference in New Issue
Block a user