Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: disable streaming for o1 #3723

Merged
merged 2 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions core/llm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { logDevData } from "../util/devdata.js";
import { DevDataSqliteDb } from "../util/devdataSqlite.js";
import mergeJson from "../util/merge.js";
import { renderChatMessage } from "../util/messageContent.js";
import { isOllamaInstalled } from "../util/ollamaHelper.js";
import { Telemetry } from "../util/posthog.js";
import { withExponentialBackoff } from "../util/withExponentialBackoff.js";

Expand Down Expand Up @@ -55,7 +56,6 @@ import {
toCompleteBody,
toFimBody,
} from "./openaiTypeConverters.js";
import { isOllamaInstalled } from "../util/ollamaHelper.js";

export abstract class BaseLLM implements ILLM {
static providerName: string;
Expand Down Expand Up @@ -415,10 +415,9 @@ export abstract class BaseLLM implements ILLM {
e.code === "ECONNREFUSED" &&
e.message.includes("http://127.0.0.1:11434")
) {
const message = (await isOllamaInstalled()) ?
"Unable to connect to local Ollama instance. Ollama may not be running." :
"Unable to connect to local Ollama instance. Ollama may not be installed or may not running."
;
const message = (await isOllamaInstalled())
? "Unable to connect to local Ollama instance. Ollama may not be running."
: "Unable to connect to local Ollama instance. Ollama may not be installed or may not running.";
throw new Error(message);
}
}
Expand Down Expand Up @@ -693,13 +692,28 @@ export abstract class BaseLLM implements ILLM {
return body;
}

private _modifyCompletionOptions(
completionOptions: CompletionOptions,
): CompletionOptions {
// As of 01/14/25 streaming is currently not available with o1
// See these threads:
// - https://github.com/continuedev/continue/issues/3698
// - https://community.openai.com/t/streaming-support-for-o1-o1-2024-12-17-resulting-in-400-unsupported-value/1085043
if (completionOptions.model === "o1") {
completionOptions.stream = false;
}

return completionOptions;
}

async *streamChat(
_messages: ChatMessage[],
signal: AbortSignal,
options: LLMFullCompletionOptions = {},
): AsyncGenerator<ChatMessage, PromptLog> {
const { completionOptions, log, raw } =
this._parseCompletionOptions(options);
let { completionOptions, log } = this._parseCompletionOptions(options);

completionOptions = this._modifyCompletionOptions(completionOptions);

const messages = this._compileChatMessages(completionOptions, _messages);

Expand Down
1 change: 0 additions & 1 deletion gui/src/hooks/useSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ function useSetup() {
if (result.status === "error") {
return;
}
console.log("Config loaded", result.content);
await handleConfigUpdate(initial, result.content);
},
[ideMessenger, handleConfigUpdate],
Expand Down
Loading