Skip to content

Commit

Permalink
add first toolset and integration services
Browse files Browse the repository at this point in the history
  • Loading branch information
czelabueno committed Dec 29, 2024
1 parent ae16a89 commit 2af552d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
3 changes: 1 addition & 2 deletions langchain4j-workflow/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<groupId>com.github.czelabueno</groupId>
<artifactId>jai-workflow-parent</artifactId>
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>langchain4j-workflow</artifactId>
Expand All @@ -15,7 +14,7 @@
<dependency>
<groupId>com.github.czelabueno</groupId>
<artifactId>jai-workflow-core</artifactId>
<version>${revision}</version>
<version>${project.version}</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

import lombok.Data;

/**
* AbstractStatefulBean is an abstract class that represents a stateful bean which is responsible for holding the state of the workflow.
* The state is a combination of a question, input data, output data and a response generation.
* Every execution of the workflow initiates a state, which is then transferred among the nodes during their execution.
* <br>
* Example:
* <pre>
* <code>
* public class MyStatefulBean extends AbstractStatefulBean {
* // my input/output data fields
* }
* </code>
* </pre>
*/
@Data
public abstract class AbstractStatefulBean {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import static dev.langchain4j.internal.ValidationUtils.ensureNotNull;

public interface AiWorkflow {
public interface JAiWorkflow {

default String answer(String question){
ensureNotNull(question, "question");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.github.czelabueno.jai.workflow.DefaultStateWorkflow;
import com.github.czelabueno.jai.workflow.StateWorkflow;
import com.github.czelabueno.jai.workflow.langchain4j.AbstractStatefulBean;
import com.github.czelabueno.jai.workflow.langchain4j.AiWorkflow;
import com.github.czelabueno.jai.workflow.langchain4j.JAiWorkflow;
import com.github.czelabueno.jai.workflow.node.Node;
import dev.langchain4j.data.message.AiMessage;
import dev.langchain4j.data.message.UserMessage;
Expand All @@ -18,9 +18,9 @@
import static dev.langchain4j.internal.Utils.getOrDefault;
import static dev.langchain4j.internal.ValidationUtils.ensureNotNull;

class DefaultAiWorkflow<T extends AbstractStatefulBean> implements AiWorkflow {
class DefaultJAiWorkflow<T extends AbstractStatefulBean> implements JAiWorkflow {

private static final Logger log = LoggerFactory.getLogger(DefaultAiWorkflow.class);
private static final Logger log = LoggerFactory.getLogger(DefaultJAiWorkflow.class);

private final Boolean runStream;
private final Boolean generateWorkflowImage;
Expand All @@ -30,11 +30,11 @@ class DefaultAiWorkflow<T extends AbstractStatefulBean> implements AiWorkflow {
private DefaultStateWorkflow<T> workflow;

@Builder
public DefaultAiWorkflow(T statefulBean,
List<Node<T,T>> nodes,
Boolean runStream,
Boolean generateWorkflowImage,
Path workflowImageOutputPath) {
public DefaultJAiWorkflow(T statefulBean,
List<Node<T,T>> nodes,
Boolean runStream,
Boolean generateWorkflowImage,
Path workflowImageOutputPath) {
this.runStream = getOrDefault(runStream, false);
// check if workflowOutputPath is valid
this.generateWorkflowImage = workflowImageOutputPath != null || getOrDefault(generateWorkflowImage, false);
Expand Down

0 comments on commit 2af552d

Please sign in to comment.