Skip to content

Commit

Permalink
gpt3 prefix and websockethandler fix
Browse files Browse the repository at this point in the history
  • Loading branch information
supertick committed Nov 16, 2023
1 parent 6a8d930 commit 9431841
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main/java/org/myrobotlab/service/Gpt3.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class Gpt3 extends Service<Gpt3Config> implements TextListener, TextPubli
private String currentChannelName;

private String currentChannelType;

public Gpt3(String n, String id) {
super(n, id);
}
Expand All @@ -85,6 +85,10 @@ public Response getResponse(String text) {
sleep();
responseText = "Ok, I will go to sleep";
}

if (c.prefix != null) {
text = c.prefix + " " + text;
}

if (!c.sleeping) {

Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/myrobotlab/service/config/Gpt3Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ public class Gpt3Config extends ServiceConfig {
public String engine = "gpt-3.5-turbo"; // "text-davinci-003"
public String wakeWord = "wake";
public String sleepWord = "sleep";
/**
* static prefix to send to gpt3
* e.g. " talk like a pirate when responding, "
*/
public String prefix = null;

@Override
public Plan getDefault(Plan plan, String name) {
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/org/myrobotlab/vertx/WebSocketHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ public void handle(ServerWebSocket socket) {
// client
MultiMap headers = socket.headers();
String uri = socket.uri();

// FIXME - get "id" from js client - need something unique from the js
// client
// String id = r.getRequest().getParameter("id");
String id = String.format("vertx-%s", service.getName());
// String uuid = UUID.randomUUID().toString();
String uuid = socket.binaryHandlerID();

Connection connection = new Connection(uuid, id, service.getName());
connection.put("c-type", service.getSimpleName());
connection.put("gateway", service.getName());
Expand Down

0 comments on commit 9431841

Please sign in to comment.