Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
2984a76
inital demo for llm agent
KellyShiiii Mar 12, 2024
4c27a5e
enable active prompting when the chatroom is inactive
KellyShiiii Mar 20, 2024
316462c
enabled chat history forwarding
KellyShiiii Mar 20, 2024
25c03c8
ChatHistoryListener now receives BotMessageEvent
KellyShiiii Mar 21, 2024
25ec440
implemented saving chat history function for ChatHisotryListener
KellyShiiii Mar 21, 2024
b2681d3
implemented ChatHistoryListener with saving and loading
KellyShiiii Mar 21, 2024
35c2aaa
added session id to chat history
KellyShiiii Mar 21, 2024
5c3c71e
support 2 llm chat listener with global assignment of active listener
KellyShiiii Mar 25, 2024
87b5179
update request payload formatting
KellyShiiii Mar 25, 2024
f6c7984
solved conflict in state.java
KellyShiiii Mar 25, 2024
7c6bcf5
enabled time out for llm chat listeners
KellyShiiii Mar 25, 2024
8885497
set personas to llm chat listeners
KellyShiiii Mar 25, 2024
4d2883e
modified properties
KellyShiiii Mar 26, 2024
9a45470
demo on mar 26
KellyShiiii Mar 26, 2024
fdfb582
added termination word
KellyShiiii Mar 26, 2024
27526af
Merge branch 'llm_agent' of https://github.com/DANCEcollaborative/baz…
KellyShiiii Mar 26, 2024
cc6a49e
added step listener, modified request roles
KellyShiiii Mar 27, 2024
69b8bc2
changed turn taking logic when timeout. implemented global timer in C…
KellyShiiii Mar 27, 2024
da39702
code clean up
KellyShiiii Mar 27, 2024
022dba3
update server version
KellyShiiii Mar 27, 2024
b134c2e
Add recent socket-related updates from master
Mar 27, 2024
203ff50
close connection after each api request
KellyShiiii Apr 1, 2024
b79db44
Merge pull request #215 from DANCEcollaborative/llm_agent_socket_update
rcmurray Apr 2, 2024
556eae1
More convenient local launch for LlmAgent
Apr 2, 2024
c045520
Use Dockerfile with Java8 & NodeJS 20
Apr 2, 2024
23a2600
Socket updates to use TLSv1.2
Apr 5, 2024
51b6853
debugged the crash issue
KellyShiiii Apr 11, 2024
2db2cd1
update server-side properties
KellyShiiii Apr 11, 2024
6ebab3f
Use Java8 plus NodeJS 20
Apr 11, 2024
77fa04c
include sender identity in api request
KellyShiiii Apr 16, 2024
b750ca6
Merge branch 'master-with-llm2' of https://github.com/DANCEcollaborat…
KellyShiiii Apr 16, 2024
5b811be
llama acess
KellyShiiii Apr 23, 2024
946ed8d
changed some properties
KellyShiiii Apr 23, 2024
b6a1216
working version of master-with-llm-2
KellyShiiii Aug 1, 2024
f63bc57
update server properties
KellyShiiii Aug 1, 2024
f3c540f
Use vanilla Input/OutputCoordinator
Aug 6, 2024
aaf00b4
add new agent llmpromptagent
KellyShiiii Aug 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
11 changes: 11 additions & 0 deletions 15619P2Agent/.project
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,15 @@
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
<filteredResources>
<filter>
<id>1711515815379</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
11 changes: 11 additions & 0 deletions 15619P2ClassicAgent/.project
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,15 @@
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
<filteredResources>
<filter>
<id>1711515815384</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
11 changes: 11 additions & 0 deletions 15619P2PlusAgent/.project
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,15 @@
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
<filteredResources>
<filter>
<id>1711515815385</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
11 changes: 11 additions & 0 deletions 15619PracticeAgent/.project
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,15 @@
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
<filteredResources>
<filter>
<id>1711515815387</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
11 changes: 11 additions & 0 deletions AccountableTalkAgent/.project
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,15 @@
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
<filteredResources>
<filter>
<id>1711515815388</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
11 changes: 11 additions & 0 deletions ActiveMQClient/.project
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,15 @@
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
<filteredResources>
<filter>
<id>1711515815390</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
11 changes: 11 additions & 0 deletions BaseAgent/.project
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,15 @@
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
<filteredResources>
<filter>
<id>1711515815391</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
26 changes: 26 additions & 0 deletions BaseAgent/src/basilica2/agents/components/InputCoordinator.java
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,20 @@ public HashMap getListeners()
return listeners;
}

public BasilicaListener getListenerByName(String listenerName) {
// Iterate through all registered listener lists
for (List<BasilicaListener> listenerList : listeners.values()) {
// Search each list for a listener with the matching class name
for (BasilicaListener listener : listenerList) {
if (listener.getClass().getSimpleName().equals(listenerName)) {
return listener;
}
}
}
// Return null if no matching listener is found
return null;
}

public BasilicaPreProcessor getPreProcessor(String preProcessorString)
{
for (ArrayList<BasilicaPreProcessor> preepList : this.preprocessors.values()) {
Expand All @@ -416,6 +430,18 @@ public BasilicaPreProcessor getPreProcessor(String preProcessorString)
}
return null;
}
public List<BasilicaPreProcessor> getAllPreProcessorsContains(String content) {
List<BasilicaPreProcessor> preprocessors = new ArrayList<>();
for (ArrayList<BasilicaPreProcessor> preepList : this.preprocessors.values()) {
for (BasilicaPreProcessor preep : preepList) {
String listenerName = preep.toString();
if (listenerName.contains("LlmChatListener")) {
preprocessors.add(preep);
}
}
}
return preprocessors;
}

public void removeListener(Class key, BasilicaListener blister)
{
Expand Down
37 changes: 33 additions & 4 deletions BaseAgent/src/basilica2/agents/components/OutputCoordinator.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@
import java.time.LocalDateTime;

import org.jivesoftware.smack.packet.Message;
import org.json.JSONArray;
import org.json.JSONException;

import basilica2.agents.events.BotMessageEvent;
import basilica2.agents.events.MessageEvent;
import basilica2.agents.events.PrivateMessageEvent;
import basilica2.agents.events.priority.AbstractPrioritySource;
import basilica2.agents.events.priority.PriorityEvent;
import basilica2.agents.listeners.BasilicaListener;
import basilica2.agents.listeners.ChatHistoryListener;
import basilica2.agents.components.StateMemory;
import basilica2.agents.data.State;
import basilica2.util.MessageEventLogger;
Expand Down Expand Up @@ -52,6 +57,8 @@ public class OutputCoordinator extends Component implements TimeoutReceiver
private Boolean outputToPSI = false;
private Boolean separateOutputToPSI = false;
private Boolean multimodalFormatToPSI = true;
private Boolean outputBotMessage = false;
private Boolean useListenerName = false;
CommunicationManager psiCommunicationManager;
// ZeroMQClient psiCommunicationManager;
// private ZMQ.Socket publisher;
Expand Down Expand Up @@ -94,6 +101,10 @@ public OutputCoordinator(Agent agent, String s1, String s2)
catch(Exception e) {e.printStackTrace();}
try{bazaarToPSITopic = myProperties.getProperty("Bazaar_to_PSI_Topic", bazaarToPSITopic);}
catch(Exception e) {e.printStackTrace();}
try{outputBotMessage = Boolean.parseBoolean(myProperties.getProperty("output_bot_message", "false"));}
catch(Exception e) {e.printStackTrace();}
try{useListenerName = Boolean.parseBoolean(myProperties.getProperty("use_listener_name", "false"));}
catch(Exception e) {e.printStackTrace();}
// try{psiHost = myProperties.getProperty("PSI_Host", psiHost);}
// catch(Exception e) {e.printStackTrace();}
// try{psiPort = myProperties.getProperty("PSI_Port", psiPort);}
Expand Down Expand Up @@ -401,9 +412,24 @@ private void publishMessage(MessageEvent me)
// Might be a better idea to merge output coordinator and actor, or
// connect them directly

log(Logger.LOG_NORMAL, "OutputCoordinator.publishMessage - Enter - message: " + me.getText());
System.err.print("OutputCoordinator.publishMessage - Enter - message: " + me.getText());

log(Logger.LOG_NORMAL, "OutputCoordinator.publishMessage - Enter - message: " + me.getText() + " from " + me.getFrom());
System.err.println("OutputCoordinator.publishMessage - Enter - message: " + me.getText());
if (outputBotMessage) {
// BotMessageEvent newBM = new BotMessageEvent(this, me.getFrom(), me.getText());
InputCoordinator IC = (InputCoordinator)me.getSender();
System.err.println("OutputCoordinator: pushing bot message... " + me.getText());
// IC.pushEvent(newBM);
BasilicaListener CHL = IC.getListenerByName("ChatHistoryListener");
try {
((ChatHistoryListener) CHL).handleMessageEvent(IC, me);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// JSONArray chatHistory = ((ChatHistoryListener) CHL).retrieveChatHistory(this.contextLen);

log(Logger.LOG_NORMAL, "OutputCoordinator.sendBotMessage - send message to ChatHistoryListener: " + me.getText());
}
String withinPromptDelimiter = "|||";
String messageText;
if (!me.getText().contains(withinPromptDelimiter))
Expand Down Expand Up @@ -546,7 +572,10 @@ private String formatMultimodalMessage(MessageEvent me)
String messageString;

String text;
String from = agent.getUsername();
String from = agent.getUsername();
if (this.useListenerName) {
from = me.getFrom();
}
String to;
String textOrig = me.getText();

Expand Down
15 changes: 14 additions & 1 deletion BaseAgent/src/basilica2/agents/data/State.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public class Student
public String facialExp;
public poseEventType pose;
public String emotion;

@Override
public String toString()
{
Expand All @@ -88,6 +87,8 @@ public String toString()
private int jointActivityMetric = 0;
private Boolean multimodalDontListenWhileSpeaking = true;
private LocalDateTime multimodalDontListenEnd = null;
public String globalActiveListener = "";

// public String conceptId;
// public String conceptExecutionStatus;

Expand All @@ -107,6 +108,8 @@ public static State copy(State s)

news.multimodalDontListenWhileSpeaking = s.multimodalDontListenWhileSpeaking;
news.multimodalDontListenEnd = s.multimodalDontListenEnd;
news.globalActiveListener = s.globalActiveListener;

Map<String, Object> map = s.more();
for (String k : map.keySet())
news.stateMap.put(k, map.get(k));
Expand Down Expand Up @@ -634,6 +637,16 @@ public void setMultimodalDontListenWhileSpeakingEnd(LocalDateTime dontListenEnd)
{
this.multimodalDontListenEnd = dontListenEnd;
}

public void setGlobalActiveListener(String name) {
globalActiveListener = name;
}

public String getGlobalActiveListener() {
return globalActiveListener;
}



@Override
public String toString()
Expand Down
85 changes: 85 additions & 0 deletions BaseAgent/src/basilica2/agents/events/BotMessageEvent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
* Copyright (c), 2020 Carnegie Mellon University.
* All rights reserved.
*
* Use in source and binary forms, with or without modifications, are permitted
* provided that that following conditions are met:
*
* 1. Source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Binary form must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* Permission to redistribute source and binary forms, with or without
* modifications, for any purpose must be obtained from the authors.
* Contact Rohit Kumar (rohitk@cs.cmu.edu) for such permission.
*
* THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
* ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
* NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package basilica2.agents.events;

import edu.cmu.cs.lti.basilica2.core.Component;
import edu.cmu.cs.lti.basilica2.core.Event;
import edu.cmu.cs.lti.project911.utils.log.Logger;

/**
*
* @author rcmurray
*/
public class BotMessageEvent extends Event {

public static String GENERIC_NAME = "BOT_MESSAGE_EVENT";
private String botMessage = "NOT FOUND";
private String from = "NOT FOUND";
// public enum fileEventType
// {
// created, changed, deleted;
// }
// private fileEventType eventType;

public BotMessageEvent(Component s, String from, String n) {
super(s);
botMessage = n;
this.from = from;

// System.err.println("FileEvent created: file: " + n + " -- event type:" + t);
// Logger.commonLog(getClass().getSimpleName(),Logger.LOG_NORMAL,"FileEvent created - file: " + n + " -- event type: " + t);
}

public String getText() {
return botMessage;
}

public void setFrom(String newFrom)
{
from = newFrom;
}

public String getFrom()
{
return from;
}

@Override
public String getName() {
return GENERIC_NAME;
}

@Override
public String toString() {
return "botMessageEvent: " + botMessage;
}
}
Loading