arvo-core 1.0.25 → 1.0.27
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +4 -0
- package/README.md +1 -0
- package/dist/ArvoContract/index.d.ts +8 -8
- package/dist/ArvoContract/index.js +8 -8
- package/dist/ArvoContract/types.d.ts +24 -0
- package/dist/ArvoEvent/index.d.ts +2 -2
- package/dist/ArvoEvent/index.js +2 -2
- package/dist/ArvoEventFactory/index.d.ts +1 -1
- package/dist/ArvoEventFactory/index.js +2 -2
- package/dist/OpenTelemetry/ArvoExecution/index.d.ts +6 -0
- package/dist/OpenTelemetry/ArvoExecution/index.js +12 -0
- package/dist/OpenTelemetry/ArvoExecution/types.d.ts +4 -0
- package/dist/OpenTelemetry/ArvoExecution/types.js +8 -0
- package/dist/OpenTelemetry/OpenInference/index.d.ts +62 -0
- package/dist/OpenTelemetry/OpenInference/index.js +85 -0
- package/dist/OpenTelemetry/OpenInference/types.d.ts +14 -0
- package/dist/OpenTelemetry/OpenInference/types.js +18 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.js +9 -1
- package/dist/schema.d.ts +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { z } from 'zod';
|
2
|
-
import { ArvoContractRecord, IArvoContract } from './types';
|
2
|
+
import { ArvoContractJSONSchema, ArvoContractRecord, IArvoContract } from './types';
|
3
3
|
import { ArvoErrorSchema } from '../schema';
|
4
4
|
/**
|
5
5
|
* ArvoContract class represents a contract with defined input and output schemas.
|
@@ -39,7 +39,7 @@ export default class ArvoContract<TUri extends string = string, TType extends st
|
|
39
39
|
get emits(): TEmits;
|
40
40
|
get systemError(): ArvoContractRecord<`sys.${TType}.error`, typeof ArvoErrorSchema>;
|
41
41
|
/**
|
42
|
-
* Validates the contract bound handler's input against the
|
42
|
+
* Validates the contract bound handler's input/ accept event against the
|
43
43
|
* contract's accept schema.
|
44
44
|
* @template U - The type of the input to validate.
|
45
45
|
* @param type - The type of the input event.
|
@@ -47,9 +47,9 @@ export default class ArvoContract<TUri extends string = string, TType extends st
|
|
47
47
|
* @returns The validation result.
|
48
48
|
* @throws If the accept type is not found in the contract.
|
49
49
|
*/
|
50
|
-
|
50
|
+
validateAccepts<U>(type: TType, input: U): z.SafeParseReturnType<any, any>;
|
51
51
|
/**
|
52
|
-
* Validates the contract bound handler's output against the
|
52
|
+
* Validates the contract bound handler's output/ emits against the
|
53
53
|
* contract's emit schema.
|
54
54
|
* @template U - The type of the output to validate.
|
55
55
|
* @param type - The type of the output event.
|
@@ -57,21 +57,21 @@ export default class ArvoContract<TUri extends string = string, TType extends st
|
|
57
57
|
* @returns The validation result.
|
58
58
|
* @throws If the emit type is not found in the contract.
|
59
59
|
*/
|
60
|
-
|
60
|
+
validateEmits<U extends keyof TEmits>(type: U, output: unknown): z.SafeParseReturnType<any, any>;
|
61
61
|
/**
|
62
62
|
* Validates the accepts record.
|
63
63
|
* @param accepts - The accepts record to validate.
|
64
64
|
* @returns The validated accepts record.
|
65
65
|
* @private
|
66
66
|
*/
|
67
|
-
private
|
67
|
+
private _validateAccepts;
|
68
68
|
/**
|
69
69
|
* Validates the emits records.
|
70
70
|
* @param emits - The emits records to validate.
|
71
71
|
* @returns The validated emits records.
|
72
72
|
* @private
|
73
73
|
*/
|
74
|
-
private
|
74
|
+
private _validateEmits;
|
75
75
|
/**
|
76
76
|
* Exports the ArvoContract instance as a plain object conforming to the IArvoContract interface.
|
77
77
|
* This method can be used to serialize the contract or to create a new instance with the same parameters.
|
@@ -90,5 +90,5 @@ export default class ArvoContract<TUri extends string = string, TType extends st
|
|
90
90
|
* - accepts: An object containing the accepted input type and its JSON Schema representation
|
91
91
|
* - emits: An array of objects, each containing an emitted event type and its JSON Schema representation
|
92
92
|
*/
|
93
|
-
toJsonSchema():
|
93
|
+
toJsonSchema(): ArvoContractJSONSchema;
|
94
94
|
}
|
@@ -32,8 +32,8 @@ var ArvoContract = /** @class */ (function () {
|
|
32
32
|
*/
|
33
33
|
function ArvoContract(params) {
|
34
34
|
this._uri = validators_1.ArvoContractValidators.contract.uri.parse(params.uri);
|
35
|
-
this._accepts = this.
|
36
|
-
this._emits = this.
|
35
|
+
this._accepts = this._validateAccepts(params.accepts);
|
36
|
+
this._emits = this._validateEmits(params.emits);
|
37
37
|
this.description = params.description || null;
|
38
38
|
}
|
39
39
|
Object.defineProperty(ArvoContract.prototype, "uri", {
|
@@ -79,7 +79,7 @@ var ArvoContract = /** @class */ (function () {
|
|
79
79
|
configurable: true
|
80
80
|
});
|
81
81
|
/**
|
82
|
-
* Validates the contract bound handler's input against the
|
82
|
+
* Validates the contract bound handler's input/ accept event against the
|
83
83
|
* contract's accept schema.
|
84
84
|
* @template U - The type of the input to validate.
|
85
85
|
* @param type - The type of the input event.
|
@@ -87,14 +87,14 @@ var ArvoContract = /** @class */ (function () {
|
|
87
87
|
* @returns The validation result.
|
88
88
|
* @throws If the accept type is not found in the contract.
|
89
89
|
*/
|
90
|
-
ArvoContract.prototype.
|
90
|
+
ArvoContract.prototype.validateAccepts = function (type, input) {
|
91
91
|
if (type !== this._accepts.type) {
|
92
92
|
throw new Error("Accept type \"".concat(type, "\" not found in contract"));
|
93
93
|
}
|
94
94
|
return this._accepts.schema.safeParse(input);
|
95
95
|
};
|
96
96
|
/**
|
97
|
-
* Validates the contract bound handler's output against the
|
97
|
+
* Validates the contract bound handler's output/ emits against the
|
98
98
|
* contract's emit schema.
|
99
99
|
* @template U - The type of the output to validate.
|
100
100
|
* @param type - The type of the output event.
|
@@ -102,7 +102,7 @@ var ArvoContract = /** @class */ (function () {
|
|
102
102
|
* @returns The validation result.
|
103
103
|
* @throws If the emit type is not found in the contract.
|
104
104
|
*/
|
105
|
-
ArvoContract.prototype.
|
105
|
+
ArvoContract.prototype.validateEmits = function (type, output) {
|
106
106
|
var emit = this.emits[type];
|
107
107
|
if (!emit) {
|
108
108
|
throw new Error("Emit type \"".concat(type.toString(), "\" not found in contract"));
|
@@ -115,7 +115,7 @@ var ArvoContract = /** @class */ (function () {
|
|
115
115
|
* @returns The validated accepts record.
|
116
116
|
* @private
|
117
117
|
*/
|
118
|
-
ArvoContract.prototype.
|
118
|
+
ArvoContract.prototype._validateAccepts = function (accepts) {
|
119
119
|
return {
|
120
120
|
type: validators_1.ArvoContractValidators.record.type.parse(accepts.type),
|
121
121
|
schema: accepts.schema,
|
@@ -127,7 +127,7 @@ var ArvoContract = /** @class */ (function () {
|
|
127
127
|
* @returns The validated emits records.
|
128
128
|
* @private
|
129
129
|
*/
|
130
|
-
ArvoContract.prototype.
|
130
|
+
ArvoContract.prototype._validateEmits = function (emits) {
|
131
131
|
Object.entries(emits).forEach(function (_a) {
|
132
132
|
var key = _a[0];
|
133
133
|
return validators_1.ArvoContractValidators.record.type.parse(key);
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { z } from 'zod';
|
2
|
+
import zodToJsonSchema from 'zod-to-json-schema';
|
2
3
|
/**
|
3
4
|
* Represents a record in an Arvo contract.
|
4
5
|
* @template TType - The type of the record, defaults to string.
|
@@ -33,3 +34,26 @@ export interface IArvoContract<TUri extends string = string, TType extends strin
|
|
33
34
|
* @template T - The ArvoContractRecord to resolve.
|
34
35
|
*/
|
35
36
|
export type ResolveArvoContractRecord<T extends ArvoContractRecord> = z.infer<T['schema']>;
|
37
|
+
/**
|
38
|
+
* Represents the JSON Schema representation of an ArvoContract.
|
39
|
+
*/
|
40
|
+
export type ArvoContractJSONSchema = {
|
41
|
+
/** The unique identifier (URI) of the contract */
|
42
|
+
uri: string;
|
43
|
+
/** The description of the contract (null if not provided) */
|
44
|
+
description: string | null;
|
45
|
+
/** The accepted input schema for the contract */
|
46
|
+
accepts: {
|
47
|
+
/** The type identifier for the accepted input */
|
48
|
+
type: string;
|
49
|
+
/** The JSON Schema representation of the accepted input schema */
|
50
|
+
schema: ReturnType<typeof zodToJsonSchema>;
|
51
|
+
};
|
52
|
+
/** An array of emitted event schemas for the contract */
|
53
|
+
emits: {
|
54
|
+
/** The type identifier for the emitted event */
|
55
|
+
type: string;
|
56
|
+
/** The JSON Schema representation of the emitted event schema */
|
57
|
+
schema: ReturnType<typeof zodToJsonSchema>;
|
58
|
+
}[];
|
59
|
+
};
|
@@ -137,7 +137,7 @@ export default class ArvoEvent<TData extends ArvoEventData = ArvoEventData, TExt
|
|
137
137
|
*
|
138
138
|
* @remark
|
139
139
|
* This is a convenience getter for the data in `this.extensions.traceparent` as this
|
140
|
-
* is an ArvoEvent object which natively
|
140
|
+
* is an ArvoEvent object which natively defines this extension on the CloudEvent
|
141
141
|
* spec.
|
142
142
|
*/
|
143
143
|
get traceparent(): string | null;
|
@@ -148,7 +148,7 @@ export default class ArvoEvent<TData extends ArvoEventData = ArvoEventData, TExt
|
|
148
148
|
*
|
149
149
|
* @remark
|
150
150
|
* This is a convenience getter for the data in `this.extensions.tracestate` as this
|
151
|
-
* is an ArvoEvent object which natively
|
151
|
+
* is an ArvoEvent object which natively defines this extension on the CloudEvent
|
152
152
|
* spec.
|
153
153
|
*/
|
154
154
|
get tracestate(): string | null;
|
package/dist/ArvoEvent/index.js
CHANGED
@@ -198,7 +198,7 @@ var ArvoEvent = /** @class */ (function () {
|
|
198
198
|
*
|
199
199
|
* @remark
|
200
200
|
* This is a convenience getter for the data in `this.extensions.traceparent` as this
|
201
|
-
* is an ArvoEvent object which natively
|
201
|
+
* is an ArvoEvent object which natively defines this extension on the CloudEvent
|
202
202
|
* spec.
|
203
203
|
*/
|
204
204
|
get: function () {
|
@@ -215,7 +215,7 @@ var ArvoEvent = /** @class */ (function () {
|
|
215
215
|
*
|
216
216
|
* @remark
|
217
217
|
* This is a convenience getter for the data in `this.extensions.tracestate` as this
|
218
|
-
* is an ArvoEvent object which natively
|
218
|
+
* is an ArvoEvent object which natively defines this extension on the CloudEvent
|
219
219
|
* spec.
|
220
220
|
*/
|
221
221
|
get: function () {
|
@@ -54,8 +54,8 @@ export default class ArvoEventFactory<TUri extends string = string, TType extend
|
|
54
54
|
error: Error;
|
55
55
|
to: string;
|
56
56
|
}, extensions?: TExtension): import("..").ArvoEvent<{
|
57
|
-
errorName: string;
|
58
57
|
errorMessage: string;
|
58
|
+
errorName: string;
|
59
59
|
errorStack: string | null;
|
60
60
|
}, TExtension, `sys.${TType}.error`>;
|
61
61
|
}
|
@@ -58,7 +58,7 @@ var ArvoEventFactory = /** @class */ (function () {
|
|
58
58
|
return api_1.context.with(api_1.trace.setSpan(api_1.context.active(), span), function () {
|
59
59
|
span.setStatus({ code: api_1.SpanStatusCode.OK });
|
60
60
|
try {
|
61
|
-
var validationResult = _this.contract.
|
61
|
+
var validationResult = _this.contract.validateAccepts(_this.contract.accepts.type, event.data);
|
62
62
|
if (!validationResult.success) {
|
63
63
|
throw new Error("Accept Event data validation failed: ".concat(validationResult.error.message));
|
64
64
|
}
|
@@ -93,7 +93,7 @@ var ArvoEventFactory = /** @class */ (function () {
|
|
93
93
|
return api_1.context.with(api_1.trace.setSpan(api_1.context.active(), span), function () {
|
94
94
|
span.setStatus({ code: api_1.SpanStatusCode.OK });
|
95
95
|
try {
|
96
|
-
var validationResult = _this.contract.
|
96
|
+
var validationResult = _this.contract.validateEmits(event.type, event.data);
|
97
97
|
if (!validationResult.success) {
|
98
98
|
throw new Error("Emit Event data validation failed: ".concat(validationResult.error.message));
|
99
99
|
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
/**
|
4
|
+
* ArvoExection class containing attribute constants for OpenTelemetry.
|
5
|
+
*/
|
6
|
+
var ArvoExecution = /** @class */ (function () {
|
7
|
+
function ArvoExecution() {
|
8
|
+
}
|
9
|
+
ArvoExecution.ATTR_SPAN_KIND = "arvo.span.kind";
|
10
|
+
return ArvoExecution;
|
11
|
+
}());
|
12
|
+
exports.default = ArvoExecution;
|
@@ -0,0 +1,8 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.ArvoExecutionSpanKind = void 0;
|
4
|
+
var ArvoExecutionSpanKind;
|
5
|
+
(function (ArvoExecutionSpanKind) {
|
6
|
+
ArvoExecutionSpanKind["EVENT_HANDLER"] = "EVENT_HANDLER";
|
7
|
+
ArvoExecutionSpanKind["COMMANDER"] = "COMMANDER";
|
8
|
+
})(ArvoExecutionSpanKind || (exports.ArvoExecutionSpanKind = ArvoExecutionSpanKind = {}));
|
@@ -0,0 +1,62 @@
|
|
1
|
+
/**
|
2
|
+
* OpenInference class containing attribute constants for OpenTelemetry OpenInference.
|
3
|
+
* These attribute names are defined as per the OpenInference specification:
|
4
|
+
* @see https://github.com/Arize-ai/openinference/blob/main/spec/semantic_conventions.md
|
5
|
+
*/
|
6
|
+
export default class OpenInference {
|
7
|
+
static readonly ATTR_SPAN_KIND = "openinference.span.kind";
|
8
|
+
static readonly ATTR_DOCUMENT_CONTENT = "document.content";
|
9
|
+
static readonly ATTR_DOCUMENT_ID = "document.id";
|
10
|
+
static readonly ATTR_DOCUMENT_METADATA = "document.metadata";
|
11
|
+
static readonly ATTR_DOCUMENT_SCORE = "document.score";
|
12
|
+
static readonly ATTR_EMBEDDING_EMBEDDINGS = "embedding.embeddings";
|
13
|
+
static readonly ATTR_EMBEDDING_MODEL_NAME = "embedding.model_name";
|
14
|
+
static readonly ATTR_EMBEDDING_TEXT = "embedding.text";
|
15
|
+
static readonly ATTR_EMBEDDING_VECTOR = "embedding.vector";
|
16
|
+
static readonly ATTR_EXCEPTION_ESCAPED = "exception.escaped";
|
17
|
+
static readonly ATTR_EXCEPTION_MESSAGE = "exception.message";
|
18
|
+
static readonly ATTR_EXCEPTION_STACKTRACE = "exception.stacktrace";
|
19
|
+
static readonly ATTR_EXCEPTION_TYPE = "exception.type";
|
20
|
+
static readonly ATTR_IMAGE_URL = "image.url";
|
21
|
+
static readonly ATTR_INPUT_MIME_TYPE = "input.mime_type";
|
22
|
+
static readonly ATTR_INPUT_VALUE = "input.value";
|
23
|
+
static readonly ATTR_LLM_FUNCTION_CALL = "llm.function_call";
|
24
|
+
static readonly ATTR_LLM_INPUT_MESSAGES = "llm.input_messages";
|
25
|
+
static readonly ATTR_LLM_INVOCATION_PARAMETERS = "llm.invocation_parameters";
|
26
|
+
static readonly ATTR_LLM_MODEL_NAME = "llm.model_name";
|
27
|
+
static readonly ATTR_LLM_OUTPUT_MESSAGES = "llm.output_messages";
|
28
|
+
static readonly ATTR_LLM_PROMPT_TEMPLATE_TEMPLATE = "llm.prompt_template.template";
|
29
|
+
static readonly ATTR_LLM_PROMPT_TEMPLATE_VARIABLES = "llm.prompt_template.variables";
|
30
|
+
static readonly ATTR_LLM_PROMPT_TEMPLATE_VERSION = "llm.prompt_template.version";
|
31
|
+
static readonly ATTR_LLM_TOKEN_COUNT_COMPLETION = "llm.token_count.completion";
|
32
|
+
static readonly ATTR_LLM_TOKEN_COUNT_PROMPT = "llm.token_count.prompt";
|
33
|
+
static readonly ATTR_LLM_TOKEN_COUNT_TOTAL = "llm.token_count.total";
|
34
|
+
static readonly ATTR_LLM_TOOLS = "llm.tools";
|
35
|
+
static readonly ATTR_MESSAGE_CONTENT = "message.content";
|
36
|
+
static readonly ATTR_MESSAGE_CONTENTS = "message.contents";
|
37
|
+
static readonly ATTR_MESSAGE_FUNCTION_CALL_ARGUMENTS_JSON = "message.function_call_arguments_json";
|
38
|
+
static readonly ATTR_MESSAGE_FUNCTION_CALL_NAME = "message.function_call_name";
|
39
|
+
static readonly ATTR_MESSAGE_ROLE = "message.role";
|
40
|
+
static readonly ATTR_MESSAGE_TOOL_CALLS = "message.tool_calls";
|
41
|
+
static readonly ATTR_MESSAGE_CONTENT_TYPE = "messagecontent.type";
|
42
|
+
static readonly ATTR_MESSAGE_CONTENT_TEXT = "messagecontent.text";
|
43
|
+
static readonly ATTR_MESSAGE_CONTENT_IMAGE = "messagecontent.image";
|
44
|
+
static readonly ATTR_METADATA = "metadata";
|
45
|
+
static readonly ATTR_OUTPUT_MIME_TYPE = "output.mime_type";
|
46
|
+
static readonly ATTR_OUTPUT_VALUE = "output.value";
|
47
|
+
static readonly ATTR_RERANKER_INPUT_DOCUMENTS = "reranker.input_documents";
|
48
|
+
static readonly ATTR_RERANKER_MODEL_NAME = "reranker.model_name";
|
49
|
+
static readonly ATTR_RERANKER_OUTPUT_DOCUMENTS = "reranker.output_documents";
|
50
|
+
static readonly ATTR_RERANKER_QUERY = "reranker.query";
|
51
|
+
static readonly ATTR_RERANKER_TOP_K = "reranker.top_k";
|
52
|
+
static readonly ATTR_RETRIEVAL_DOCUMENTS = "retrieval.documents";
|
53
|
+
static readonly ATTR_SESSION_ID = "session.id";
|
54
|
+
static readonly ATTR_TAG_TAGS = "tag.tags";
|
55
|
+
static readonly ATTR_TOOL_DESCRIPTION = "tool.description";
|
56
|
+
static readonly ATTR_TOOL_JSON_SCHEMA = "tool.json_schema";
|
57
|
+
static readonly ATTR_TOOL_NAME = "tool.name";
|
58
|
+
static readonly ATTR_TOOL_PARAMETERS = "tool.parameters";
|
59
|
+
static readonly ATTR_TOOL_CALL_FUNCTION_ARGUMENTS = "tool_call.function.arguments";
|
60
|
+
static readonly ATTR_TOOL_CALL_FUNCTION_NAME = "tool_call.function.name";
|
61
|
+
static readonly ATTR_USER_ID = "user.id";
|
62
|
+
}
|
@@ -0,0 +1,85 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
/**
|
4
|
+
* OpenInference class containing attribute constants for OpenTelemetry OpenInference.
|
5
|
+
* These attribute names are defined as per the OpenInference specification:
|
6
|
+
* @see https://github.com/Arize-ai/openinference/blob/main/spec/semantic_conventions.md
|
7
|
+
*/
|
8
|
+
var OpenInference = /** @class */ (function () {
|
9
|
+
function OpenInference() {
|
10
|
+
}
|
11
|
+
OpenInference.ATTR_SPAN_KIND = "openinference.span.kind";
|
12
|
+
// Document attributes
|
13
|
+
OpenInference.ATTR_DOCUMENT_CONTENT = "document.content";
|
14
|
+
OpenInference.ATTR_DOCUMENT_ID = "document.id";
|
15
|
+
OpenInference.ATTR_DOCUMENT_METADATA = "document.metadata";
|
16
|
+
OpenInference.ATTR_DOCUMENT_SCORE = "document.score";
|
17
|
+
// Embedding attributes
|
18
|
+
OpenInference.ATTR_EMBEDDING_EMBEDDINGS = "embedding.embeddings";
|
19
|
+
OpenInference.ATTR_EMBEDDING_MODEL_NAME = "embedding.model_name";
|
20
|
+
OpenInference.ATTR_EMBEDDING_TEXT = "embedding.text";
|
21
|
+
OpenInference.ATTR_EMBEDDING_VECTOR = "embedding.vector";
|
22
|
+
// Exception attributes
|
23
|
+
OpenInference.ATTR_EXCEPTION_ESCAPED = "exception.escaped";
|
24
|
+
OpenInference.ATTR_EXCEPTION_MESSAGE = "exception.message";
|
25
|
+
OpenInference.ATTR_EXCEPTION_STACKTRACE = "exception.stacktrace";
|
26
|
+
OpenInference.ATTR_EXCEPTION_TYPE = "exception.type";
|
27
|
+
// Image attribute
|
28
|
+
OpenInference.ATTR_IMAGE_URL = "image.url";
|
29
|
+
// Input attributes
|
30
|
+
OpenInference.ATTR_INPUT_MIME_TYPE = "input.mime_type";
|
31
|
+
OpenInference.ATTR_INPUT_VALUE = "input.value";
|
32
|
+
// LLM attributes
|
33
|
+
OpenInference.ATTR_LLM_FUNCTION_CALL = "llm.function_call";
|
34
|
+
OpenInference.ATTR_LLM_INPUT_MESSAGES = "llm.input_messages";
|
35
|
+
OpenInference.ATTR_LLM_INVOCATION_PARAMETERS = "llm.invocation_parameters";
|
36
|
+
OpenInference.ATTR_LLM_MODEL_NAME = "llm.model_name";
|
37
|
+
OpenInference.ATTR_LLM_OUTPUT_MESSAGES = "llm.output_messages";
|
38
|
+
OpenInference.ATTR_LLM_PROMPT_TEMPLATE_TEMPLATE = "llm.prompt_template.template";
|
39
|
+
OpenInference.ATTR_LLM_PROMPT_TEMPLATE_VARIABLES = "llm.prompt_template.variables";
|
40
|
+
OpenInference.ATTR_LLM_PROMPT_TEMPLATE_VERSION = "llm.prompt_template.version";
|
41
|
+
OpenInference.ATTR_LLM_TOKEN_COUNT_COMPLETION = "llm.token_count.completion";
|
42
|
+
OpenInference.ATTR_LLM_TOKEN_COUNT_PROMPT = "llm.token_count.prompt";
|
43
|
+
OpenInference.ATTR_LLM_TOKEN_COUNT_TOTAL = "llm.token_count.total";
|
44
|
+
OpenInference.ATTR_LLM_TOOLS = "llm.tools";
|
45
|
+
// Message attributes
|
46
|
+
OpenInference.ATTR_MESSAGE_CONTENT = "message.content";
|
47
|
+
OpenInference.ATTR_MESSAGE_CONTENTS = "message.contents";
|
48
|
+
OpenInference.ATTR_MESSAGE_FUNCTION_CALL_ARGUMENTS_JSON = "message.function_call_arguments_json";
|
49
|
+
OpenInference.ATTR_MESSAGE_FUNCTION_CALL_NAME = "message.function_call_name";
|
50
|
+
OpenInference.ATTR_MESSAGE_ROLE = "message.role";
|
51
|
+
OpenInference.ATTR_MESSAGE_TOOL_CALLS = "message.tool_calls";
|
52
|
+
// Message content attributes
|
53
|
+
OpenInference.ATTR_MESSAGE_CONTENT_TYPE = "messagecontent.type";
|
54
|
+
OpenInference.ATTR_MESSAGE_CONTENT_TEXT = "messagecontent.text";
|
55
|
+
OpenInference.ATTR_MESSAGE_CONTENT_IMAGE = "messagecontent.image";
|
56
|
+
// Metadata attribute
|
57
|
+
OpenInference.ATTR_METADATA = "metadata";
|
58
|
+
// Output attributes
|
59
|
+
OpenInference.ATTR_OUTPUT_MIME_TYPE = "output.mime_type";
|
60
|
+
OpenInference.ATTR_OUTPUT_VALUE = "output.value";
|
61
|
+
// Reranker attributes
|
62
|
+
OpenInference.ATTR_RERANKER_INPUT_DOCUMENTS = "reranker.input_documents";
|
63
|
+
OpenInference.ATTR_RERANKER_MODEL_NAME = "reranker.model_name";
|
64
|
+
OpenInference.ATTR_RERANKER_OUTPUT_DOCUMENTS = "reranker.output_documents";
|
65
|
+
OpenInference.ATTR_RERANKER_QUERY = "reranker.query";
|
66
|
+
OpenInference.ATTR_RERANKER_TOP_K = "reranker.top_k";
|
67
|
+
// Retrieval attribute
|
68
|
+
OpenInference.ATTR_RETRIEVAL_DOCUMENTS = "retrieval.documents";
|
69
|
+
// Session attribute
|
70
|
+
OpenInference.ATTR_SESSION_ID = "session.id";
|
71
|
+
// Tag attribute
|
72
|
+
OpenInference.ATTR_TAG_TAGS = "tag.tags";
|
73
|
+
// Tool attributes
|
74
|
+
OpenInference.ATTR_TOOL_DESCRIPTION = "tool.description";
|
75
|
+
OpenInference.ATTR_TOOL_JSON_SCHEMA = "tool.json_schema";
|
76
|
+
OpenInference.ATTR_TOOL_NAME = "tool.name";
|
77
|
+
OpenInference.ATTR_TOOL_PARAMETERS = "tool.parameters";
|
78
|
+
// Tool call attributes
|
79
|
+
OpenInference.ATTR_TOOL_CALL_FUNCTION_ARGUMENTS = "tool_call.function.arguments";
|
80
|
+
OpenInference.ATTR_TOOL_CALL_FUNCTION_NAME = "tool_call.function.name";
|
81
|
+
// User attribute
|
82
|
+
OpenInference.ATTR_USER_ID = "user.id";
|
83
|
+
return OpenInference;
|
84
|
+
}());
|
85
|
+
exports.default = OpenInference;
|
@@ -0,0 +1,14 @@
|
|
1
|
+
/**
|
2
|
+
* The open inference span kind as per
|
3
|
+
* https://github.com/Arize-ai/openinference/blob/main/spec/traces.md#span-kind
|
4
|
+
*/
|
5
|
+
export declare enum OpenInferenceSpanKind {
|
6
|
+
CHAIN = "CHAIN",
|
7
|
+
RETRIEVER = "RETRIEVER",
|
8
|
+
RERANKER = "RERANKER",
|
9
|
+
LLM = "LLM",
|
10
|
+
EMBEDDING = "EMBEDDING",
|
11
|
+
TOOL = "TOOL",
|
12
|
+
GUARDRAIL = "GUARDRAIL",
|
13
|
+
EVALUATOR = "EVALUATOR"
|
14
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.OpenInferenceSpanKind = void 0;
|
4
|
+
/**
|
5
|
+
* The open inference span kind as per
|
6
|
+
* https://github.com/Arize-ai/openinference/blob/main/spec/traces.md#span-kind
|
7
|
+
*/
|
8
|
+
var OpenInferenceSpanKind;
|
9
|
+
(function (OpenInferenceSpanKind) {
|
10
|
+
OpenInferenceSpanKind["CHAIN"] = "CHAIN";
|
11
|
+
OpenInferenceSpanKind["RETRIEVER"] = "RETRIEVER";
|
12
|
+
OpenInferenceSpanKind["RERANKER"] = "RERANKER";
|
13
|
+
OpenInferenceSpanKind["LLM"] = "LLM";
|
14
|
+
OpenInferenceSpanKind["EMBEDDING"] = "EMBEDDING";
|
15
|
+
OpenInferenceSpanKind["TOOL"] = "TOOL";
|
16
|
+
OpenInferenceSpanKind["GUARDRAIL"] = "GUARDRAIL";
|
17
|
+
OpenInferenceSpanKind["EVALUATOR"] = "EVALUATOR";
|
18
|
+
})(OpenInferenceSpanKind || (exports.OpenInferenceSpanKind = OpenInferenceSpanKind = {}));
|
package/dist/index.d.ts
CHANGED
@@ -8,12 +8,16 @@ import { validateURI, cleanString } from './utils';
|
|
8
8
|
import ArvoContract from './ArvoContract';
|
9
9
|
import { createArvoContract, InferArvoContract } from './ArvoContract/helpers';
|
10
10
|
import { ArvoContractValidators } from './ArvoContract/validators';
|
11
|
-
import { ArvoContractRecord, IArvoContract, ResolveArvoContractRecord } from './ArvoContract/types';
|
11
|
+
import { ArvoContractRecord, IArvoContract, ResolveArvoContractRecord, ArvoContractJSONSchema } from './ArvoContract/types';
|
12
12
|
import ArvoContractLibrary from './ArvoContractLibrary';
|
13
13
|
import { createArvoContractLibrary } from './ArvoContractLibrary/helpers';
|
14
14
|
import ArvoEventFactory from './ArvoEventFactory';
|
15
15
|
import { createArvoEventFactory } from './ArvoEventFactory/helpers';
|
16
16
|
import { ArvoErrorSchema } from './schema';
|
17
|
+
import OpenInference from './OpenTelemetry/OpenInference';
|
18
|
+
import ArvoExecution from './OpenTelemetry/ArvoExecution';
|
19
|
+
import { ArvoExecutionSpanKind } from './OpenTelemetry/ArvoExecution/types';
|
20
|
+
import { OpenInferenceSpanKind } from './OpenTelemetry/OpenInference/types';
|
17
21
|
/**
|
18
22
|
* Collection of Zod schemas for validating various aspects of Arvo events.
|
19
23
|
* @property {z.ZodObject} CloudEventContextSchema - Schema for core CloudEvent properties.
|
@@ -80,4 +84,4 @@ declare const ArvoEventSchemas: {
|
|
80
84
|
tracestate: string | null;
|
81
85
|
}>;
|
82
86
|
};
|
83
|
-
export { ArvoEvent, createArvoEvent, ArvoDataContentType, ArvoEventData, CloudEventExtension, ArvoEventSchemas, CloudEventContext, ArvoExtension, OpenTelemetryExtension, CreateArvoEvent, exceptionToSpan, logToSpan, OpenTelemetryHeaders, TelemetryLogLevel, OTelNull, validateURI, cleanString, ArvoContract, createArvoContract, ArvoContractValidators, ArvoContractRecord, InferArvoContract, IArvoContract, ResolveArvoContractRecord, ArvoContractLibrary, createArvoContractLibrary, ArvoEventFactory, createArvoEventFactory, ArvoErrorSchema, currentOpenTelemetryHeaders, };
|
87
|
+
export { ArvoEvent, createArvoEvent, ArvoDataContentType, ArvoEventData, CloudEventExtension, ArvoEventSchemas, CloudEventContext, ArvoExtension, OpenTelemetryExtension, CreateArvoEvent, exceptionToSpan, logToSpan, OpenTelemetryHeaders, TelemetryLogLevel, OTelNull, validateURI, cleanString, ArvoContract, createArvoContract, ArvoContractValidators, ArvoContractRecord, InferArvoContract, IArvoContract, ResolveArvoContractRecord, ArvoContractLibrary, createArvoContractLibrary, ArvoEventFactory, createArvoEventFactory, ArvoErrorSchema, currentOpenTelemetryHeaders, OpenInference, OpenInferenceSpanKind, ArvoExecution, ArvoExecutionSpanKind, ArvoContractJSONSchema, };
|
package/dist/index.js
CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.currentOpenTelemetryHeaders = exports.ArvoErrorSchema = exports.createArvoEventFactory = exports.ArvoEventFactory = exports.createArvoContractLibrary = exports.ArvoContractLibrary = exports.ArvoContractValidators = exports.createArvoContract = exports.ArvoContract = exports.cleanString = exports.validateURI = exports.OTelNull = exports.logToSpan = exports.exceptionToSpan = exports.ArvoEventSchemas = exports.ArvoDataContentType = exports.createArvoEvent = exports.ArvoEvent = void 0;
|
6
|
+
exports.ArvoExecutionSpanKind = exports.ArvoExecution = exports.OpenInferenceSpanKind = exports.OpenInference = exports.currentOpenTelemetryHeaders = exports.ArvoErrorSchema = exports.createArvoEventFactory = exports.ArvoEventFactory = exports.createArvoContractLibrary = exports.ArvoContractLibrary = exports.ArvoContractValidators = exports.createArvoContract = exports.ArvoContract = exports.cleanString = exports.validateURI = exports.OTelNull = exports.logToSpan = exports.exceptionToSpan = exports.ArvoEventSchemas = exports.ArvoDataContentType = exports.createArvoEvent = exports.ArvoEvent = void 0;
|
7
7
|
var ArvoEvent_1 = __importDefault(require("./ArvoEvent"));
|
8
8
|
exports.ArvoEvent = ArvoEvent_1.default;
|
9
9
|
var schema_1 = require("./ArvoEvent/schema");
|
@@ -34,6 +34,14 @@ var helpers_4 = require("./ArvoEventFactory/helpers");
|
|
34
34
|
Object.defineProperty(exports, "createArvoEventFactory", { enumerable: true, get: function () { return helpers_4.createArvoEventFactory; } });
|
35
35
|
var schema_2 = require("./schema");
|
36
36
|
Object.defineProperty(exports, "ArvoErrorSchema", { enumerable: true, get: function () { return schema_2.ArvoErrorSchema; } });
|
37
|
+
var OpenInference_1 = __importDefault(require("./OpenTelemetry/OpenInference"));
|
38
|
+
exports.OpenInference = OpenInference_1.default;
|
39
|
+
var ArvoExecution_1 = __importDefault(require("./OpenTelemetry/ArvoExecution"));
|
40
|
+
exports.ArvoExecution = ArvoExecution_1.default;
|
41
|
+
var types_1 = require("./OpenTelemetry/ArvoExecution/types");
|
42
|
+
Object.defineProperty(exports, "ArvoExecutionSpanKind", { enumerable: true, get: function () { return types_1.ArvoExecutionSpanKind; } });
|
43
|
+
var types_2 = require("./OpenTelemetry/OpenInference/types");
|
44
|
+
Object.defineProperty(exports, "OpenInferenceSpanKind", { enumerable: true, get: function () { return types_2.OpenInferenceSpanKind; } });
|
37
45
|
/**
|
38
46
|
* Collection of Zod schemas for validating various aspects of Arvo events.
|
39
47
|
* @property {z.ZodObject} CloudEventContextSchema - Schema for core CloudEvent properties.
|
package/dist/schema.d.ts
CHANGED
@@ -10,11 +10,11 @@ export declare const ArvoErrorSchema: z.ZodObject<{
|
|
10
10
|
errorMessage: z.ZodString;
|
11
11
|
errorStack: z.ZodNullable<z.ZodString>;
|
12
12
|
}, "strip", z.ZodTypeAny, {
|
13
|
-
errorName: string;
|
14
13
|
errorMessage: string;
|
14
|
+
errorName: string;
|
15
15
|
errorStack: string | null;
|
16
16
|
}, {
|
17
|
-
errorName: string;
|
18
17
|
errorMessage: string;
|
18
|
+
errorName: string;
|
19
19
|
errorStack: string | null;
|
20
20
|
}>;
|