mirror of
https://github.com/google-gemini/gemini-cli
synced 2026-04-21 13:37:17 +00:00
feat: add option to disable streaming in CLI
This commit is contained in:
parent
1c963345a4
commit
d6a1864961
4 changed files with 31 additions and 1 deletions
|
|
@ -80,6 +80,7 @@ export interface CliArgs {
|
|||
model: string | undefined;
|
||||
sandbox: boolean | string | undefined;
|
||||
debug: boolean | undefined;
|
||||
disableStreaming?: boolean;
|
||||
prompt: string | undefined;
|
||||
promptInteractive: string | undefined;
|
||||
worktree?: string;
|
||||
|
|
@ -421,6 +422,10 @@ export async function parseArguments(
|
|||
type: 'boolean',
|
||||
description: 'Enable screen reader mode for accessibility.',
|
||||
})
|
||||
.option('disable-streaming', {
|
||||
type: 'boolean',
|
||||
description: 'Disable streaming responses from the model',
|
||||
})
|
||||
.option('output-format', {
|
||||
alias: 'o',
|
||||
type: 'string',
|
||||
|
|
@ -918,6 +923,7 @@ export async function loadCliConfig(
|
|||
return new Config({
|
||||
acpMode: isAcpMode,
|
||||
clientName,
|
||||
disableStreaming: argv.disableStreaming,
|
||||
sessionId,
|
||||
clientVersion: await getVersion(),
|
||||
embeddingModel: DEFAULT_GEMINI_EMBEDDING_MODEL,
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ export class UserSimulator {
|
|||
}
|
||||
this.interactionsFile = `interactions_${Date.now()}.txt`;
|
||||
this.isRunning = true;
|
||||
this.timer = setInterval(() => this.tick(), 3000);
|
||||
this.timer = setInterval(() => this.tick(), 1000);
|
||||
}
|
||||
|
||||
stop() {
|
||||
|
|
|
|||
|
|
@ -626,6 +626,7 @@ export interface ConfigParameters {
|
|||
bugCommand?: BugCommandSettings;
|
||||
model: string;
|
||||
disableLoopDetection?: boolean;
|
||||
disableStreaming?: boolean;
|
||||
maxSessionTurns?: number;
|
||||
acpMode?: boolean;
|
||||
listSessions?: boolean;
|
||||
|
|
@ -962,6 +963,7 @@ export class Config implements McpContext, AgentLoopContext {
|
|||
private approvedPlanPath: string | undefined;
|
||||
private readonly simulateUser: boolean;
|
||||
private readonly knowledgeSource?: string;
|
||||
private readonly disableStreaming: boolean;
|
||||
|
||||
constructor(params: ConfigParameters) {
|
||||
this._sessionId = params.sessionId;
|
||||
|
|
@ -1284,6 +1286,7 @@ export class Config implements McpContext, AgentLoopContext {
|
|||
this.enableConseca = params.enableConseca ?? false;
|
||||
this.simulateUser = params.simulateUser ?? false;
|
||||
this.knowledgeSource = params.knowledgeSource;
|
||||
this.disableStreaming = params.disableStreaming ?? false;
|
||||
|
||||
// Initialize Safety Infrastructure
|
||||
const contextBuilder = new ContextBuilder(this);
|
||||
|
|
@ -2880,6 +2883,10 @@ export class Config implements McpContext, AgentLoopContext {
|
|||
return this.simulateUser;
|
||||
}
|
||||
|
||||
getDisableStreaming(): boolean {
|
||||
return this.disableStreaming;
|
||||
}
|
||||
|
||||
getKnowledgeSource(): string | undefined {
|
||||
return this.knowledgeSource;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -656,6 +656,23 @@ export class GeminiChat {
|
|||
lastConfig = config;
|
||||
lastContentsToUse = contentsToUse;
|
||||
|
||||
if (this.context.config.getDisableStreaming()) {
|
||||
const response = await this.context.config
|
||||
.getContentGenerator()
|
||||
.generateContent(
|
||||
{
|
||||
model: modelToUse,
|
||||
contents: contentsToUse,
|
||||
config,
|
||||
},
|
||||
prompt_id,
|
||||
role,
|
||||
);
|
||||
return (async function* () {
|
||||
yield response;
|
||||
})();
|
||||
}
|
||||
|
||||
return this.context.config.getContentGenerator().generateContentStream(
|
||||
{
|
||||
model: modelToUse,
|
||||
|
|
|
|||
Loading…
Reference in a new issue