Package edu.uky.cs.nil.tt


package edu.uky.cs.nil.tt
This library provides the abstract classes Client and ClientFactory for implementing Tandem Tales agents in Java.

Client handles connecting to the server and joining a session. A minimal subclass of Client only needs to implement the onChoice(Status) method to choose what the agent will do on its turn.

ClientFactory continuously creates new clients to connect to the server and wait for partners. A minimal subclass of ClientFactory only needs to implement the create() method to return a new Client instance.

Here is an example client and factory:

package edu.uky.cs.nil.tt;

import java.util.List;
import java.util.Random;

import edu.uky.cs.nil.tt.world.Status;
import edu.uky.cs.nil.tt.world.Turn;

public class RandomAgent extends Client {

    private final Random random = new Random();

    public RandomAgent() {
        super("random", null, null);
    }

    @Override
    protected int onChoice(Status status) throws Exception {
        List<Turn> choices = status.getChoices();
        int choice = random.nextInt(choices.size());
        System.out.println(choices.get(choice).getDescription());
        return choice;
    }
}
package edu.uky.cs.nil.tt;

public class RandomAgentFactory extends ClientFactory {

    @Override
    protected Client create() throws Exception {
        return new RandomAgent();
    }

    public static void main(String[] args) throws Exception {
        try(RandomAgentFactory factory = new RandomAgentFactory()) {
            factory.call();
        }
    }
}

Both classes have other lifecycle methods that are meant to be overridden.

Client has the following lifecycle methods:

ClientFactory has the following lifecycle methods:

  • onStart(), which runs after the factory starts.
  • onClose(), which runs after the factory begins shutting down.
  • onStop(), which runs before the factory stops.

Client also provides a way to call an external API for expensive operations like text embedding and text completion.

  • embed(String) lets you convert a text string to an array of floats.
  • complete(String...) lets you generate text that is a fitting continuation of a sequence of messages.
  • Class
    Description
    A client connects to a server to find a partner and play a role in a storytelling session.
    A client factory continuously creates clients to connect to a server and is useful for deploying automated agents.
    The external API is how a client contacts remote services to perform computations the client cannot perform on its own.
    Represents the different levels of effort that can be used by a reasoning model during text completion.