langchain 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/load/import_map.cjs +2 -1
- package/dist/load/import_map.d.ts +1 -0
- package/dist/load/import_map.js +1 -0
- package/dist/smith/config.cjs +2 -0
- package/dist/smith/config.d.ts +166 -0
- package/dist/smith/config.js +1 -0
- package/dist/smith/index.cjs +5 -0
- package/dist/smith/index.d.ts +3 -0
- package/dist/smith/index.js +2 -0
- package/dist/smith/name_generation.cjs +726 -0
- package/dist/smith/name_generation.d.ts +1 -0
- package/dist/smith/name_generation.js +722 -0
- package/dist/smith/progress.cjs +69 -0
- package/dist/smith/progress.d.ts +22 -0
- package/dist/smith/progress.js +65 -0
- package/dist/smith/runner_utils.cjs +353 -0
- package/dist/smith/runner_utils.d.ts +77 -0
- package/dist/smith/runner_utils.js +349 -0
- package/package.json +11 -3
- package/smith.cjs +1 -0
- package/smith.d.ts +1 -0
- package/smith.js +1 -0
package/dist/load/import_map.cjs
CHANGED
|
@@ -25,7 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
};
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
27
|
exports.util__document = exports.storage__in_memory = exports.storage__encoder_backed = exports.stores__message__in_memory = exports.stores__file__in_memory = exports.stores__doc__in_memory = exports.retrievers__vespa = exports.retrievers__score_threshold = exports.retrievers__hyde = exports.retrievers__document_compressors__embeddings_filter = exports.retrievers__document_compressors__chain_extract = exports.retrievers__time_weighted = exports.retrievers__parent_document = exports.retrievers__multi_vector = exports.retrievers__multi_query = exports.retrievers__document_compressors = exports.retrievers__contextual_compression = exports.retrievers__remote = exports.output_parsers = exports.schema__query_constructor = exports.schema__prompt_template = exports.chat_models__anthropic = exports.document_transformers__openai_functions = exports.document_loaders__web__sort_xyz_blockchain = exports.document_loaders__web__serpapi = exports.document_loaders__web__searchapi = exports.document_loaders__base = exports.text_splitter = exports.vectorstores__memory = exports.llms__fake = exports.embeddings__fake = exports.embeddings__cache_backed = exports.chains__retrieval = exports.chains__openai_functions = exports.chains__history_aware_retriever = exports.chains__combine_documents__reduce = exports.chains__combine_documents = exports.chains = exports.tools__retriever = exports.tools__render = exports.agents__openai__output_parser = exports.agents__xml__output_parser = exports.agents__react__output_parser = exports.agents__format_scratchpad__log_to_message = exports.agents__format_scratchpad__xml = exports.agents__format_scratchpad__log = exports.agents__format_scratchpad__openai_tools = exports.agents__format_scratchpad = exports.agents__toolkits = exports.agents = void 0;
|
|
28
|
-
exports.llms__fireworks = exports.chat_models__fireworks = exports.schema__output = exports.schema__output_parser = exports.schema__runnable = exports.prompts__base = exports.prompts__pipeline = exports.prompts__chat = exports.schema__messages = exports.prompts__prompt = exports.embeddings__openai = exports.llms__openai = exports.chat_models__openai = exports.runnables__remote = exports.evaluation = exports.experimental__prompts__custom_format = exports.experimental__masking = exports.experimental__chains__violation_of_expectations = exports.experimental__chat_models__bittensor = exports.experimental__plan_and_execute = exports.experimental__generative_agents = exports.experimental__babyagi = exports.experimental__openai_files = exports.experimental__openai_assistant = exports.experimental__autogpt = exports.util__time = exports.util__math = void 0;
|
|
28
|
+
exports.llms__fireworks = exports.chat_models__fireworks = exports.schema__output = exports.schema__output_parser = exports.schema__runnable = exports.prompts__base = exports.prompts__pipeline = exports.prompts__chat = exports.schema__messages = exports.prompts__prompt = exports.embeddings__openai = exports.llms__openai = exports.chat_models__openai = exports.runnables__remote = exports.smith = exports.evaluation = exports.experimental__prompts__custom_format = exports.experimental__masking = exports.experimental__chains__violation_of_expectations = exports.experimental__chat_models__bittensor = exports.experimental__plan_and_execute = exports.experimental__generative_agents = exports.experimental__babyagi = exports.experimental__openai_files = exports.experimental__openai_assistant = exports.experimental__autogpt = exports.util__time = exports.util__math = void 0;
|
|
29
29
|
exports.agents = __importStar(require("../agents/index.cjs"));
|
|
30
30
|
exports.agents__toolkits = __importStar(require("../agents/toolkits/index.cjs"));
|
|
31
31
|
exports.agents__format_scratchpad = __importStar(require("../agents/format_scratchpad/openai_functions.cjs"));
|
|
@@ -89,6 +89,7 @@ exports.experimental__chains__violation_of_expectations = __importStar(require("
|
|
|
89
89
|
exports.experimental__masking = __importStar(require("../experimental/masking/index.cjs"));
|
|
90
90
|
exports.experimental__prompts__custom_format = __importStar(require("../experimental/prompts/custom_format.cjs"));
|
|
91
91
|
exports.evaluation = __importStar(require("../evaluation/index.cjs"));
|
|
92
|
+
exports.smith = __importStar(require("../smith/index.cjs"));
|
|
92
93
|
exports.runnables__remote = __importStar(require("../runnables/remote.cjs"));
|
|
93
94
|
const openai_1 = require("@langchain/openai");
|
|
94
95
|
const prompts_1 = require("@langchain/core/prompts");
|
|
@@ -61,6 +61,7 @@ export * as experimental__chains__violation_of_expectations from "../experimenta
|
|
|
61
61
|
export * as experimental__masking from "../experimental/masking/index.js";
|
|
62
62
|
export * as experimental__prompts__custom_format from "../experimental/prompts/custom_format.js";
|
|
63
63
|
export * as evaluation from "../evaluation/index.js";
|
|
64
|
+
export * as smith from "../smith/index.js";
|
|
64
65
|
export * as runnables__remote from "../runnables/remote.js";
|
|
65
66
|
import { ChatOpenAI, OpenAI, OpenAIEmbeddings } from "@langchain/openai";
|
|
66
67
|
import { PromptTemplate, AIMessagePromptTemplate, ChatMessagePromptTemplate, ChatPromptTemplate, HumanMessagePromptTemplate, MessagesPlaceholder, SystemMessagePromptTemplate, PipelinePromptTemplate } from "@langchain/core/prompts";
|
package/dist/load/import_map.js
CHANGED
|
@@ -62,6 +62,7 @@ export * as experimental__chains__violation_of_expectations from "../experimenta
|
|
|
62
62
|
export * as experimental__masking from "../experimental/masking/index.js";
|
|
63
63
|
export * as experimental__prompts__custom_format from "../experimental/prompts/custom_format.js";
|
|
64
64
|
export * as evaluation from "../evaluation/index.js";
|
|
65
|
+
export * as smith from "../smith/index.js";
|
|
65
66
|
export * as runnables__remote from "../runnables/remote.js";
|
|
66
67
|
import { ChatOpenAI, OpenAI, OpenAIEmbeddings } from "@langchain/openai";
|
|
67
68
|
import { PromptTemplate, AIMessagePromptTemplate, ChatMessagePromptTemplate, ChatPromptTemplate, HumanMessagePromptTemplate, MessagesPlaceholder, SystemMessagePromptTemplate, PipelinePromptTemplate } from "@langchain/core/prompts";
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { BaseLanguageModel } from "@langchain/core/language_models/base";
|
|
2
|
+
import { Example, Run } from "langsmith";
|
|
3
|
+
import { EvaluationResult, RunEvaluator } from "langsmith/evaluation";
|
|
4
|
+
import { Criteria } from "../evaluation/index.js";
|
|
5
|
+
import { LoadEvaluatorOptions } from "../evaluation/loader.js";
|
|
6
|
+
import { EvaluatorType } from "../evaluation/types.js";
|
|
7
|
+
export type EvaluatorInputs = {
|
|
8
|
+
input?: string | unknown;
|
|
9
|
+
prediction: string | unknown;
|
|
10
|
+
reference?: string | unknown;
|
|
11
|
+
};
|
|
12
|
+
export type EvaluatorInputFormatter = ({ rawInput, rawPrediction, rawReferenceOutput, run, }: {
|
|
13
|
+
rawInput: any;
|
|
14
|
+
rawPrediction: any;
|
|
15
|
+
rawReferenceOutput?: any;
|
|
16
|
+
run: Run;
|
|
17
|
+
}) => EvaluatorInputs;
|
|
18
|
+
/**
|
|
19
|
+
* Type of a function that can be coerced into a RunEvaluator function.
|
|
20
|
+
* While we have the class-based RunEvaluator, it's often more convenient to directly
|
|
21
|
+
* pass a function to the runner. This type allows us to do that.
|
|
22
|
+
*/
|
|
23
|
+
export type RunEvaluatorLike = (({ run, example, }: {
|
|
24
|
+
run: Run;
|
|
25
|
+
example?: Example;
|
|
26
|
+
}) => Promise<EvaluationResult>) | (({ run, example }: {
|
|
27
|
+
run: Run;
|
|
28
|
+
example?: Example;
|
|
29
|
+
}) => EvaluationResult);
|
|
30
|
+
/**
|
|
31
|
+
* Configuration class for running evaluations on datasets.
|
|
32
|
+
*
|
|
33
|
+
* @remarks
|
|
34
|
+
* RunEvalConfig in LangSmith is a configuration class for running evaluations on datasets. Its primary purpose is to define the parameters and evaluators that will be applied during the evaluation of a dataset. This configuration can include various evaluators, custom evaluators, and different keys for inputs, predictions, and references.
|
|
35
|
+
*
|
|
36
|
+
* @typeparam T - The type of evaluators.
|
|
37
|
+
* @typeparam U - The type of custom evaluators.
|
|
38
|
+
*/
|
|
39
|
+
export type RunEvalConfig<T extends keyof EvaluatorType = keyof EvaluatorType, U extends RunEvaluator | RunEvaluatorLike = RunEvaluator | RunEvaluatorLike> = {
|
|
40
|
+
/**
|
|
41
|
+
* Custom evaluators to apply to a dataset run.
|
|
42
|
+
* Each evaluator is provided with a run trace containing the model
|
|
43
|
+
* outputs, as well as an "example" object representing a record
|
|
44
|
+
* in the dataset.
|
|
45
|
+
*/
|
|
46
|
+
customEvaluators?: U[];
|
|
47
|
+
/**
|
|
48
|
+
* LangChain evaluators to apply to a dataset run.
|
|
49
|
+
* You can optionally specify these by name, or by
|
|
50
|
+
* configuring them with an EvalConfig object.
|
|
51
|
+
*/
|
|
52
|
+
evaluators?: (T | EvalConfig)[];
|
|
53
|
+
/**
|
|
54
|
+
* Convert the evaluation data into a format that can be used by the evaluator.
|
|
55
|
+
* By default, we pass the first value of the run.inputs, run.outputs (predictions),
|
|
56
|
+
* and references (example.outputs)
|
|
57
|
+
*
|
|
58
|
+
* @returns The prepared data.
|
|
59
|
+
*/
|
|
60
|
+
formatEvaluatorInputs?: EvaluatorInputFormatter;
|
|
61
|
+
/**
|
|
62
|
+
* The language model specification for evaluators that require one.
|
|
63
|
+
*/
|
|
64
|
+
evalLlm?: string;
|
|
65
|
+
};
|
|
66
|
+
export interface EvalConfig extends LoadEvaluatorOptions {
|
|
67
|
+
/**
|
|
68
|
+
* The name of the evaluator to use.
|
|
69
|
+
* Example: labeled_criteria, criteria, etc.
|
|
70
|
+
*/
|
|
71
|
+
evaluatorType: keyof EvaluatorType;
|
|
72
|
+
/**
|
|
73
|
+
* The feedback (or metric) name to use for the logged
|
|
74
|
+
* evaluation results. If none provided, we default to
|
|
75
|
+
* the evaluationName.
|
|
76
|
+
*/
|
|
77
|
+
feedbackKey?: string;
|
|
78
|
+
/**
|
|
79
|
+
* Convert the evaluation data into a format that can be used by the evaluator.
|
|
80
|
+
* @param data The data to prepare.
|
|
81
|
+
* @returns The prepared data.
|
|
82
|
+
*/
|
|
83
|
+
formatEvaluatorInputs: EvaluatorInputFormatter;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Configuration to load a "CriteriaEvalChain" evaluator,
|
|
87
|
+
* which prompts an LLM to determine whether the model's
|
|
88
|
+
* prediction complies with the provided criteria.
|
|
89
|
+
* @param criteria - The criteria to use for the evaluator.
|
|
90
|
+
* @param llm - The language model to use for the evaluator.
|
|
91
|
+
* @returns The configuration for the evaluator.
|
|
92
|
+
* @example
|
|
93
|
+
* ```ts
|
|
94
|
+
* const evalConfig = new RunEvalConfig(
|
|
95
|
+
* [new RunEvalConfig.Criteria("helpfulness")],
|
|
96
|
+
* );
|
|
97
|
+
* ```
|
|
98
|
+
* @example
|
|
99
|
+
* ```ts
|
|
100
|
+
* const evalConfig = new RunEvalConfig(
|
|
101
|
+
* [new RunEvalConfig.Criteria(
|
|
102
|
+
* { "isCompliant": "Does the submission comply with the requirements of XYZ"
|
|
103
|
+
* })],
|
|
104
|
+
*/
|
|
105
|
+
export type CriteriaEvalChainConfig = EvalConfig & {
|
|
106
|
+
evaluatorType: "criteria";
|
|
107
|
+
/**
|
|
108
|
+
* The "criteria" to insert into the prompt template
|
|
109
|
+
* used for evaluation. See the prompt at
|
|
110
|
+
* https://smith.langchain.com/hub/langchain-ai/criteria-evaluator
|
|
111
|
+
* for more information.
|
|
112
|
+
*/
|
|
113
|
+
criteria?: Criteria | Record<string, string>;
|
|
114
|
+
/**
|
|
115
|
+
* The feedback (or metric) name to use for the logged
|
|
116
|
+
* evaluation results. If none provided, we default to
|
|
117
|
+
* the evaluationName.
|
|
118
|
+
*/
|
|
119
|
+
feedbackKey?: string;
|
|
120
|
+
/**
|
|
121
|
+
* The language model to use as the evaluator.
|
|
122
|
+
*/
|
|
123
|
+
llm?: BaseLanguageModel;
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* Configuration to load a "LabeledCriteriaEvalChain" evaluator,
|
|
127
|
+
* which prompts an LLM to determine whether the model's
|
|
128
|
+
* prediction complies with the provided criteria and also
|
|
129
|
+
* provides a "ground truth" label for the evaluator to incorporate
|
|
130
|
+
* in its evaluation.
|
|
131
|
+
* @param criteria - The criteria to use for the evaluator.
|
|
132
|
+
* @param llm - The language model to use for the evaluator.
|
|
133
|
+
* @returns The configuration for the evaluator.
|
|
134
|
+
* @example
|
|
135
|
+
* ```ts
|
|
136
|
+
* const evalConfig = new RunEvalConfig(
|
|
137
|
+
* [new RunEvalConfig.LabeledCriteria("correctness")],
|
|
138
|
+
* );
|
|
139
|
+
* ```
|
|
140
|
+
* @example
|
|
141
|
+
* ```ts
|
|
142
|
+
* const evalConfig = new RunEvalConfig(
|
|
143
|
+
* [new RunEvalConfig.Criteria(
|
|
144
|
+
* { "mentionsAllFacts": "Does the include all facts provided in the reference?"
|
|
145
|
+
* })],
|
|
146
|
+
*/
|
|
147
|
+
export type LabeledCriteria = EvalConfig & {
|
|
148
|
+
evaluatorType: "labeled_criteria";
|
|
149
|
+
/**
|
|
150
|
+
* The "criteria" to insert into the prompt template
|
|
151
|
+
* used for evaluation. See the prompt at
|
|
152
|
+
* https://smith.langchain.com/hub/langchain-ai/labeled-criteria
|
|
153
|
+
* for more information.
|
|
154
|
+
*/
|
|
155
|
+
criteria?: Criteria | Record<string, string>;
|
|
156
|
+
/**
|
|
157
|
+
* The feedback (or metric) name to use for the logged
|
|
158
|
+
* evaluation results. If none provided, we default to
|
|
159
|
+
* the evaluationName.
|
|
160
|
+
*/
|
|
161
|
+
feedbackKey?: string;
|
|
162
|
+
/**
|
|
163
|
+
* The language model to use as the evaluator.
|
|
164
|
+
*/
|
|
165
|
+
llm?: BaseLanguageModel;
|
|
166
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runOnDataset = void 0;
|
|
4
|
+
const runner_utils_js_1 = require("./runner_utils.cjs");
|
|
5
|
+
Object.defineProperty(exports, "runOnDataset", { enumerable: true, get: function () { return runner_utils_js_1.runOnDataset; } });
|