• EnglishEspañol日本語한국어Português
  • 로그인지금 시작하기

사용자의 편의를 위해 제공되는 기계 번역입니다.

In the event of any inconsistency between the English version and the translated version, the English versionwill take priority. Please visit this page for more information.

문제 신고

SetLlmTokenCountingCallback(.NET 에이전트 API)

통사론

NewRelic.Api.Agent.NewRelic.SetLlmTokenCountingCallback(Func<string, string, int> callback);

토큰 수를 계산하는 콜백 메서드를 제공합니다.

요구 사항

이 API 호출은 다음과 호환됩니다.

  • 에이전트 버전 >= 10.23.0
  • 모든 앱 유형

설명

에이전트가 LLM 이벤트의 토큰 수를 결정하는 데 사용할 콜백 방법을 설정합니다. 높은 보안 모드에서 또는 콘텐츠 기록이 비활성화된 경우 LLM 이벤트에 대한 토큰 수를 결정하기 위해 이 메서드가 호출됩니다.

콜백 메서드는 string 유형의 두 인수를 허용하고 정수를 반환해야 합니다. 첫 번째 문자열 인수는 LLM 모델 이름이고 두 번째 문자열 인수는 LLM에 대한 입력입니다. 콜백 메소드는 LLM 이벤트에 대한 토큰 수를 반환해야 합니다. 0 이하의 값은 무시됩니다.

매개변수

매개변수

설명

$callback

'_Func<string, string, int>_'

토큰 수를 결정하는 콜백입니다.

예시

Func<string, string, int> llmTokenCountingCallback = (modelName, modelInput) => {
int tokenCount = 0;
// split the input string by spaces and count the tokens
if (!string.IsNullOrEmpty(modelInput))
{
tokenCount = modelInput.Split(' ').Length;
}
return tokenCount;
};
NewRelic.Api.Agent.NewRelic.SetLlmTokenCountingCallback(llmTokenCountingCallback);
Copyright © 2024 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.