Skip to content

Commit

Permalink
fix: case when no gpt llm
Browse files Browse the repository at this point in the history
  • Loading branch information
himself65 committed Apr 7, 2024
1 parent 130556c commit 4e4d6ce
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/core/src/agent/openai/base.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Settings } from "../../Settings.js";
import type { ChatMessage } from "../../llm/index.js";
import { OpenAI } from "../../llm/index.js";
import type { ObjectRetriever } from "../../objects/base.js";
Expand Down Expand Up @@ -32,7 +33,14 @@ export class OpenAIAgent extends AgentRunner {
toolRetriever,
systemPrompt,
}: OpenAIAgentParams) {
llm = llm ?? new OpenAI({ model: "gpt-3.5-turbo-0613" });
if (!llm) {
if (Settings.llm instanceof OpenAI) {
llm = Settings.llm;
} else {
console.warn("No OpenAI model provided, creating a new one");
llm = new OpenAI({ model: "gpt-3.5-turbo-0613" });
}
}

if (systemPrompt) {
if (prefixMessages) {
Expand Down

0 comments on commit 4e4d6ce

Please sign in to comment.