类名称:CodeExecutionUtils

java.lang.Object
com.google.adk.codeexecutors.CodeExecutionUtils

public final class CodeExecutionUtils extends Object
用于代码执行的实用函数。
  • 方法详细信息(Method Details)

    • buildCodeExecutionResultPart

      public static com.google.genai.types.Part buildCodeExecutionResultPart(CodeExecutionUtils.CodeExecutionResult result)
    • buildExecutableCodePart

      public static com.google.genai.types.Part buildExecutableCodePart(String code)
    • convertCodeExecutionParts

      public static com.google.genai.types.Content convertCodeExecutionParts(com.google.genai.types.Content content, List<String> codeBlockDelimiters, List<String> executionResultDelimiters)
      将代码执行部分转换为内容中的文本部分。
      Parameters:
      content - The content to convert.
      codeBlockDelimiters - The delimiters to format the code block.
      executionResultDelimiters - The delimiters to format the code execution result.
      Returns:
      The updated content.
    • extractCodeAndTruncateContent

      public static Optional<String> extractCodeAndTruncateContent(com.google.genai.types.Content.Builder contentBuilder, List<? extends List<String>> codeBlockDelimiters)
      从内容中提取第一个代码块,并删除该代码块之后的所有内容。
      Parameters:
      contentBuilder - The content builder to extract the code from and modify.
      codeBlockDelimiters - The list of the enclosing delimiters to identify the code blocks.
      Returns:
      The extracted code if found.