New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@effect/ai

Package Overview
Dependencies
Maintainers
0
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@effect/ai - npm Package Compare versions

Comparing version

to
0.10.6

31

dist/cjs/internal/aiPlan.js

@@ -7,7 +7,6 @@ "use strict";

exports.withFallback = exports.fromModel = exports.concatSteps = exports.TypeId = exports.PlanPrototype = void 0;
var Cause = _interopRequireWildcard(require("effect/Cause"));
var Context = _interopRequireWildcard(require("effect/Context"));
var Effect = _interopRequireWildcard(require("effect/Effect"));
var _Effectable = require("effect/Effectable");
var Exit = _interopRequireWildcard(require("effect/Exit"));
var Either = _interopRequireWildcard(require("effect/Either"));
var _Function = require("effect/Function");

@@ -42,16 +41,18 @@ var Option = _interopRequireWildcard(require("effect/Option"));

const models = Context.get(context, _AiModels.AiModels);
return Effect.fnUntraced(function* (effect) {
let exit = undefined;
for (const step of plan.steps) {
if (exit !== undefined && Exit.isFailure(exit) && Option.isSome(step.check)) {
const check = step.check.value(Cause.squash(exit.cause));
const isFatalError = !(Effect.isEffect(check) ? yield* check : check);
if (isFatalError) break;
return {
provide: Effect.fnUntraced(function* (effect) {
let result = undefined;
for (const step of plan.steps) {
if (result !== undefined && Either.isLeft(result) && Option.isSome(step.check)) {
const check = step.check.value(result.left);
const isFatalError = !(Effect.isEffect(check) ? yield* check : check);
if (isFatalError) break;
}
const retryOptions = getRetryOptions(step);
result = yield* Effect.scopedWith(scope => models.build(step.model, context).pipe(Scope.extend(scope), Effect.flatMap(context => effect.pipe(Option.isSome(retryOptions) ? Effect.retry(retryOptions.value) : _Function.identity, Effect.provide(context))), Effect.either));
if (Either.isRight(result)) break;
}
const retryOptions = getRetryOptions(step);
exit = yield* Effect.scopedWith(scope => models.build(step.model, context).pipe(Scope.extend(scope), Effect.flatMap(context => effect.pipe(Option.isSome(retryOptions) ? Effect.retry(retryOptions.value) : _Function.identity, Effect.provide(context))), Effect.exit));
if (Exit.isSuccess(exit)) break;
}
return yield* exit;
});
return yield* result;
})
};
});

@@ -58,0 +59,0 @@ const getRetryOptions = step => {

@@ -1,6 +0,5 @@

import * as Cause from "effect/Cause";
import * as Context from "effect/Context";
import * as Effect from "effect/Effect";
import { CommitPrototype } from "effect/Effectable";
import * as Exit from "effect/Exit";
import * as Either from "effect/Either";
import { dual, identity } from "effect/Function";

@@ -33,16 +32,18 @@ import * as Option from "effect/Option";

const models = Context.get(context, AiModels);
return Effect.fnUntraced(function* (effect) {
let exit = undefined;
for (const step of plan.steps) {
if (exit !== undefined && Exit.isFailure(exit) && Option.isSome(step.check)) {
const check = step.check.value(Cause.squash(exit.cause));
const isFatalError = !(Effect.isEffect(check) ? yield* check : check);
if (isFatalError) break;
return {
provide: Effect.fnUntraced(function* (effect) {
let result = undefined;
for (const step of plan.steps) {
if (result !== undefined && Either.isLeft(result) && Option.isSome(step.check)) {
const check = step.check.value(result.left);
const isFatalError = !(Effect.isEffect(check) ? yield* check : check);
if (isFatalError) break;
}
const retryOptions = getRetryOptions(step);
result = yield* Effect.scopedWith(scope => models.build(step.model, context).pipe(Scope.extend(scope), Effect.flatMap(context => effect.pipe(Option.isSome(retryOptions) ? Effect.retry(retryOptions.value) : identity, Effect.provide(context))), Effect.either));
if (Either.isRight(result)) break;
}
const retryOptions = getRetryOptions(step);
exit = yield* Effect.scopedWith(scope => models.build(step.model, context).pipe(Scope.extend(scope), Effect.flatMap(context => effect.pipe(Option.isSome(retryOptions) ? Effect.retry(retryOptions.value) : identity, Effect.provide(context))), Effect.exit));
if (Exit.isSuccess(exit)) break;
}
return yield* exit;
});
return yield* result;
})
};
});

@@ -49,0 +50,0 @@ const getRetryOptions = step => {

{
"name": "@effect/ai",
"version": "0.10.4",
"version": "0.10.6",
"description": "Effect modules for working with AI apis",

@@ -14,5 +14,5 @@ "license": "MIT",

"peerDependencies": {
"@effect/experimental": "^0.41.4",
"effect": "^3.13.4",
"@effect/platform": "^0.77.4"
"@effect/experimental": "^0.41.6",
"@effect/platform": "^0.77.6",
"effect": "^3.13.6"
},

@@ -19,0 +19,0 @@ "publishConfig": {

@@ -1,6 +0,5 @@

import * as Cause from "effect/Cause"
import * as Context from "effect/Context"
import * as Effect from "effect/Effect"
import { CommitPrototype } from "effect/Effectable"
import * as Exit from "effect/Exit"
import * as Either from "effect/Either"
import { dual, identity } from "effect/Function"

@@ -42,3 +41,3 @@ import * as Option from "effect/Option"

): Effect.Effect<
<A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Provides>>,
AiPlan.AiPlan.Provider<Provides>,
never,

@@ -49,29 +48,31 @@ Requires | AiModels

const models = Context.get(context, AiModels)
return Effect.fnUntraced(function*<A, E, R>(effect: Effect.Effect<A, E, R>) {
let exit: Exit.Exit<A, E> | undefined = undefined
for (const step of plan.steps) {
if (exit !== undefined && Exit.isFailure(exit) && Option.isSome(step.check)) {
const check = step.check.value(Cause.squash(exit.cause) as Error)
const isFatalError = !(Effect.isEffect(check) ? yield* check : check)
if (isFatalError) break
return {
provide: Effect.fnUntraced(function*<A, E, R>(effect: Effect.Effect<A, E, R>) {
let result: Either.Either<A, E> | undefined = undefined
for (const step of plan.steps) {
if (result !== undefined && Either.isLeft(result) && Option.isSome(step.check)) {
const check = step.check.value(result.left as any)
const isFatalError = !(Effect.isEffect(check) ? yield* check : check)
if (isFatalError) break
}
const retryOptions = getRetryOptions(step)
result = yield* Effect.scopedWith((scope) =>
models.build(step.model, context).pipe(
Scope.extend(scope),
Effect.flatMap((context) =>
effect.pipe(
Option.isSome(retryOptions)
? Effect.retry(retryOptions.value)
: identity,
Effect.provide(context)
)
),
Effect.either
)
)
if (Either.isRight(result)) break
}
const retryOptions = getRetryOptions(step)
exit = yield* Effect.scopedWith((scope) =>
models.build(step.model, context).pipe(
Scope.extend(scope),
Effect.flatMap((context) =>
effect.pipe(
Option.isSome(retryOptions)
? Effect.retry(retryOptions.value)
: identity,
Effect.provide(context)
)
),
Effect.exit
)
)
if (Exit.isSuccess(exit)) break
}
return yield* exit!
})
return yield* result!
})
}
})

@@ -78,0 +79,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet