Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
package org.conductoross.conductor.sdk;

import java.time.Duration;
import java.util.List;

import org.conductoross.conductor.sdk.internal.Command;
import org.conductoross.conductor.sdk.internal.Engine;
import org.conductoross.conductor.sdk.internal.Entries;
import org.conductoross.conductor.sdk.internal.Json;

/** A chat completion executed by the server (LLM_CHAT_COMPLETE). Models are {@code provider/model}. */
public final class LlmCall {
Expand Down Expand Up @@ -64,6 +66,17 @@ public LlmCall prompt(String prompt) {
return this;
}

/**
* The conversation so far, oldest first: each message an object with {@code role} ({@code
* user}, {@code assistant} or {@code system}) and {@code message}, as the server's {@code
* ChatMessage}. With messages the server ignores {@link #prompt}: the last message is the one
* the model answers.
*/
public LlmCall messages(List<?> messages) {
command.input.put("messages", Json.plain(messages));
return this;
}

/**
* Asks the model and returns its answer as {@code type}: a {@code String} for text, or a record
* or class for a JSON answer, which the server then requires (an answer that is not JSON fails
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1260,7 +1260,9 @@ public boolean awaitCondition(BooleanSupplier condition, Duration timeout) {
if (mode != Mode.ACTIVE) {
throw diverged("the code waits for a condition as " + ref + " but the recorded execution has no such wait");
}
Command wait = new Command(Command.Kind.WAIT, ref);
// named "condition" whatever its reference, as sleep is "sleep": the UI folds a Java
// loop's passes by call site and name, so a name numbered like the ref never repeats
Command wait = new Command(Command.Kind.WAIT, "condition");
wait.input.put("duration", Entries.duration(timeout));
emit(Entries.continuation(Entries.of(wait, ref, id), counter + 1));
pendingConditions.put(ref, condition);
Expand Down
Loading