Skip to content

Commit

Permalink
chore: lint files
Browse files Browse the repository at this point in the history
  • Loading branch information
bracesproul committed Oct 16, 2023
1 parent ac4de4e commit 12cc475
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions langchain/src/agents/openai/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,20 +232,28 @@ export class OpenAIAgent extends Agent {
newInputs.stop = this._stop();
}

// Split inputs between prompt and llm
const llm = this.runnable.llm as ChatOpenAI;
let llm: ChatOpenAI;
let prompt: BasePromptTemplate;
// eslint-disable-next-line no-instanceof/no-instanceof
if (this.runnable instanceof LLMChain) {
llm = this.runnable.llm;
prompt = this.runnable.prompt;
} else {
throw new Error("Must pass an LLMChain to an OpenAIAgent");
}

const valuesForPrompt = { ...newInputs };
const valuesForLLM: (typeof llm)["CallOptions"] = {
tools: this.tools,
};
for (const key of this.llmChain.llm.callKeys) {
for (const key of llm.callKeys) {
if (key in inputs) {
valuesForLLM[key as keyof (typeof llm)["CallOptions"]] = inputs[key];
delete valuesForPrompt[key];
}
}

const promptValue = await this.llmChain.prompt.formatPromptValue(
const promptValue = await prompt.formatPromptValue(
valuesForPrompt
);
const message = await llm.predictMessages(
Expand Down

0 comments on commit 12cc475

Please sign in to comment.