Skip to content

Commit

Permalink
[Typescript][Callbacks][2/n] Add CallbackManager to AIConfigRuntime
Browse files Browse the repository at this point in the history
  • Loading branch information
Ankush Pala [email protected] committed Nov 14, 2023
1 parent 8dab0fb commit bf2de0c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions typescript/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { ParameterizedModelParser } from "./parameterizedModelParser";
import { OpenAIChatModelParser, OpenAIModelParser } from "./parsers/openai";
import { extractOverrideSettings } from "./utils";
import { HuggingFaceTextGenerationParser } from "./parsers/hf";
import { CallbackManager } from "./callback";

export type PromptWithOutputs = Prompt & { outputs?: Output[] };

Expand Down Expand Up @@ -73,6 +74,7 @@ export class AIConfigRuntime implements AIConfig {
prompts: PromptWithOutputs[];

filePath?: string;
callbackManager: CallbackManager = CallbackManager.createManagerWithLogging();

public constructor(
name: string,
Expand Down Expand Up @@ -211,8 +213,8 @@ export class AIConfigRuntime implements AIConfig {
* @param saveOptions Options that determine how to save the AIConfig to the file.
*/
public save(filePath?: string, saveOptions?: SaveOptions) {
const keysToOmit = ['filePath'] as const;
const keysToOmit = ["filePath", "callbackManager"] as const;

try {
// Create a Deep Copy and omit fields that should not be saved
const aiConfigObj: Omit<AIConfigRuntime, typeof keysToOmit[number]> = _.omit(_.cloneDeep(this), keysToOmit)
Expand Down Expand Up @@ -412,6 +414,10 @@ export class AIConfigRuntime implements AIConfig {
return result;
}

public setCallbackManager(callbackManager: CallbackManager) {
this.callbackManager = callbackManager;
}

//#endregion

//#region CRUD operations for AIConfig properties
Expand Down

0 comments on commit bf2de0c

Please sign in to comment.