Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Javet: Integrate as code execution engine #43

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

omarmahamid
Copy link

@omarmahamid omarmahamid commented Dec 28, 2024

Issue

Closes #langchain4j/langchain4j#1984
#langchain4j/langchain4j#1983

we decide to add the v8 execution engine to lc4j community.

Change

General checklist

  • There are no breaking changes
  • I have added unit and integration tests for my change
  • I have manually run all the unit tests in all modules, and they are all green
  • I have manually run all integration tests in the module I have added/changed, and they are all green

Checklist for adding new maven module

  • I have added my new module in the root pom.xml and langchain4j-community-bom/pom.xml

Checklist for adding new embedding store integration

  • I have added a {NameOfIntegration}EmbeddingStoreIT that extends from either EmbeddingStoreIT or EmbeddingStoreWithFilteringIT
  • I have added a {NameOfIntegration}EmbeddingStoreRemovalIT that extends from EmbeddingStoreWithRemovalIT

Checklist for changing existing embedding store integration

  • I have manually verified that the {NameOfIntegration}EmbeddingStore works correctly with the data persisted using the latest released version of LangChain4j

@Martin7-1 Martin7-1 added enhancement New feature or request P3 Medium priority labels Dec 29, 2024
@Martin7-1 Martin7-1 added this to the 1.0.0-alpha2 milestone Dec 29, 2024
@Martin7-1 Martin7-1 added the theme: code execution engines Issues/PRs related to code execution engines label Dec 29, 2024
Copy link
Collaborator

@Martin7-1 Martin7-1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Would you mind running make format to apply spotless?

omarmahamid and others added 6 commits December 29, 2024 10:17
…/src/main/java/dev/langchain4j/agent/V8JavaScriptExecutionEngine.java

Co-authored-by: Martin7-1 <[email protected]>
…/src/main/java/dev/langchain4j/agent/V8JavaScriptExecutionTool.java

Co-authored-by: Martin7-1 <[email protected]>
…/src/test/java/dev/langchain4j/agent/V8JavaScriptExecutionEngineTest.java

Co-authored-by: Martin7-1 <[email protected]>
@omarmahamid
Copy link
Author

@Martin7-1

Done.

Copy link
Collaborator

@Martin7-1 Martin7-1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@omarmahamid Thank you!

  1. Tool's IT is missing, could you please test tool if works correctly?
  2. Could you move the ExecutionEngine to dev.langchain4j.community.code.javet package, and move the Tool to dev.langchain4j.community.agent.tool.javet package?

package dev.langchain4j.community.agent;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Please always use the same assert framework (Prefer AssertJ).

@@ -62,6 +62,7 @@

<!-- Integration of web search engine -->
<module>web-search-engines/langchain4j-community-web-search-engine-searxng</module>
<module>code-execution-engines/langchain4j-code-execution-engine-javet</module>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the directory name is not correctly. (Missing community)


<dependency>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-code-execution-engine-graalvm-polyglot</artifactId>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Looks like this dependency is not necessary


<dependency>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j</artifactId>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Looks like this dependency is not necessary


<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Looks like this dependency is not necessary

}

@Override
public String execute(final String code) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public String execute(final String code) {
public String execute(String code) {

import dev.langchain4j.agent.tool.Tool;
import dev.langchain4j.code.CodeExecutionEngine;

public class V8JavaScriptExecutionTool {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public class V8JavaScriptExecutionTool {
public class JavetJavaScriptExecutionTool {

@@ -0,0 +1,39 @@
package dev.langchain4j.community.agent;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please move it to dev.langchain4j.community.code.javet package?

@@ -0,0 +1,24 @@
package dev.langchain4j.community.agent;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please move it to dev.langchain4j.community.agent.tool.javet package?


public class V8JavaScriptExecutionEngine implements CodeExecutionEngine {

private final IJavetEnginePool<V8Runtime> javetEnginePool;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this pool does not close properly.

@Martin7-1 Martin7-1 changed the title add v8 execution engine Javet: Integrate as code execution engine Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request P3 Medium priority theme: code execution engines Issues/PRs related to code execution engines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants