-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jan
committed
Sep 2, 2024
1 parent
437d703
commit 8e7ab02
Showing
6 changed files
with
296 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import 'dart:convert'; | ||
import 'package:lite_agent_core_dart/lite_agent_core.dart'; | ||
import 'package:opentool_dart/opentool_dart.dart'; | ||
|
||
void listen(AgentMessageDto agentMessageDto) { | ||
String system = "🖥SYSTEM"; | ||
String user = "👤USER"; | ||
String agent = "🤖AGENT"; | ||
String llm = "💡LLM"; | ||
String tool = "🔧TOOL"; | ||
String client = "🔗CLIENT"; | ||
|
||
String message = ""; | ||
if (agentMessageDto.type == ToolMessageType.TEXT) | ||
message = agentMessageDto.message as String; | ||
if (agentMessageDto.type == ToolMessageType.IMAGE_URL) | ||
message = agentMessageDto.message as String; | ||
if (agentMessageDto.type == ToolMessageType.FUNCTION_CALL_LIST) { | ||
List<dynamic> originalFunctionCallList = | ||
agentMessageDto.message as List<dynamic>; | ||
List<FunctionCall> functionCallList = | ||
originalFunctionCallList.map((dynamic json) { | ||
return FunctionCall.fromJson(json); | ||
}).toList(); | ||
message = jsonEncode(functionCallList); | ||
} | ||
if (agentMessageDto.type == ToolMessageType.TOOL_RETURN) { | ||
message = jsonEncode(ToolReturn.fromJson(agentMessageDto.message)); | ||
} | ||
; | ||
|
||
String from = ""; | ||
if (agentMessageDto.from == ToolRoleType.SYSTEM) { | ||
from = system; | ||
message = "\n$message"; | ||
} | ||
if (agentMessageDto.from == ToolRoleType.USER) from = user; | ||
if (agentMessageDto.from == ToolRoleType.AGENT) from = agent; | ||
if (agentMessageDto.from == ToolRoleType.LLM) from = llm; | ||
if (agentMessageDto.from == ToolRoleType.TOOL) from = tool; | ||
if (agentMessageDto.from == ToolRoleType.CLIENT) from = client; | ||
|
||
String to = ""; | ||
if (agentMessageDto.to == ToolRoleType.SYSTEM) to = system; | ||
if (agentMessageDto.to == ToolRoleType.USER) to = user; | ||
if (agentMessageDto.to == ToolRoleType.AGENT) to = agent; | ||
if (agentMessageDto.to == ToolRoleType.LLM) to = llm; | ||
if (agentMessageDto.to == ToolRoleType.TOOL) to = tool; | ||
if (agentMessageDto.to == ToolRoleType.CLIENT) to = client; | ||
|
||
if (from.isNotEmpty && to.isNotEmpty) { | ||
print("#${agentMessageDto.sessionId}:${agentMessageDto.taskId}# $from -> $to: [${agentMessageDto.type}] $message"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.