Skip to content
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
21 changes: 11 additions & 10 deletions multimodal/omni-tars/gui-agent/src/GuiAgentPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class GuiAgentPlugin extends AgentPlugin {
readonly environmentSection = COMPUTER_USE_ENVIRONMENT;
private agentMode?: AgentMode;
private operatorManager: OperatorManager;
private initializedWithMode = false;

constructor(option: GuiAgentPluginOption) {
super();
Expand All @@ -36,10 +37,11 @@ export class GuiAgentPlugin extends AgentPlugin {
}

async initialize(): Promise<void> {
if (this.agentMode && this.agentMode.id === 'game') {
if (this.agentMode && this.agentMode.id === 'game' && !this.initializedWithMode) {
await this.emitPresetUserQuey();
await this.emitScreenshotEvent();
await this.emitPresetAssistantMessage();
this.initializedWithMode = true;
}

this.agent.registerTool(
Expand Down Expand Up @@ -109,7 +111,7 @@ export class GuiAgentPlugin extends AgentPlugin {
if (interval > 0) await sleep(interval);
const output = await operator?.doScreenshot();
if (!output?.base64) {
guiLogger.error('Failed to get screenshot');
guiLogger.error('emitScreenshotEvent: Failed to get screenshot');
return;
}
const base64Tool = new Base64ImageParser(output.base64);
Expand All @@ -126,7 +128,7 @@ export class GuiAgentPlugin extends AgentPlugin {
const compressedSize = compressedBuffer.byteLength;
const compressionRatio = (((originalSize - compressedSize) / originalSize) * 100).toFixed(2);

guiLogger.debug(`compression stat: `, {
guiLogger.debug(`emitScreenshotEvent compression stat: `, {
originalSize: formatBytes(originalSize),
compressedSize: formatBytes(compressedSize),
compressionRatio: `${compressionRatio}% reduction`,
Expand All @@ -150,7 +152,7 @@ export class GuiAgentPlugin extends AgentPlugin {

const eventStream = this.agent.getEventStream();
const events = eventStream.getEvents();
guiLogger.info('onAfterToolCall events length:', events.length);
guiLogger.info('emitScreenshotEvent events length:', events.length);

const event = eventStream.createEvent('environment_input', {
description: 'Browser Screenshot',
Expand All @@ -177,11 +179,10 @@ export class GuiAgentPlugin extends AgentPlugin {
private async emitPresetAssistantMessage(): Promise<void> {
const eventStream = this.agent.getEventStream();
const events = eventStream.getEvents();
if (events.length === 0) {
const event = eventStream.createEvent('assistant_message', {
content: `Successfully navigated to ${this.agentMode!.link}, page loaded successfully`,
});
eventStream.sendEvent(event);
}
guiLogger.debug('emitPresetAssistantMessage events length:', events.length);
const event = eventStream.createEvent('assistant_message', {
content: `Successfully navigated to ${this.agentMode!.link}, page loaded completely`,
});
eventStream.sendEvent(event);
}
}
10 changes: 5 additions & 5 deletions multimodal/omni-tars/omni-agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default class OmniTARSAgent extends ComposableAgent {
{
title: 'Four in a Row',
category: 'Game',
prompt: `Play this game, win the computer`,
// prompt: `Play this game, win the computer`,
image:
'https://img.poki-cdn.com/cdn-cgi/image/q=78,scq=50,width=80,height=80,fit=cover,f=auto/e80686db-b0fb-4f2c-bd2f-3a89734f102a/four-in-a-row.jpg',
agentOptions: {
Expand All @@ -49,7 +49,7 @@ export default class OmniTARSAgent extends ComposableAgent {
{
title: 'Block the Pig',
category: 'Game',
prompt: `Play this game, reach level 5`,
// prompt: `Play this game, reach level 5`,
image:
'https://img.poki-cdn.com/cdn-cgi/image/q=78,scq=50,width=80,height=80,fit=cover,f=auto/9fec1234ce2afd5e789f56da463dcffc/block-the-pig.jpeg',
agentOptions: {
Expand All @@ -63,7 +63,7 @@ export default class OmniTARSAgent extends ComposableAgent {
{
title: 'Factory Balls Forever',
category: 'Game',
prompt: `Play this game, reach level 5`,
// prompt: `Play this game, reach level 5`,
image:
'https://img.poki-cdn.com/cdn-cgi/image/q=78,scq=50,width=80,height=80,fit=cover,f=auto/2a503d0a1d9475d6e62c7ea11caa429ab952aa8f500755613a34e66e2196fe82/factory-balls-forever.png',
agentOptions: {
Expand All @@ -77,7 +77,7 @@ export default class OmniTARSAgent extends ComposableAgent {
{
title: 'Snake Solver',
category: 'Game',
prompt: `Play this game, reach level 5`,
// prompt: `Play this game, reach level 5`,
image:
'https://img.poki-cdn.com/cdn-cgi/image/q=78,scq=50,width=80,height=80,fit=cover,f=auto/e466baf845544ef47e0dfbd60f127071/snake-solver.png',
agentOptions: {
Expand All @@ -91,7 +91,7 @@ export default class OmniTARSAgent extends ComposableAgent {
{
title: 'Penalty Kicks',
category: 'Game',
prompt: `Play this game, your target score is 600`,
// prompt: `Play this game, your target score is 600`,
image:
'https://img.poki-cdn.com/cdn-cgi/image/q=78,scq=50,width=80,height=80,fit=cover,f=auto/0770daaa8c4ff3c36dd53e6e41f59396/penalty-kicks.png',
agentOptions: {
Expand Down
Loading