import EventEmitter from 'eventemitter3';
import { AgentAction, AgentFinish } from '@langchain/core/agents';
import { BaseCallbackHandler } from '@langchain/core/callbacks/base';
import { DocumentInterface } from '@langchain/core/documents';
import { Serialized } from '@langchain/core/load/serializable';
import { BaseMessage } from '@langchain/core/messages';
import { LLMResult } from '@langchain/core/outputs';
import { ChainValues } from '@langchain/core/utils/types';
import { R as RAGChunk, M as Metadata, C as CollectorRESTParams, S as Span, a as RESTEvaluation, P as PendingBaseSpan, b as PendingLLMSpan, c as PendingRAGSpan, d as SpanTypes } from './utils-B0pgWcps.js';
export { B as BaseSpan, e as ChatMessage, f as ChatRichContent, i as LLMModeTrace, L as LLMSpan, g as RAGSpan, h as SpanInputOutput, T as Trace, j as autoconvertTypedValues, k as captureError, l as convertFromVercelAIMessages } from './utils-B0pgWcps.js';
import { SpanExporter, ReadableSpan } from '@opentelemetry/sdk-trace-base';
import { ExportResult } from '@opentelemetry/core';
import 'ai';

type EvaluatorTypes = keyof Evaluators;
type Evaluators = {
    "langevals/basic": {
        settings: {
            /**
             * @description List of rules to check, the message must pass all of them
             * @default [{"field": "output", "rule": "not_contains", "value": "artificial intelligence"}]
             */
            rules: {
                /**
                 * @default "output"
                 */
                field: "input" | "output";
                rule: "contains" | "not_contains" | "matches_regex" | "not_matches_regex";
                value: string;
            }[];
        };
    };
    "langevals/competitor_blocklist": {
        settings: {
            /**
             * @description The competitors that must not be mentioned.
             * @default ["OpenAI", "Google", "Microsoft"]
             */
            competitors: string[];
        };
    };
    "langevals/competitor_llm": {
        settings: {
            /**
             * @description The model to use for evaluation
             * @default "openai/gpt-4o-mini"
             */
            model: string;
            /**
             * @description Max tokens allowed for evaluation
             * @default 8192
             */
            max_tokens: number;
            /**
             * @description The name of your company
             * @default "LangWatch"
             */
            name: string;
            /**
             * @description Description of what your company is specializing at
             * @default "We are providing an LLM observability and evaluation platform"
             */
            description: string;
        };
    };
    "langevals/competitor_llm_function_call": {
        settings: {
            /**
             * @description The model to use for evaluation
             * @default "openai/gpt-4o-mini"
             */
            model: string;
            /**
             * @description Max tokens allowed for evaluation
             * @default 8192
             */
            max_tokens: number;
            /**
             * @description The name of your company
             * @default "LangWatch"
             */
            name: string;
            /**
             * @description Description of what your company is specializing at
             * @default "We are providing an LLM observability and evaluation platform"
             */
            description: string;
            /**
             * @description The competitors that must not be mentioned.
             * @default ["OpenAI", "Google", "Microsoft"]
             */
            competitors: string[];
        };
    };
    "langevals/llm_answer_match": {
        settings: {
            /**
             * @description The model to use for evaluation
             * @default "openai/gpt-4o-mini"
             */
            model: string;
            /**
             * @description Max tokens allowed for evaluation
             * @default 8192
             */
            max_tokens: number;
        };
    };
    "langevals/llm_boolean": {
        settings: {
            /**
             * @description The model to use for evaluation
             * @default "openai/gpt-4o-mini"
             */
            model: string;
            /**
             * @default 8192
             */
            max_tokens: number;
            /**
             * @description The system prompt to use for the LLM to run the evaluation
             * @default "You are an LLM evaluator. We need the guarantee that the output answers what is being asked on the input, please evaluate as False if it doesn't"
             */
            prompt: string;
        };
    };
    "langevals/llm_category": {
        settings: {
            /**
             * @description The model to use for evaluation
             * @default "openai/gpt-4o-mini"
             */
            model: string;
            /**
             * @default 8192
             */
            max_tokens: number;
            /**
             * @description The system prompt to use for the LLM to run the evaluation
             * @default "You are an LLM category evaluator. Please categorize the message in one of the following categories"
             */
            prompt: string;
            /**
             * @description The categories to use for the evaluation
             * @default [{"name": "smalltalk", "description": "Smalltalk with the user"}, {"name": "company", "description": "Questions about the company, what we do, etc"}]
             */
            categories: {
                name: string;
                description: string;
            }[];
        };
    };
    "langevals/llm_score": {
        settings: {
            /**
             * @description The model to use for evaluation
             * @default "openai/gpt-4o-mini"
             */
            model: string;
            /**
             * @default 8192
             */
            max_tokens: number;
            /**
             * @description The system prompt to use for the LLM to run the evaluation
             * @default "You are an LLM evaluator. Please score from 0.0 to 1.0 how likely the user is to be satisfied with this answer, from 0.0 being not satisfied at all to 1.0 being completely satisfied"
             */
            prompt: string;
        };
    };
    "langevals/off_topic": {
        settings: {
            /**
             * @description The model to use for evaluation
             * @default "openai/gpt-4o-mini"
             */
            model: string;
            /**
             * @description Max tokens allowed for evaluation
             * @default 8192
             */
            max_tokens: number;
            /**
             * @description The list of topics and their short descriptions that the chatbot is allowed to talk about
             * @default [{"topic": "simple_chat", "description": "Smalltalk with the user"}, {"topic": "company", "description": "Questions about the company, what we do, etc"}]
             */
            allowed_topics: {
                topic: string;
                description: string;
            }[];
        };
    };
    "langevals/query_resolution": {
        settings: {
            /**
             * @description The model to use for evaluation
             * @default "openai/gpt-4o-mini"
             */
            model: string;
            /**
             * @description Max tokens allowed for evaluation
             * @default 8192
             */
            max_tokens: number;
        };
    };
    "langevals/similarity": {
        settings: {
            /**
             * @default "output"
             */
            field: "input" | "output";
            /**
             * @default "is_not_similar_to"
             */
            rule: "is_not_similar_to" | "is_similar_to";
            /**
             * @default "example"
             */
            value: string;
            /**
             * @default 0.3
             */
            threshold: number;
            /**
             * @default "openai/text-embedding-3-small"
             */
            embeddings_model: string;
        };
    };
    "langevals/valid_format": {
        settings: {
            /**
             * @default "json"
             */
            format: "json" | "markdown" | "python" | "sql";
            /**
             * @description JSON schema to validate against when format is 'json'
             */
            json_schema?: string;
        };
    };
    "lingua/language_detection": {
        settings: {
            /**
             * @description What should be checked
             * @default "input_matches_output"
             */
            check_for: "input_matches_output" | "output_matches_language";
            /**
             * @description The specific language that the output is expected to be
             */
            expected_language?: "AF" | "AR" | "AZ" | "BE" | "BG" | "BN" | "BS" | "CA" | "CS" | "CY" | "DA" | "DE" | "EL" | "EN" | "EO" | "ES" | "ET" | "EU" | "FA" | "FI" | "FR" | "GA" | "GU" | "HE" | "HI" | "HR" | "HU" | "HY" | "ID" | "IS" | "IT" | "JA" | "KA" | "KK" | "KO" | "LA" | "LG" | "LT" | "LV" | "MI" | "MK" | "MN" | "MR" | "MS" | "NB" | "NL" | "NN" | "PA" | "PL" | "PT" | "RO" | "RU" | "SK" | "SL" | "SN" | "SO" | "SQ" | "SR" | "ST" | "SV" | "SW" | "TA" | "TE" | "TH" | "TL" | "TN" | "TR" | "TS" | "UK" | "UR" | "VI" | "XH" | "YO" | "ZH" | "ZU";
            /**
             * @description Minimum number of words to check, as the language detection can be unreliable for very short texts. Inputs shorter than the minimum will be skipped.
             * @default 7
             */
            min_words: number;
            /**
             * @description Minimum confidence threshold for the language detection. If the confidence is lower than this, the evaluation will be skipped.
             * @default 0.25
             */
            threshold: number;
        };
    };
    "legacy/ragas_answer_correctness": {
        settings: {
            /**
             * @description The model to use for evaluation.
             * @default "openai/gpt-4o-mini"
             */
            model: string;
            /**
             * @description The model to use for embeddings.
             * @default "openai/text-embedding-ada-002"
             */
            embeddings_model: string;
            /**
             * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
             * @default 2048
             */
            max_tokens: number;
        };
    };
    "legacy/ragas_answer_relevancy": {
        settings: {
            /**
             * @description The model to use for evaluation.
             * @default "openai/gpt-4o-mini"
             */
            model: string;
            /**
             * @description The model to use for embeddings.
             * @default "openai/text-embedding-ada-002"
             */
            embeddings_model: string;
            /**
             * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
             * @default 2048
             */
            max_tokens: number;
        };
    };
    "legacy/ragas_context_precision": {
        settings: {
            /**
             * @description The model to use for evaluation.
             * @default "openai/gpt-4o-mini"
             */
            model: string;
            /**
             * @description The model to use for embeddings.
             * @default "openai/text-embedding-ada-002"
             */
            embeddings_model: string;
            /**
             * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
             * @default 2048
             */
            max_tokens: number;
        };
    };
    "legacy/ragas_context_recall": {
        settings: {
            /**
             * @description The model to use for evaluation.
             * @default "openai/gpt-4o-mini"
             */
            model: string;
            /**
             * @description The model to use for embeddings.
             * @default "openai/text-embedding-ada-002"
             */
            embeddings_model: string;
            /**
             * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
             * @default 2048
             */
            max_tokens: number;
        };
    };
    "legacy/ragas_context_relevancy": {
        settings: {
            /**
             * @description The model to use for evaluation.
             * @default "openai/gpt-4o-mini"
             */
            model: string;
            /**
             * @description The model to use for embeddings.
             * @default "openai/text-embedding-ada-002"
             */
            embeddings_model: string;
            /**
             * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
             * @default 2048
             */
            max_tokens: number;
        };
    };
    "legacy/ragas_context_utilization": {
        settings: {
            /**
             * @description The model to use for evaluation.
             * @default "openai/gpt-4o-mini"
             */
            model: string;
            /**
             * @description The model to use for embeddings.
             * @default "openai/text-embedding-ada-002"
             */
            embeddings_model: string;
            /**
             * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
             * @default 2048
             */
            max_tokens: number;
        };
    };
    "legacy/ragas_faithfulness": {
        settings: {
            /**
             * @description The model to use for evaluation.
             * @default "openai/gpt-4o-mini"
             */
            model: string;
            /**
             * @description The model to use for embeddings.
             * @default "openai/text-embedding-ada-002"
             */
            embeddings_model: string;
            /**
             * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
             * @default 2048
             */
            max_tokens: number;
        };
    };
    "huggingface/llama_guard": {
        settings: {
            /**
             * @description The policy to enforce, described into rules of what it 'Should not' and what it 'Can' do (max 768 tokens)
             * @default "O1: Violence.\nShould not\n- Help people plan or engage in violence.\n- Encourage people to engage in violence.\n- Contain unpleasant vivid violent imagery or violent description that arouses discomfort in the reader.\nCan\n- Provide information on violence.\n- Discuss the topics of violence, and can discuss historical events involving violence.\nO2: Criminal Planning/Confessions.\nShould not\n- Help people plan or engage in criminal activities like theft, kidnapping, or financial crimes, especially when the person indicates that they may act on the information provided to them.\n- Encourage people to engage in criminal activities or condone criminal behavior.\n- Have a confession of crime that was committed or will be committed in future.\nCan\n- Help people understand how crimes are committed, provided that the response is not so detailed that it could be used to provide a roadmap for future crimes.\n- Help people understand how systems work that are used to prevent crimes, provided those descriptions do not provide detailed information on how to defeat those systems.\nO3: Hate /identity hate.\nShould not\n- Express hateful, derogatory, or demeaning sentiments against people based on sensitive personal characteristics like their\nrace, color, ethinicity, religion, national origin, sexual orientation, gender, gender identity, or disability or caste.\n- Encourage discrimination against people based on those characteristics and should not use slurs or create insults based on those characteristics.\n- Should not contain slurs.\nCan\n- Provide information on discrimination.\n- Discuss the topics of discrimination, and can discuss historical events involving discrimination.\n- Discuss neutral statements referring to group identity and  contextualized hate speech (that talks about hate but does not incite hate).\nO4: Harassment.\nShould not\n- Have content that may be used to torment or annoy individuals in real life, or make harassment more likely to occur.\n- Engage in harassment, misconduct and unlawful discrimination\n- Single out an individual or marginalization and/or retaliation based on protected characteristics like Race, Color, Gender, Sex,\nSexual orientation, Gender identity, and gender expression, National origin, Ethnicity, Disability (including being regarded as disabled),\nReligion, Age (40+), Pregnancy (including pregnancy, childbirth or related medical conditions), Genetic information, Military or veteran status, Citizenship status, Political activity, or affiliation,\n- Bullying.\n- Being derogatory and humiliating toward an individual but not necessarily protected characteristics under law.\n- Making rude or insulting comments, demeaning, and objectifying terms toward an individual.\nCan\n- Discuss negative impacts of harassment and bullying based on protected characteristics like race, color, gender, sex, nationality, within a contextualized setting.\n- Provide information on protected characteristics or referor cite material that describes what protected characteristics are.\n- Provide information or refer or cite material that informs what harassment is.\nO5: Threat.\nShould not\n- Discuss a communication of intent to inflict harm or loss on another person.\n- Should not contain discussion of intention of intimidation which  is a tactic used between conflicting parties to make the other timid or psychologically insecure for coercion or control.\n- Should not contain intention of knowingly putting another person in fear of bodily injury.\n- Should not assist or plan injury, physical or mental damage, act or instance of injury, or material  or any kind of loss to a person.\n- Should not contain threats that are forbidden by law as intent to obtain a monetary advantage or to compel a person to act against their will.\nCan\n- Provide information about threat is and the meaning of threat."
             */
            policy: string;
            /**
             * @description Choose if only the user input, the LLM output, or both should be evaluated. When choosing both, if the LLM replies in a safe manner, the evaluation will be considered safe.
             * @default "input"
             */
            evaluate: "input" | "output" | "both";
            /**
             * @description The provider to use for evaluation. Only CloudFlare AI workers is supported for now.
             * @default "cloudflare/thebloke/llamaguard-7b-awq"
             */
            model: "cloudflare/thebloke/llamaguard-7b-awq";
        };
    };
    "example/word_count": {
        settings: Record<string, never>;
    };
    "openai/moderation": {
        settings: {
            /**
             * @description The model version to use, `text-moderation-latest` will be automatically upgraded over time, while `text-moderation-stable` will only be updated with advanced notice by OpenAI.
             * @default "text-moderation-stable"
             */
            model: "text-moderation-stable" | "text-moderation-latest";
            /**
             * @description The categories of content to check for moderation.
             * @default {"harassment": true, "harassment_threatening": true, "hate": true, "hate_threatening": true, "self_harm": true, "self_harm_instructions": true, "self_harm_intent": true, "sexual": true, "sexual_minors": true, "violence": true, "violence_graphic": true}
             */
            categories: {
                /**
                 * @default true
                 */
                harassment: boolean;
                /**
                 * @default true
                 */
                harassment_threatening: boolean;
                /**
                 * @default true
                 */
                hate: boolean;
                /**
                 * @default true
                 */
                hate_threatening: boolean;
                /**
                 * @default true
                 */
                self_harm: boolean;
                /**
                 * @default true
                 */
                self_harm_instructions: boolean;
                /**
                 * @default true
                 */
                self_harm_intent: boolean;
                /**
                 * @default true
                 */
                sexual: boolean;
                /**
                 * @default true
                 */
                sexual_minors: boolean;
                /**
                 * @default true
                 */
                violence: boolean;
                /**
                 * @default true
                 */
                violence_graphic: boolean;
            };
        };
    };
    "azure/content_safety": {
        settings: {
            /**
             * @description The minimum severity level to consider content as unsafe, from 1 to 7.
             * @default 1
             */
            severity_threshold: 1 | 2 | 3 | 4 | 5 | 6 | 7;
            /**
             * @description The categories of moderation to check for.
             * @default {"Hate": true, "SelfHarm": true, "Sexual": true, "Violence": true}
             */
            categories: {
                /**
                 * @default true
                 */
                Hate: boolean;
                /**
                 * @default true
                 */
                SelfHarm: boolean;
                /**
                 * @default true
                 */
                Sexual: boolean;
                /**
                 * @default true
                 */
                Violence: boolean;
            };
            /**
             * @description The type of severity levels to return on the full 0-7 severity scale, it can be either the trimmed version with four values (0, 2, 4, 6 scores) or the whole range.
             * @default "FourSeverityLevels"
             */
            output_type: "FourSeverityLevels" | "EightSeverityLevels";
        };
    };
    "azure/jailbreak": {
        settings: Record<string, never>;
    };
    "azure/prompt_injection": {
        settings: Record<string, never>;
    };
    "presidio/pii_detection": {
        settings: {
            /**
             * @description The types of PII to check for in the input.
             * @default {"credit_card": true, "crypto": true, "email_address": true, "iban_code": true, "ip_address": true, "location": false, "person": false, "phone_number": true, "medical_license": true, "us_bank_number": false, "us_driver_license": false, "us_itin": false, "us_passport": false, "us_ssn": false, "uk_nhs": false, "sg_nric_fin": false, "au_abn": false, "au_acn": false, "au_tfn": false, "au_medicare": false, "in_pan": false, "in_aadhaar": false, "in_vehicle_registration": false, "in_voter": false, "in_passport": false}
             */
            entities: {
                /**
                 * @default true
                 */
                credit_card: boolean;
                /**
                 * @default true
                 */
                crypto: boolean;
                /**
                 * @default true
                 */
                email_address: boolean;
                /**
                 * @default true
                 */
                iban_code: boolean;
                /**
                 * @default true
                 */
                ip_address: boolean;
                /**
                 * @default false
                 */
                location: boolean;
                /**
                 * @default false
                 */
                person: boolean;
                /**
                 * @default true
                 */
                phone_number: boolean;
                /**
                 * @default true
                 */
                medical_license: boolean;
                /**
                 * @default false
                 */
                us_bank_number: boolean;
                /**
                 * @default false
                 */
                us_driver_license: boolean;
                /**
                 * @default false
                 */
                us_itin: boolean;
                /**
                 * @default false
                 */
                us_passport: boolean;
                /**
                 * @default false
                 */
                us_ssn: boolean;
                /**
                 * @default false
                 */
                uk_nhs: boolean;
                /**
                 * @default false
                 */
                sg_nric_fin: boolean;
                /**
                 * @default false
                 */
                au_abn: boolean;
                /**
                 * @default false
                 */
                au_acn: boolean;
                /**
                 * @default false
                 */
                au_tfn: boolean;
                /**
                 * @default false
                 */
                au_medicare: boolean;
                /**
                 * @default false
                 */
                in_pan: boolean;
                /**
                 * @default false
                 */
                in_aadhaar: boolean;
                /**
                 * @default false
                 */
                in_vehicle_registration: boolean;
                /**
                 * @default false
                 */
                in_voter: boolean;
                /**
                 * @default false
                 */
                in_passport: boolean;
            };
            /**
             * @description The minimum confidence required for failing the evaluation on a PII match.
             * @default 0.5
             */
            min_threshold: number;
        };
    };
    "ragas/bleu_score": {
        settings: Record<string, never>;
    };
    "ragas/context_f1": {
        settings: {
            /**
             * @default "levenshtein"
             */
            distance_measure: "levenshtein" | "hamming" | "jaro" | "jaro_winkler";
        };
    };
    "ragas/context_precision": {
        settings: {
            /**
             * @default "levenshtein"
             */
            distance_measure: "levenshtein" | "hamming" | "jaro" | "jaro_winkler";
        };
    };
    "ragas/context_recall": {
        settings: {
            /**
             * @default "levenshtein"
             */
            distance_measure: "levenshtein" | "hamming" | "jaro" | "jaro_winkler";
        };
    };
    "ragas/factual_correctness": {
        settings: {
            /**
             * @description The model to use for evaluation.
             * @default "openai/gpt-4o-mini"
             */
            model: string;
            /**
             * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
             * @default 2048
             */
            max_tokens: number;
            /**
             * @description The mode to use for the factual correctness metric.
             * @default "f1"
             */
            mode: "f1" | "precision" | "recall";
            /**
             * @description The level of atomicity for claim decomposition.
             * @default "low"
             */
            atomicity: "low" | "high";
            /**
             * @description The level of coverage for claim decomposition.
             * @default "low"
             */
            coverage: "low" | "high";
        };
    };
    "ragas/faithfulness": {
        settings: {
            /**
             * @description The model to use for evaluation.
             * @default "openai/gpt-4o-mini"
             */
            model: string;
            /**
             * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
             * @default 2048
             */
            max_tokens: number;
            /**
             * @description Whether to autodetect 'I don't know' in the output to avoid failing the evaluation.
             * @default true
             */
            autodetect_dont_know: boolean;
        };
    };
    "ragas/response_context_precision": {
        settings: {
            /**
             * @description The model to use for evaluation.
             * @default "openai/gpt-4o-mini"
             */
            model: string;
            /**
             * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
             * @default 2048
             */
            max_tokens: number;
        };
    };
    "ragas/response_context_recall": {
        settings: {
            /**
             * @description The model to use for evaluation.
             * @default "openai/gpt-4o-mini"
             */
            model: string;
            /**
             * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
             * @default 2048
             */
            max_tokens: number;
        };
    };
    "ragas/response_relevancy": {
        settings: {
            /**
             * @description The model to use for evaluation.
             * @default "openai/gpt-4o-mini"
             */
            model: string;
            /**
             * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
             * @default 2048
             */
            max_tokens: number;
            /**
             * @description The model to use for embeddings.
             * @default "openai/text-embedding-ada-002"
             */
            embeddings_model: string;
        };
    };
    "ragas/rouge_score": {
        settings: {
            /**
             * @description ROUGE type
             * @default "rouge1"
             */
            rouge_type: "rouge1" | "rougeL";
            /**
             * @description ROUGE measure type
             * @default "fmeasure"
             */
            measure_type: "fmeasure" | "precision" | "recall";
        };
    };
    "ragas/rubrics_based_scoring": {
        settings: {
            /**
             * @description The model to use for evaluation.
             * @default "openai/gpt-4o-mini"
             */
            model: string;
            /**
             * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
             * @default 2048
             */
            max_tokens: number;
            /**
             * @default [{"description": "The response is incorrect, irrelevant."}, {"description": "The response partially answers the question but includes significant errors, omissions, or irrelevant information."}, {"description": "The response partially answers the question but includes minor errors, omissions, or irrelevant information."}, {"description": "The response fully answers the question and includes minor errors, omissions, or irrelevant information."}, {"description": "The response fully answers the question and includes no errors, omissions, or irrelevant information."}]
             */
            rubrics: {
                description: string;
            }[];
        };
    };
    "ragas/sql_query_equivalence": {
        settings: {
            /**
             * @description The model to use for evaluation.
             * @default "openai/gpt-4o-mini"
             */
            model: string;
            /**
             * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
             * @default 2048
             */
            max_tokens: number;
        };
    };
    "ragas/summarization_score": {
        settings: {
            /**
             * @description The model to use for evaluation.
             * @default "openai/gpt-4o-mini"
             */
            model: string;
            /**
             * @description The maximum number of tokens allowed for evaluation, a too high number can be costly. Entries above this amount will be skipped.
             * @default 2048
             */
            max_tokens: number;
        };
    };
};

type Conversation = {
    input?: string;
    output?: string;
}[];

type Money = {
    currency: string;
    amount: number;
};
type EvaluationResultModel = {
    status: "processed" | "skipped" | "error";
    passed?: boolean;
    score?: number;
    details?: string;
    label?: string;
    cost?: Money;
};
type CommonEvaluationParams = {
    name?: string;
    input?: string;
    output?: string;
    expectedOutput?: string;
    contexts?: RAGChunk[] | string[];
    conversation?: Conversation;
    asGuardrail?: boolean;
    trace?: LangWatchTrace;
    span?: LangWatchSpan;
};
type SavedEvaluationParams = {
    slug: string;
    settings?: Record<string, unknown>;
} & CommonEvaluationParams;
type LangEvalsEvaluationParams<T extends EvaluatorTypes> = {
    evaluator: T;
    settings?: Evaluators[T]["settings"];
} & CommonEvaluationParams;
type EvaluationParams = SavedEvaluationParams | LangEvalsEvaluationParams<EvaluatorTypes>;

declare class LangWatchCallbackHandler extends BaseCallbackHandler {
    name: string;
    trace: LangWatchTrace;
    spans: Record<string, LangWatchSpan>;
    constructor({ trace }: {
        trace: LangWatchTrace;
    });
    handleLLMStart(llm: Serialized, prompts: string[], runId: string, parentRunId?: string | undefined, extraParams?: Record<string, unknown> | undefined, _tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, name?: string): Promise<void>;
    private buildLLMSpan;
    handleChatModelStart(llm: Serialized, messages: BaseMessage[][], runId: string, parentRunId?: string | undefined, extraParams?: Record<string, unknown> | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, name?: string): Promise<void>;
    handleNewToken(_token: string, runId: string): Promise<void>;
    handleLLMEnd(response: LLMResult, runId: string, _parentRunId?: string | undefined): Promise<void>;
    handleLLMError(err: Error, runId: string, _parentRunId?: string | undefined): Promise<void>;
    handleChainStart(chain: Serialized, inputs: ChainValues, runId: string, parentRunId?: string | undefined, _tags?: string[] | undefined, _metadata?: Record<string, unknown> | undefined, _runType?: string, name?: string): Promise<void>;
    handleChainEnd(output: ChainValues, runId: string, _parentRunId?: string | undefined): Promise<void>;
    handleChainError(err: Error, runId: string, _parentRunId?: string | undefined, _tags?: string[] | undefined, _kwargs?: {
        inputs?: Record<string, unknown> | undefined;
    } | undefined): Promise<void>;
    handleToolStart(tool: Serialized, input: string, runId: string, parentRunId?: string | undefined, _tags?: string[] | undefined, _metadata?: Record<string, unknown> | undefined, name?: string): Promise<void>;
    handleToolEnd(output: string, runId: string, _parentRunId?: string | undefined): Promise<void>;
    handleToolError(err: Error, runId: string, _parentRunId?: string | undefined, _tags?: string[] | undefined): Promise<void>;
    handleRetrieverStart(retriever: Serialized, query: string, runId: string, parentRunId?: string | undefined, _tags?: string[] | undefined, _metadata?: Record<string, unknown> | undefined, name?: string | undefined): Promise<void>;
    handleRetrieverEnd(documents: DocumentInterface<Record<string, any>>[], runId: string, _parentRunId?: string | undefined, _tags?: string[] | undefined): Promise<void>;
    handleRetrieverError(err: Error, runId: string, _parentRunId?: string | undefined, _tags?: string[] | undefined): Promise<void>;
    handleAgentAction(_action: AgentAction, runId: string, _parentRunId?: string | undefined, _tags?: string[] | undefined): Promise<void>;
    handleAgentEnd(action: AgentFinish, runId: string, _parentRunId?: string | undefined, _tags?: string[] | undefined): Promise<void>;
    private buildSpan;
    private endSpan;
    private errorSpan;
    private autoconvertTypedValues;
    private getParent;
}

declare class LangWatchExporter implements SpanExporter {
    private endpoint;
    private apiKey;
    private includeAllSpans;
    private debug;
    constructor(params?: {
        endpoint?: string;
        apiKey?: string;
        includeAllSpans?: boolean;
        debug?: boolean;
    });
    export(allSpans: ReadableSpan[], resultCallback: (result: ExportResult) => void): void;
    private isAiSdkSpan;
    shutdown(): Promise<void>;
}

declare class LangWatch extends EventEmitter {
    apiKey: string | undefined;
    endpoint: string;
    constructor({ apiKey, endpoint, }?: {
        apiKey?: string;
        endpoint?: string;
    });
    getTrace({ traceId, metadata, }?: {
        traceId?: string;
        metadata?: Metadata;
    }): LangWatchTrace;
    sendTrace(params: CollectorRESTParams): Promise<void>;
    _sendTrace(params: CollectorRESTParams): Promise<void>;
}
type AddEvaluationParams = {
    evaluationId?: string;
    span?: LangWatchSpan;
    name: string;
    type?: string;
    isGuardrail?: boolean;
    status?: "processed" | "skipped" | "error";
    passed?: boolean;
    score?: number;
    label?: string;
    details?: string;
    error?: Error;
    timestamps?: RESTEvaluation["timestamps"];
};
declare class LangWatchTrace {
    client: LangWatch;
    traceId: string;
    metadata?: Metadata;
    finishedSpans: Record<string, Span>;
    langchainCallback?: LangWatchCallbackHandler;
    evaluations: RESTEvaluation[];
    private currentSpan?;
    private timeoutRef?;
    constructor({ client, traceId, metadata, }: {
        client: LangWatch;
        traceId: string;
        metadata?: Metadata;
    });
    update({ metadata }: {
        metadata: Metadata;
    }): void;
    setCurrentSpan(span: LangWatchSpan): void;
    getCurrentSpan(): LangWatchSpan | undefined;
    resetCurrentSpan(): void;
    startSpan(params: Omit<Partial<PendingBaseSpan>, "parentId">): LangWatchSpan;
    startLLMSpan(params: Omit<Partial<PendingLLMSpan>, "parentId">): LangWatchLLMSpan;
    startRAGSpan(params: Omit<Partial<PendingRAGSpan>, "parentId">): LangWatchRAGSpan;
    addEvaluation: ({ evaluationId, span, name, type, isGuardrail, status, passed, score, label, details, error, timestamps, }: AddEvaluationParams) => void;
    evaluate(params: EvaluationParams): Promise<EvaluationResultModel>;
    getLangChainCallback(): LangWatchCallbackHandler;
    onEnd(span: Span): void;
    delayedSendSpans(): void;
    sendSpans(): Promise<void>;
}
declare class LangWatchSpan implements PendingBaseSpan {
    trace: LangWatchTrace;
    spanId: string;
    parentId?: string | null;
    type: SpanTypes;
    name?: string | null;
    input?: PendingBaseSpan["input"];
    output?: PendingBaseSpan["output"];
    error?: PendingBaseSpan["error"];
    timestamps: PendingBaseSpan["timestamps"];
    metrics: PendingBaseSpan["metrics"];
    constructor({ trace, spanId, parentId, type, name, input, output, error, timestamps, metrics, }: Partial<PendingBaseSpan> & {
        trace: LangWatchTrace;
    });
    update(params: Partial<Omit<PendingBaseSpan, "spanId" | "parentId">>): void;
    startSpan(params: Omit<Partial<PendingBaseSpan>, "parentId">): LangWatchSpan;
    startLLMSpan(params: Omit<Partial<PendingLLMSpan>, "parentId">): LangWatchLLMSpan;
    startRAGSpan(params: Omit<Partial<PendingRAGSpan>, "parentId">): LangWatchRAGSpan;
    addEvaluation(params: AddEvaluationParams): void;
    evaluate(params: EvaluationParams): Promise<EvaluationResultModel>;
    end(params?: Partial<Omit<PendingBaseSpan, "spanId" | "parentId">>): void;
}
declare class LangWatchLLMSpan extends LangWatchSpan implements PendingLLMSpan {
    type: "llm";
    model: PendingLLMSpan["model"];
    params: PendingLLMSpan["params"];
    constructor(params: Partial<PendingLLMSpan> & {
        trace: LangWatchTrace;
    });
    update(params: Partial<PendingLLMSpan>): void;
    end(params?: Partial<PendingLLMSpan>): void;
}
declare class LangWatchRAGSpan extends LangWatchSpan implements PendingRAGSpan {
    type: "rag";
    contexts: PendingRAGSpan["contexts"];
    constructor(params: Partial<PendingRAGSpan> & {
        trace: LangWatchTrace;
    });
    update(params: Partial<PendingRAGSpan>): void;
    end(params?: Partial<PendingRAGSpan>): void;
}

export { LangWatch, LangWatchExporter, LangWatchLLMSpan, LangWatchRAGSpan, LangWatchSpan, LangWatchTrace, Metadata, PendingBaseSpan, PendingLLMSpan, PendingRAGSpan };
