Class Judge0JavaScriptExecutionTool

java.lang.Object
dev.langchain4j.code.judge0.Judge0JavaScriptExecutionTool

public class Judge0JavaScriptExecutionTool extends Object
A tool that executes JS code using the Judge0 service, hosted by Rapid API.
  • Constructor Details

    • Judge0JavaScriptExecutionTool

      public Judge0JavaScriptExecutionTool(String apiKey)
      Constructs a new instance with the provided Rapid API key. The code fixing feature is enabled by default. Default timeout is 10 seconds.
      Parameters:
      apiKey - The Rapid API key. You can subscribe to the free plan (Basic) here: https://rapidapi.com/judge0-official/api/judge0-ce/pricing
    • Judge0JavaScriptExecutionTool

      public Judge0JavaScriptExecutionTool(String apiKey, boolean fixCodeIfNeeded, Duration timeout)
      Constructs a new instance with the provided Rapid API key, a flag to control whether to fix the code, and a timeout.
      Parameters:
      apiKey - Rapid API key. You can subscribe to the free plan (Basic) here: https://rapidapi.com/judge0-official/api/judge0-ce/pricing
      fixCodeIfNeeded - Judge0 can return result of an execution if it was printed to the console. If provided JS code does not print result to the console, attempt will be made to fix it.
      timeout - Timeout for calling Judge0.
  • Method Details

    • executeJavaScriptCode

      public String executeJavaScriptCode(String javaScriptCode)