@mastra/core 0.1.27-alpha.75 → 0.1.27-alpha.76

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/core.esm.js CHANGED
@@ -557,7 +557,11 @@ var LLM = (_model = /*#__PURE__*/_classPrivateFieldLooseKey("model"), /*#__PURE_
557
557
  this.log(LogLevel.DEBUG, "Initializing Azure model " + (model.name || 'gpt-35-turbo-instruct'));
558
558
  var azure = createAzure({
559
559
  resourceName: process.env.AZURE_RESOURCE_NAME || '',
560
- apiKey: (model == null ? void 0 : model.apiKey) || process.env.AZURE_API_KEY || ''
560
+ apiKey: (model == null ? void 0 : model.apiKey) || process.env.AZURE_API_KEY || '',
561
+ apiVersion: model == null ? void 0 : model.apiVersion,
562
+ baseURL: model == null ? void 0 : model.baseURL,
563
+ headers: model == null ? void 0 : model.headers,
564
+ fetch: model == null ? void 0 : model.fetch
561
565
  });
562
566
  modelDef = azure(model.name || 'gpt-35-turbo-instruct');
563
567
  } else if (model.type === 'amazon') {
@@ -824,14 +828,7 @@ var LLM = (_model = /*#__PURE__*/_classPrivateFieldLooseKey("model"), /*#__PURE_
824
828
  tools: Object.keys(tools || convertedTools || {})
825
829
  });
826
830
  if ('name' in model) {
827
- modelToPass = {
828
- type: this.getModelType(),
829
- name: model.name,
830
- toolChoice: model.toolChoice,
831
- apiKey: model.provider !== 'LM_STUDIO' ? model == null ? void 0 : model.apiKey : undefined,
832
- baseURL: model.provider === 'LM_STUDIO' ? model.baseURL : undefined,
833
- fetch: model.provider === 'BASETEN' ? model.fetch : undefined
834
- };
831
+ modelToPass = this.__getNamedModel();
835
832
  } else {
836
833
  modelToPass = model;
837
834
  }
@@ -901,6 +898,21 @@ var LLM = (_model = /*#__PURE__*/_classPrivateFieldLooseKey("model"), /*#__PURE_
901
898
  }
902
899
  return __text;
903
900
  }();
901
+ _proto.__getNamedModel = function __getNamedModel() {
902
+ var model = _classPrivateFieldLooseBase(this, _model)[_model];
903
+ if (!('name' in model)) {
904
+ throw new Error('Model name is required');
905
+ }
906
+ return {
907
+ type: this.getModelType(),
908
+ name: model.name,
909
+ toolChoice: model.toolChoice,
910
+ apiKey: model == null ? void 0 : model.apiKey,
911
+ baseURL: model == null ? void 0 : model.baseURL,
912
+ headers: model == null ? void 0 : model.headers,
913
+ fetch: model == null ? void 0 : model.fetch
914
+ };
915
+ };
904
916
  _proto.__textObject = /*#__PURE__*/function () {
905
917
  var _textObject = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(_ref9) {
906
918
  var _this4 = this;
@@ -914,14 +926,7 @@ var LLM = (_model = /*#__PURE__*/_classPrivateFieldLooseKey("model"), /*#__PURE_
914
926
  runId: runId
915
927
  });
916
928
  if ('name' in model) {
917
- modelToPass = {
918
- type: this.getModelType(),
919
- name: model.name,
920
- toolChoice: model.toolChoice,
921
- apiKey: model.provider !== 'LM_STUDIO' ? model == null ? void 0 : model.apiKey : undefined,
922
- baseURL: model.provider === 'LM_STUDIO' ? model.baseURL : undefined,
923
- fetch: model.provider === 'BASETEN' ? model.fetch : undefined
924
- };
929
+ modelToPass = this.__getNamedModel();
925
930
  } else {
926
931
  modelToPass = model;
927
932
  }
@@ -1017,14 +1022,7 @@ var LLM = (_model = /*#__PURE__*/_classPrivateFieldLooseKey("model"), /*#__PURE_
1017
1022
  runId: runId
1018
1023
  });
1019
1024
  if ('name' in model) {
1020
- modelToPass = {
1021
- type: this.getModelType(),
1022
- name: model.name,
1023
- toolChoice: model.toolChoice,
1024
- apiKey: model.provider !== 'LM_STUDIO' ? model == null ? void 0 : model.apiKey : undefined,
1025
- baseURL: model.provider === 'LM_STUDIO' ? model.baseURL : undefined,
1026
- fetch: model.provider === 'BASETEN' ? model.fetch : undefined
1027
- };
1025
+ modelToPass = this.__getNamedModel();
1028
1026
  } else {
1029
1027
  modelToPass = model;
1030
1028
  }
@@ -1132,14 +1130,7 @@ var LLM = (_model = /*#__PURE__*/_classPrivateFieldLooseKey("model"), /*#__PURE_
1132
1130
  runId: runId
1133
1131
  });
1134
1132
  if ('name' in model) {
1135
- modelToPass = {
1136
- type: this.getModelType(),
1137
- name: model.name,
1138
- toolChoice: model.toolChoice,
1139
- apiKey: model.provider !== 'LM_STUDIO' ? model == null ? void 0 : model.apiKey : undefined,
1140
- baseURL: model.provider === 'LM_STUDIO' ? model.baseURL : undefined,
1141
- fetch: model.provider === 'BASETEN' ? model.fetch : undefined
1142
- };
1133
+ modelToPass = this.__getNamedModel();
1143
1134
  } else {
1144
1135
  modelToPass = model;
1145
1136
  }
@@ -4009,13 +4000,13 @@ var MastraMemory = /*#__PURE__*/function (_MastraBase) {
4009
4000
 
4010
4001
  // Cohere implementation
4011
4002
  var CohereRelevanceScorer = /*#__PURE__*/function () {
4012
- function CohereRelevanceScorer(apiKey, model) {
4003
+ function CohereRelevanceScorer(model, apiKey) {
4013
4004
  this.client = void 0;
4014
4005
  this.model = void 0;
4015
4006
  this.client = new CohereClient({
4016
- token: apiKey
4007
+ token: apiKey || process.env.COHERE_API_KEY || ''
4017
4008
  });
4018
- this.model = model || 'rerank-v3.5';
4009
+ this.model = model;
4019
4010
  }
4020
4011
  var _proto = CohereRelevanceScorer.prototype;
4021
4012
  _proto.getRelevanceScore = /*#__PURE__*/function () {
@@ -4055,12 +4046,15 @@ function createSimilarityPrompt(query, text) {
4055
4046
 
4056
4047
  // Mastra Agent implementation
4057
4048
  var MastraAgentRelevanceScorer = /*#__PURE__*/function () {
4058
- function MastraAgentRelevanceScorer(provider, name) {
4049
+ function MastraAgentRelevanceScorer(provider, name, model) {
4059
4050
  this.agent = void 0;
4060
- var modelConfig = {
4061
- provider: provider,
4051
+ var modelConfig = _extends({
4052
+ provider: provider
4053
+ }, model ? {
4054
+ model: model
4055
+ } : {
4062
4056
  name: name
4063
- };
4057
+ });
4064
4058
  this.agent = new Agent({
4065
4059
  name: "Relevance Scorer " + provider + " " + name,
4066
4060
  instructions: "You are a specialized agent for evaluating the relevance of text to queries.\nYour task is to rate how well a text passage answers a given query.\nOutput only a number between 0 and 1, where:\n1.0 = Perfectly relevant, directly answers the query\n0.0 = Completely irrelevant\nConsider:\n- Direct relevance to the question\n- Completeness of information\n- Quality and specificity\nAlways return just the number, no explanation.",