-
Notifications
You must be signed in to change notification settings - Fork 275
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
import { generateText, generateObject, jsonSchema, streamText, streamObject } from 'ai'; | ||
import type { LanguageModel, Schema, CoreMessage } from 'ai'; | ||
import type { CoreMessage, LanguageModel, Schema } from 'ai'; | ||
import { generateObject, generateText, jsonSchema, streamObject, streamText } from 'ai'; | ||
import type { JSONSchema7 } from 'json-schema'; | ||
import { z } from 'zod'; | ||
import type { ZodSchema } from 'zod'; | ||
import { z } from 'zod'; | ||
|
||
import type { | ||
GenerateReturn, | ||
LLMTextOptions, | ||
LLMInnerStreamOptions, | ||
LLMStreamObjectOptions, | ||
LLMStreamOptions, | ||
LLMTextObjectOptions, | ||
LLMTextOptions, | ||
StreamReturn, | ||
} from '../'; | ||
import type { MastraPrimitives } from '../../action'; | ||
|
@@ -114,6 +114,7 @@ export class MastraLLM extends MastraLLMBase { | |
temperature, | ||
toolChoice = 'auto', | ||
onStepFinish, | ||
telemetryOptions, | ||
}: LLMTextOptions) { | ||
const model = this.#model; | ||
|
||
|
@@ -159,7 +160,10 @@ export class MastraLLM extends MastraLLMBase { | |
return await generateText({ | ||
Check failure on line 160 in packages/core/src/llm/model/model.ts
|
||
messages, | ||
...argsForExecute, | ||
experimental_telemetry: this.experimental_telemetry, | ||
experimental_telemetry: { | ||
...this.experimental_telemetry, | ||
...telemetryOptions, | ||
}, | ||
}); | ||
} | ||
|
||
|
@@ -173,6 +177,7 @@ export class MastraLLM extends MastraLLMBase { | |
runId, | ||
temperature, | ||
toolChoice = 'auto', | ||
telemetryOptions, | ||
}: LLMTextObjectOptions<T>) { | ||
const model = this.#model; | ||
|
||
|
@@ -228,7 +233,10 @@ export class MastraLLM extends MastraLLMBase { | |
...argsForExecute, | ||
output: output as any, | ||
schema, | ||
experimental_telemetry: this.experimental_telemetry, | ||
experimental_telemetry: { | ||
...this.experimental_telemetry, | ||
...telemetryOptions, | ||
}, | ||
}); | ||
} | ||
|
||
|
@@ -242,6 +250,7 @@ export class MastraLLM extends MastraLLMBase { | |
runId, | ||
temperature, | ||
toolChoice = 'auto', | ||
telemetryOptions, | ||
}: LLMInnerStreamOptions) { | ||
const model = this.#model; | ||
this.logger.debug(`[LLM] - Streaming text`, { | ||
|
@@ -298,7 +307,10 @@ export class MastraLLM extends MastraLLMBase { | |
return await streamText({ | ||
messages, | ||
...argsForExecute, | ||
experimental_telemetry: this.experimental_telemetry, | ||
experimental_telemetry: { | ||
...this.experimental_telemetry, | ||
...telemetryOptions, | ||
}, | ||
}); | ||
} | ||
|
||
|
@@ -313,6 +325,7 @@ export class MastraLLM extends MastraLLMBase { | |
runId, | ||
temperature, | ||
toolChoice = 'auto', | ||
telemetryOptions, | ||
}: LLMStreamObjectOptions<T>) { | ||
const model = this.#model; | ||
this.logger.debug(`[LLM] - Streaming structured output`, { | ||
|
@@ -384,7 +397,10 @@ export class MastraLLM extends MastraLLMBase { | |
...argsForExecute, | ||
output: output as any, | ||
schema, | ||
experimental_telemetry: this.experimental_telemetry, | ||
experimental_telemetry: { | ||
...this.experimental_telemetry, | ||
...telemetryOptions, | ||
}, | ||
}); | ||
} | ||
|
||
|
@@ -398,6 +414,7 @@ export class MastraLLM extends MastraLLMBase { | |
runId, | ||
output = 'text', | ||
temperature, | ||
telemetryOptions, | ||
}: LLMStreamOptions<Z> = {}, | ||
): Promise<GenerateReturn<Z>> { | ||
const msgs = this.convertToMessages(messages); | ||
|
@@ -422,6 +439,7 @@ export class MastraLLM extends MastraLLMBase { | |
tools, | ||
convertedTools, | ||
runId, | ||
telemetryOptions, | ||
})) as unknown as GenerateReturn<Z>; | ||
} | ||
|
||
|
@@ -436,6 +454,7 @@ export class MastraLLM extends MastraLLMBase { | |
runId, | ||
output = 'text', | ||
temperature, | ||
telemetryOptions, | ||
}: LLMStreamOptions<Z> = {}, | ||
) { | ||
const msgs = this.convertToMessages(messages); | ||
|
@@ -450,6 +469,7 @@ export class MastraLLM extends MastraLLMBase { | |
convertedTools, | ||
runId, | ||
temperature, | ||
telemetryOptions, | ||
})) as unknown as StreamReturn<Z>; | ||
} | ||
|
||
|
@@ -463,6 +483,7 @@ export class MastraLLM extends MastraLLMBase { | |
convertedTools, | ||
runId, | ||
temperature, | ||
telemetryOptions, | ||
})) as unknown as StreamReturn<Z>; | ||
} | ||
} |