UNPKG

@langchain/community

Version:
1 lines • 6.69 kB
{"version":3,"file":"base.d.ts","names":["BaseChatModel","BaseChatModelParams","BaseMessage","ChatResult","ChatGenerationChunk","CallbackManagerForLLMRun","sign","HunyuanMessageRole","HunyuanMessage","ModelName","NonNullable","ChatCompletionRequest","TencentHunyuanChatInput","TencentHunyuanChatInputWithSign","ChatTencentHunyuan","Partial","Omit","HeadersInit","AsyncGenerator","Promise","AbortSignal"],"sources":["../../../src/chat_models/tencent_hunyuan/base.d.ts"],"sourcesContent":["import { BaseChatModel, type BaseChatModelParams } from \"@langchain/core/language_models/chat_models\";\nimport { BaseMessage } from \"@langchain/core/messages\";\nimport { ChatResult, ChatGenerationChunk } from \"@langchain/core/outputs\";\nimport { CallbackManagerForLLMRun } from \"@langchain/core/callbacks/manager\";\nimport { sign } from \"../../utils/tencent_hunyuan/common.js\";\n/**\n * Type representing the role of a message in the Hunyuan chat model.\n */\nexport type HunyuanMessageRole = \"system\" | \"assistant\" | \"user\";\n/**\n * Interface representing a message in the Hunyuan chat model.\n */\ninterface HunyuanMessage {\n Role: HunyuanMessageRole;\n Content: string;\n}\n/**\n * Models available, see https://cloud.tencent.com/document/product/1729/104753.\n */\ntype ModelName = (string & NonNullable<unknown>) | \"hunyuan-lite\" | \"hunyuan-standard\" | \"hunyuan-standard-32K\" | \"hunyuan-standard-256K\" | \"hunyuan-pro\";\n/**\n * Interface representing a request for a chat completion.\n * See https://cloud.tencent.com/document/api/1729/105701.\n */\ninterface ChatCompletionRequest {\n Model: ModelName;\n Messages: HunyuanMessage[];\n Stream?: boolean;\n StreamModeration?: boolean;\n EnableEnhancement?: boolean;\n Temperature?: number;\n TopP?: number;\n}\n/**\n * Interface defining the input to the ChatTencentHunyuan class.\n */\nexport interface TencentHunyuanChatInput {\n /**\n * Tencent Cloud API Host.\n * @default \"hunyuan.tencentcloudapi.com\"\n */\n host?: string;\n /**\n * Model name to use.\n * @default \"hunyuan-pro\"\n */\n model: ModelName;\n /**\n * Whether to stream the results or not. Defaults to false.\n * @default false\n */\n streaming?: boolean;\n /**\n * SecretID to use when making requests, can be obtained from https://console.cloud.tencent.com/cam/capi.\n * Defaults to the value of `TENCENT_SECRET_ID` environment variable.\n */\n tencentSecretId?: string;\n /**\n * Secret key to use when making requests, can be obtained from https://console.cloud.tencent.com/cam/capi.\n * Defaults to the value of `TENCENT_SECRET_KEY` environment variable.\n */\n tencentSecretKey?: string;\n /**\n * Amount of randomness injected into the response. Ranges\n * from 0.0 to 2.0. Use temp closer to 0 for analytical /\n * multiple choice, and temp closer to 1 for creative\n * and generative tasks. Defaults to 1.0.95.\n */\n temperature?: number;\n /**\n * Total probability mass of tokens to consider at each step. Range\n * from 0 to 1.0. Defaults to 1.0.\n */\n topP?: number;\n}\n/**\n * Interface defining the input to the ChatTencentHunyuan class.\n */\ninterface TencentHunyuanChatInputWithSign extends TencentHunyuanChatInput {\n /**\n * Tencent Cloud API v3 sign method.\n */\n sign: sign;\n}\n/**\n * Wrapper around Tencent Hunyuan large language models that use the Chat endpoint.\n *\n * To use you should have the `TENCENT_SECRET_ID` and `TENCENT_SECRET_KEY`\n * environment variable set.\n *\n * @augments BaseLLM\n * @augments TencentHunyuanInput\n * @example\n * ```typescript\n * const messages = [new HumanMessage(\"Hello\")];\n *\n * const hunyuanLite = new ChatTencentHunyuan({\n * model: \"hunyuan-lite\",\n * tencentSecretId: \"YOUR-SECRET-ID\",\n * tencentSecretKey: \"YOUR-SECRET-KEY\",\n * });\n *\n * let res = await hunyuanLite.call(messages);\n *\n * const hunyuanPro = new ChatTencentHunyuan({\n * model: \"hunyuan-pro\",\n * temperature: 1,\n * tencentSecretId: \"YOUR-SECRET-ID\",\n * tencentSecretKey: \"YOUR-SECRET-KEY\",\n * });\n *\n * res = await hunyuanPro.call(messages);\n * ```\n */\nexport declare class ChatTencentHunyuan extends BaseChatModel implements TencentHunyuanChatInputWithSign {\n static lc_name(): string;\n get callKeys(): string[];\n get lc_secrets(): {\n [key: string]: string;\n } | undefined;\n get lc_aliases(): {\n [key: string]: string;\n } | undefined;\n lc_serializable: boolean;\n tencentSecretId?: string;\n tencentSecretKey?: string;\n streaming: boolean;\n host: string;\n model: string;\n temperature?: number | undefined;\n topP?: number | undefined;\n sign: sign;\n constructor(fields?: Partial<TencentHunyuanChatInputWithSign> & BaseChatModelParams);\n /**\n * Get the parameters used to invoke the model\n */\n invocationParams(): Omit<ChatCompletionRequest, \"Messages\">;\n /**\n * Get the HTTP headers used to invoke the model\n */\n invocationHeaders(request: object, timestamp: number): HeadersInit;\n _streamResponseChunks(messages: BaseMessage[], options: this[\"ParsedCallOptions\"], runManager?: CallbackManagerForLLMRun): AsyncGenerator<ChatGenerationChunk>;\n private createStream;\n /** @ignore */\n _generate(messages: BaseMessage[], options?: this[\"ParsedCallOptions\"], runManager?: CallbackManagerForLLMRun): Promise<ChatResult>;\n /** @ignore */\n completionWithRetry(request: ChatCompletionRequest, signal?: AbortSignal): Promise<any>;\n _llmType(): string;\n /** @ignore */\n _combineLLMOutput(): never[];\n}\nexport {};\n//# sourceMappingURL=base.d.ts.map"],"mappings":";;;;;;;;;;AAQA;AAIUQ,KAJED,kBAAAA,GAIY,QACdA,GAAAA,WAAkB,GAAA,MAAA;AAAA;AAMU;AAiBtC;AAsCC,UA9DSC,cAAAA,CAkEAK;EAoCWC,IAAAA,EArGXP,kBAqG6B;EAiB7BD,OAAAA,EAAAA,MAAAA;;;;;KAhHLG,SAAAA,GAqHmBO,CAAAA,MAAAA,GArHGN,WAqHHM,CAAAA,OAAAA,CAAAA,CAAAA,GAAAA,cAAAA,GAAAA,kBAAAA,GAAAA,sBAAAA,GAAAA,uBAAAA,GAAAA,aAAAA;;;;;UAhHdL,qBAAAA,CAqHqHO;EAGvGhB,KAAAA,EAvHbO,SAuHaP;EAAiEG,QAAAA,EAtH3EG,cAsH2EH,EAAAA;EAAmCF,MAAAA,CAAAA,EAAAA,OAAAA;EAARgB,gBAAAA,CAAAA,EAAAA,OAAAA;EAEnFR,iBAAAA,CAAAA,EAAAA,OAAAA;EAAgCS,WAAAA,CAAAA,EAAAA,MAAAA;EAAcD,IAAAA,CAAAA,EAAAA,MAAAA;;;AAhCyB;;UA9EvFP,uBAAAA;;;;;;;;;;SAUNH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAgCDI,+BAAAA,SAAwCD;;;;QAIxCN;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAgCWQ,kBAAAA,SAA2Bd,aAAAA,YAAyBa;;;;;;;;;;;;;;;;;QAiB/DP;uBACeS,QAAQF,mCAAmCZ;;;;sBAI5Ce,KAAKL;;;;yDAI8BM;kCACvBf,gEAAgEG,2BAA2Ba,eAAed;;;sBAGtHF,iEAAiEG,2BAA2Bc,QAAQhB;;+BAE3FQ,gCAAgCS,cAAcD"}