openloops 0.1.22 → 0.1.23

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.
@@ -1,4 +1,3 @@
1
- import 'reflect-metadata';
2
1
  import type { KnownProvider, Message, AssistantMessage } from '@mariozechner/pi-ai';
3
2
  import { CurrentUser } from '../common/base/index.js';
4
3
  export declare class LLMClient {
@@ -12,7 +11,7 @@ export declare class LLMClient {
12
11
  private formatMessagesForLog;
13
12
  }
14
13
  export interface LLMCompletionParams {
15
- taskName: string;
14
+ origin: string;
16
15
  sessionId: string;
17
16
  answerId: string;
18
17
  currentUser?: CurrentUser;
@@ -23,7 +22,7 @@ export interface LLMCompletionParams {
23
22
  temperature?: number;
24
23
  }
25
24
  export interface LLMPostResponseParams {
26
- taskName: string;
25
+ origin: string;
27
26
  sessionId: string;
28
27
  answerId: string;
29
28
  currentUser?: CurrentUser;
@@ -31,13 +31,11 @@ __export(llm_client_exports, {
31
31
  LLMClient: () => LLMClient
32
32
  });
33
33
  module.exports = __toCommonJS(llm_client_exports);
34
- var import_reflect_metadata = require("reflect-metadata");
35
- var import_tsyringe = require("tsyringe");
36
34
  var import_langfuse = require("langfuse");
37
35
  var import_secret_manager = require("../common/utils/secret-manager.js");
38
36
  var import_logger = require("../common/logger/index.js");
39
37
  var import_helpers = require("../common/helpers/index.js");
40
- var import_create_llmcall = require("../services/llmcalls/lambdas/create-llmcall/index.js");
38
+ var import_llmcalls = require("../services/llmcalls/index.js");
41
39
  class LLMClient {
42
40
  logger = new import_logger.Logger();
43
41
  langfuse;
@@ -58,7 +56,7 @@ class LLMClient {
58
56
  async complete(params) {
59
57
  const { getModel, complete } = await import("@mariozechner/pi-ai");
60
58
  const {
61
- taskName,
59
+ origin,
62
60
  sessionId,
63
61
  answerId,
64
62
  currentUser,
@@ -74,7 +72,7 @@ class LLMClient {
74
72
  messages
75
73
  };
76
74
  this.logger.debug({
77
- taskName,
75
+ origin,
78
76
  context: {
79
77
  ...context,
80
78
  messages: this.formatMessagesForLog(messages)
@@ -82,10 +80,10 @@ class LLMClient {
82
80
  }, "[LLM Service] context");
83
81
  const trace = this.langfuseEnabled ? this.langfuse.trace({
84
82
  sessionId,
85
- name: taskName,
83
+ name: origin,
86
84
  userId: currentUser?.userId,
87
85
  metadata: {
88
- taskName,
86
+ origin,
89
87
  email: currentUser?.email,
90
88
  sessionId
91
89
  }
@@ -110,13 +108,13 @@ class LLMClient {
110
108
  });
111
109
  if (this.langfuseEnabled) await this.langfuse.flushAsync();
112
110
  this.logger.debug({
113
- taskName,
111
+ origin,
114
112
  response: {
115
113
  ...response,
116
114
  content: this.formatContentForLog(response?.content)
117
115
  }
118
116
  }, "[LLM Service] Response");
119
- await this.postResponse({ taskName, sessionId, answerId, currentUser, response });
117
+ await this.postResponse({ origin, sessionId, answerId, currentUser, response });
120
118
  return response;
121
119
  } catch (error) {
122
120
  generation?.end({
@@ -128,11 +126,10 @@ class LLMClient {
128
126
  }
129
127
  }
130
128
  async postResponse(params) {
131
- const { taskName, sessionId, answerId, currentUser, response } = params ?? {};
132
- const createLLMCallUseCase = import_tsyringe.container.resolve(import_create_llmcall.CreateLLMCallUseCase);
133
- await createLLMCallUseCase.execute({
129
+ const { origin, sessionId, answerId, currentUser, response } = params ?? {};
130
+ await (0, import_llmcalls.createLLMCall)({
134
131
  payload: {
135
- taskName,
132
+ origin,
136
133
  sessionId,
137
134
  answerId,
138
135
  response,
@@ -1,11 +1,9 @@
1
1
  import "../chunk-CF3WOMB3.mjs";
2
- import "reflect-metadata";
3
- import { container } from "tsyringe";
4
2
  import { Langfuse } from "langfuse";
5
3
  import { secretManager } from "../common/utils/secret-manager.js";
6
4
  import { Logger } from "../common/logger/index.js";
7
5
  import { extractJSON } from "../common/helpers/index.js";
8
- import { CreateLLMCallUseCase } from "../services/llmcalls/lambdas/create-llmcall/index.js";
6
+ import { createLLMCall } from "../services/llmcalls/index.js";
9
7
  class LLMClient {
10
8
  logger = new Logger();
11
9
  langfuse;
@@ -26,7 +24,7 @@ class LLMClient {
26
24
  async complete(params) {
27
25
  const { getModel, complete } = await import("@mariozechner/pi-ai");
28
26
  const {
29
- taskName,
27
+ origin,
30
28
  sessionId,
31
29
  answerId,
32
30
  currentUser,
@@ -42,7 +40,7 @@ class LLMClient {
42
40
  messages
43
41
  };
44
42
  this.logger.debug({
45
- taskName,
43
+ origin,
46
44
  context: {
47
45
  ...context,
48
46
  messages: this.formatMessagesForLog(messages)
@@ -50,10 +48,10 @@ class LLMClient {
50
48
  }, "[LLM Service] context");
51
49
  const trace = this.langfuseEnabled ? this.langfuse.trace({
52
50
  sessionId,
53
- name: taskName,
51
+ name: origin,
54
52
  userId: currentUser?.userId,
55
53
  metadata: {
56
- taskName,
54
+ origin,
57
55
  email: currentUser?.email,
58
56
  sessionId
59
57
  }
@@ -78,13 +76,13 @@ class LLMClient {
78
76
  });
79
77
  if (this.langfuseEnabled) await this.langfuse.flushAsync();
80
78
  this.logger.debug({
81
- taskName,
79
+ origin,
82
80
  response: {
83
81
  ...response,
84
82
  content: this.formatContentForLog(response?.content)
85
83
  }
86
84
  }, "[LLM Service] Response");
87
- await this.postResponse({ taskName, sessionId, answerId, currentUser, response });
85
+ await this.postResponse({ origin, sessionId, answerId, currentUser, response });
88
86
  return response;
89
87
  } catch (error) {
90
88
  generation?.end({
@@ -96,11 +94,10 @@ class LLMClient {
96
94
  }
97
95
  }
98
96
  async postResponse(params) {
99
- const { taskName, sessionId, answerId, currentUser, response } = params ?? {};
100
- const createLLMCallUseCase = container.resolve(CreateLLMCallUseCase);
101
- await createLLMCallUseCase.execute({
97
+ const { origin, sessionId, answerId, currentUser, response } = params ?? {};
98
+ await createLLMCall({
102
99
  payload: {
103
- taskName,
100
+ origin,
104
101
  sessionId,
105
102
  answerId,
106
103
  response,
@@ -2,7 +2,7 @@ import { ObjectId } from 'mongodb';
2
2
  import type { AssistantMessage } from '@mariozechner/pi-ai';
3
3
  import { BaseEntity, BaseEntityProps } from '../../../common/base/base.entity.js';
4
4
  export interface LLMCallProps extends BaseEntityProps {
5
- taskName?: string;
5
+ origin?: string;
6
6
  answerId?: string | ObjectId;
7
7
  sessionId?: string | ObjectId;
8
8
  costInUsd?: number;
@@ -10,14 +10,14 @@ export interface LLMCallProps extends BaseEntityProps {
10
10
  }
11
11
  export declare class LLMCall extends BaseEntity {
12
12
  private readonly props;
13
- taskName?: string | undefined;
13
+ origin?: string | undefined;
14
14
  answerId?: ObjectId | undefined;
15
15
  sessionId?: ObjectId | undefined;
16
16
  costInUsd?: number | undefined;
17
17
  response?: AssistantMessage | undefined;
18
18
  static fromJSON(props: LLMCallProps): LLMCall;
19
- constructor(props: LLMCallProps, taskName?: string | undefined, answerId?: ObjectId | undefined, sessionId?: ObjectId | undefined, costInUsd?: number | undefined, response?: AssistantMessage | undefined);
19
+ constructor(props: LLMCallProps, origin?: string | undefined, answerId?: ObjectId | undefined, sessionId?: ObjectId | undefined, costInUsd?: number | undefined, response?: AssistantMessage | undefined);
20
20
  toJSON(): LLMCallProps;
21
21
  setResponse(response: AssistantMessage): void;
22
- setTaskName(taskId: string): void;
22
+ setOrigin(origin: string): void;
23
23
  }
@@ -23,17 +23,17 @@ __export(llmcall_entity_exports, {
23
23
  module.exports = __toCommonJS(llmcall_entity_exports);
24
24
  var import_base = require("../../../common/base/base.entity.js");
25
25
  class LLMCall extends import_base.BaseEntity {
26
- constructor(props, taskName, answerId, sessionId, costInUsd, response) {
26
+ constructor(props, origin, answerId, sessionId, costInUsd, response) {
27
27
  super(props);
28
28
  this.props = props;
29
- this.taskName = taskName;
29
+ this.origin = origin;
30
30
  this.answerId = answerId;
31
31
  this.sessionId = sessionId;
32
32
  this.costInUsd = costInUsd;
33
33
  this.response = response;
34
34
  }
35
35
  props;
36
- taskName;
36
+ origin;
37
37
  answerId;
38
38
  sessionId;
39
39
  costInUsd;
@@ -41,7 +41,7 @@ class LLMCall extends import_base.BaseEntity {
41
41
  static fromJSON(props) {
42
42
  return new LLMCall(
43
43
  props,
44
- props.taskName || void 0,
44
+ props.origin || void 0,
45
45
  import_base.BaseEntity.toObjectId(props.answerId),
46
46
  import_base.BaseEntity.toObjectId(props.sessionId),
47
47
  props.costInUsd ? Number(props.costInUsd) : void 0,
@@ -51,7 +51,7 @@ class LLMCall extends import_base.BaseEntity {
51
51
  toJSON() {
52
52
  return {
53
53
  ...super.toJSON(),
54
- taskName: this.taskName,
54
+ origin: this.origin,
55
55
  answerId: this.answerId,
56
56
  sessionId: this.sessionId,
57
57
  costInUsd: this.costInUsd,
@@ -61,8 +61,8 @@ class LLMCall extends import_base.BaseEntity {
61
61
  setResponse(response) {
62
62
  this.response = response;
63
63
  }
64
- setTaskName(taskId) {
65
- this.taskName = taskId;
64
+ setOrigin(origin) {
65
+ this.origin = origin;
66
66
  }
67
67
  }
68
68
  // Annotate the CommonJS export names for ESM import in node:
@@ -1,17 +1,17 @@
1
1
  import "../../../chunk-CF3WOMB3.mjs";
2
2
  import { BaseEntity } from "../../../common/base/base.entity.js";
3
3
  class LLMCall extends BaseEntity {
4
- constructor(props, taskName, answerId, sessionId, costInUsd, response) {
4
+ constructor(props, origin, answerId, sessionId, costInUsd, response) {
5
5
  super(props);
6
6
  this.props = props;
7
- this.taskName = taskName;
7
+ this.origin = origin;
8
8
  this.answerId = answerId;
9
9
  this.sessionId = sessionId;
10
10
  this.costInUsd = costInUsd;
11
11
  this.response = response;
12
12
  }
13
13
  props;
14
- taskName;
14
+ origin;
15
15
  answerId;
16
16
  sessionId;
17
17
  costInUsd;
@@ -19,7 +19,7 @@ class LLMCall extends BaseEntity {
19
19
  static fromJSON(props) {
20
20
  return new LLMCall(
21
21
  props,
22
- props.taskName || void 0,
22
+ props.origin || void 0,
23
23
  BaseEntity.toObjectId(props.answerId),
24
24
  BaseEntity.toObjectId(props.sessionId),
25
25
  props.costInUsd ? Number(props.costInUsd) : void 0,
@@ -29,7 +29,7 @@ class LLMCall extends BaseEntity {
29
29
  toJSON() {
30
30
  return {
31
31
  ...super.toJSON(),
32
- taskName: this.taskName,
32
+ origin: this.origin,
33
33
  answerId: this.answerId,
34
34
  sessionId: this.sessionId,
35
35
  costInUsd: this.costInUsd,
@@ -39,8 +39,8 @@ class LLMCall extends BaseEntity {
39
39
  setResponse(response) {
40
40
  this.response = response;
41
41
  }
42
- setTaskName(taskId) {
43
- this.taskName = taskId;
42
+ setOrigin(origin) {
43
+ this.origin = origin;
44
44
  }
45
45
  }
46
46
  export {
@@ -1,3 +1,5 @@
1
1
  import 'reflect-metadata';
2
2
  import { Params as LParams, Output as LOutput } from './lambdas/get-llm-usage';
3
+ import { Params as CParams, Output as COutput } from './lambdas/create-llmcall';
3
4
  export declare function getLLMUsage(props: LParams): Promise<LOutput>;
5
+ export declare function createLLMCall(props: CParams): Promise<COutput>;
@@ -18,17 +18,24 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var module_exports = {};
20
20
  __export(module_exports, {
21
+ createLLMCall: () => createLLMCall,
21
22
  getLLMUsage: () => getLLMUsage
22
23
  });
23
24
  module.exports = __toCommonJS(module_exports);
24
25
  var import_reflect_metadata = require("reflect-metadata");
25
26
  var import_tsyringe = require("tsyringe");
26
27
  var import_get_llm_usage = require("./lambdas/get-llm-usage");
28
+ var import_create_llmcall = require("./lambdas/create-llmcall");
27
29
  async function getLLMUsage(props) {
28
30
  const getLLMUsageUseCase = import_tsyringe.container.resolve(import_get_llm_usage.GetLLMUsageUseCase);
29
31
  return getLLMUsageUseCase.execute(props);
30
32
  }
33
+ async function createLLMCall(props) {
34
+ const createLLMCall2 = import_tsyringe.container.resolve(import_create_llmcall.CreateLLMCallUseCase);
35
+ return createLLMCall2.execute(props);
36
+ }
31
37
  // Annotate the CommonJS export names for ESM import in node:
32
38
  0 && (module.exports = {
39
+ createLLMCall,
33
40
  getLLMUsage
34
41
  });
@@ -2,10 +2,16 @@ import "../../chunk-CF3WOMB3.mjs";
2
2
  import "reflect-metadata";
3
3
  import { container } from "tsyringe";
4
4
  import { GetLLMUsageUseCase } from "./lambdas/get-llm-usage";
5
+ import { CreateLLMCallUseCase } from "./lambdas/create-llmcall";
5
6
  async function getLLMUsage(props) {
6
7
  const getLLMUsageUseCase = container.resolve(GetLLMUsageUseCase);
7
8
  return getLLMUsageUseCase.execute(props);
8
9
  }
10
+ async function createLLMCall(props) {
11
+ const createLLMCall2 = container.resolve(CreateLLMCallUseCase);
12
+ return createLLMCall2.execute(props);
13
+ }
9
14
  export {
15
+ createLLMCall,
10
16
  getLLMUsage
11
17
  };
@@ -86,7 +86,7 @@ let SkillRunner = class {
86
86
  const response = await this.llmClient.complete({
87
87
  sessionId,
88
88
  answerId,
89
- taskName: skill.name,
89
+ origin: skill.name,
90
90
  currentUser,
91
91
  messages: [
92
92
  {
@@ -58,7 +58,7 @@ let SkillRunner = class {
58
58
  const response = await this.llmClient.complete({
59
59
  sessionId,
60
60
  answerId,
61
- taskName: skill.name,
61
+ origin: skill.name,
62
62
  currentUser,
63
63
  messages: [
64
64
  {
@@ -90,7 +90,7 @@ class Skill {
90
90
  const response = await llmClient.complete({
91
91
  sessionId,
92
92
  answerId,
93
- taskName: this.name,
93
+ origin: this.name,
94
94
  currentUser,
95
95
  messages: [
96
96
  {
@@ -68,7 +68,7 @@ class Skill {
68
68
  const response = await llmClient.complete({
69
69
  sessionId,
70
70
  answerId,
71
- taskName: this.name,
71
+ origin: this.name,
72
72
  currentUser,
73
73
  messages: [
74
74
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openloops",
3
- "version": "0.1.22",
3
+ "version": "0.1.23",
4
4
  "description": "Framework to build AI Agents",
5
5
  "author": {
6
6
  "name": "Jose Barcos",