Java: Small fixes from API review (#5053)

- Make some enums upper case
- Update service loader file names to be in sync with new package
structure
- Exclude implementation packages from javadoc
This commit is contained in:
John Oliver
2024-02-16 15:34:37 +00:00
committed by GitHub
parent 679bdb2180
commit bd0593968d
21 changed files with 49 additions and 51 deletions
+1 -1
View File
@@ -7,7 +7,7 @@
<parent>
<groupId>com.microsoft.semantic-kernel</groupId>
<artifactId>semantickernel-parent</artifactId>
<version>1.0.0-alpha.2-SNAPSHOT</version>
<version>1.0.0-rc1-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
+1 -1
View File
@@ -7,7 +7,7 @@
<parent>
<groupId>com.microsoft.semantic-kernel</groupId>
<artifactId>api-test</artifactId>
<version>1.0.0-alpha.2-SNAPSHOT</version>
<version>1.0.0-rc1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
+1 -1
View File
@@ -7,7 +7,7 @@
<parent>
<groupId>com.microsoft.semantic-kernel</groupId>
<artifactId>semantickernel-parent</artifactId>
<version>1.0.0-alpha.2-SNAPSHOT</version>
<version>1.0.0-rc1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
@@ -7,7 +7,7 @@
<parent>
<groupId>com.microsoft.semantic-kernel</groupId>
<artifactId>semantickernel-parent</artifactId>
<version>1.0.0-alpha.2-SNAPSHOT</version>
<version>1.0.0-rc1-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
@@ -6,7 +6,7 @@
<parent>
<groupId>com.microsoft.semantic-kernel</groupId>
<artifactId>semantickernel-parent</artifactId>
<version>1.0.0-alpha.2-SNAPSHOT</version>
<version>1.0.0-rc1-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
+2 -1
View File
@@ -7,7 +7,7 @@
<groupId>com.microsoft.semantic-kernel</groupId>
<artifactId>semantickernel-parent</artifactId>
<version>1.0.0-alpha.2-SNAPSHOT</version>
<version>1.0.0-rc1-SNAPSHOT</version>
<packaging>pom</packaging>
<url>https://www.github.com/microsoft/semantic-kernel</url>
@@ -255,6 +255,7 @@
<failOnError>false</failOnError>
<nohelp>true</nohelp>
<show>public</show>
<excludePackageNames>*.implementation.*:*.implementation</excludePackageNames>
</configuration>
</plugin>
<plugin>
+2 -2
View File
@@ -5,12 +5,12 @@
<parent>
<groupId>com.microsoft.semantic-kernel</groupId>
<artifactId>semantickernel-parent</artifactId>
<version>1.0.0-alpha.2-SNAPSHOT</version>
<version>1.0.0-rc1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>semantickernel-samples-parent</artifactId>
<version>1.0.0-alpha.2-SNAPSHOT</version>
<version>1.0.0-rc1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Semantic Kernel Samples Parent</name>
<description>Parent pom for sample code for using the Semantic Kernel project</description>
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<groupId>com.microsoft.semantic-kernel</groupId>
<artifactId>semantickernel-samples-parent</artifactId>
<version>1.0.0-alpha.2-SNAPSHOT</version>
<version>1.0.0-rc1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
+1 -1
View File
@@ -7,7 +7,7 @@
<parent>
<groupId>com.microsoft.semantic-kernel</groupId>
<artifactId>semantickernel-parent</artifactId>
<version>1.0.0-alpha.2-SNAPSHOT</version>
<version>1.0.0-rc1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
@@ -86,9 +86,9 @@ public class DefaultPromptTemplate implements PromptTemplate {
blocks.forEach(block -> {
String name = null;
if (block.getType() == BlockTypes.Variable) {
if (block.getType() == BlockTypes.VARIABLE) {
name = ((VarBlock) block).getName();
} else if (block.getType() == BlockTypes.NamedArg) {
} else if (block.getType() == BlockTypes.NAMED_ARG) {
VarBlock blockName = ((NamedArgBlock) block).getVarBlock();
name = blockName == null ? null : blockName.getName();
}
@@ -134,7 +134,7 @@ public class TemplateTokenizer {
.tokenize(contentWithoutDelimiters);
switch (codeBlocks.get(0).getType()) {
case Variable:
case VARIABLE:
if (codeBlocks.size() > 1) {
throw new TemplateException(
TemplateException.ErrorCodes.SYNTAX_ERROR,
@@ -145,7 +145,7 @@ public class TemplateTokenizer {
blocks.add(codeBlocks.get(0));
break;
case Value:
case VALUE:
if (codeBlocks.size() > 1) {
throw new TemplateException(
TemplateException.ErrorCodes.SYNTAX_ERROR,
@@ -156,13 +156,13 @@ public class TemplateTokenizer {
blocks.add(codeBlocks.get(0));
break;
case FunctionId:
case FUNCTION_ID:
blocks.add(new CodeBlock(codeBlocks, contentWithoutDelimiters));
break;
case Code:
case Text:
case Undefined:
case CODE:
case TEXT:
case UNDEFINED:
default:
throw new TemplateException(
TemplateException.ErrorCodes.UNEXPECTED_BLOCK_TYPE,
@@ -8,32 +8,29 @@ public enum BlockTypes {
/**
* Undefined block type
*/
Undefined(0),
UNDEFINED,
/**
* Text block type
*/
Text(1),
TEXT,
/**
* Code block type
*/
Code(2),
CODE,
/**
* Variable block type
*/
Variable(3),
VARIABLE,
/**
* Value block type
*/
Value(4),
VALUE,
/**
* Function block type
*/
FunctionId(5),
FUNCTION_ID,
/**
* Named argument block type
*/
NamedArg(6);
BlockTypes(int i) {
}
NAMED_ARG;
}
@@ -35,7 +35,7 @@ public final class CodeBlock extends Block implements CodeRendering {
* @param content The content.
*/
public CodeBlock(List<Block> tokens, String content) {
super(content, BlockTypes.Code);
super(content, BlockTypes.CODE);
this.tokens = Collections.unmodifiableList(tokens);
}
@@ -47,7 +47,7 @@ public final class CodeBlock extends Block implements CodeRendering {
return false;
}
if (this.tokens.size() > 0 && this.tokens.get(0).getType() == BlockTypes.NamedArg) {
if (this.tokens.size() > 0 && this.tokens.get(0).getType() == BlockTypes.NAMED_ARG) {
LOGGER.error("Unexpected named argument found. Expected function name first.");
return false;
}
@@ -60,21 +60,21 @@ public final class CodeBlock extends Block implements CodeRendering {
}
private boolean isValidFunctionCall() {
if (this.tokens.get(0).getType() != BlockTypes.FunctionId) {
if (this.tokens.get(0).getType() != BlockTypes.FUNCTION_ID) {
LOGGER.error("Unexpected second token found: " + tokens.get(1).getContent());
return false;
}
if (this.tokens.get(1).getType() != BlockTypes.Value &&
this.tokens.get(1).getType() != BlockTypes.Variable &&
this.tokens.get(1).getType() != BlockTypes.NamedArg) {
if (this.tokens.get(1).getType() != BlockTypes.VALUE &&
this.tokens.get(1).getType() != BlockTypes.VARIABLE &&
this.tokens.get(1).getType() != BlockTypes.NAMED_ARG) {
LOGGER.error(
"The first arg of a function must be a quoted string, variable or named argument");
return false;
}
for (int i = 2; i < this.tokens.size(); i++) {
if (this.tokens.get(i).getType() != BlockTypes.NamedArg) {
if (this.tokens.get(i).getType() != BlockTypes.NAMED_ARG) {
LOGGER.error(
"Functions only support named arguments after the first argument. Argument " + i
+ " is not named.");
@@ -101,12 +101,12 @@ public final class CodeBlock extends Block implements CodeRendering {
// this.Log.LogTrace("Rendering code: `{0}`", this.Content);
switch (this.tokens.get(0).getType()) {
case Value:
case Variable:
case VALUE:
case VARIABLE:
return Mono.just(
((TextRendering) this.tokens.get(0)).render(arguments));
case FunctionId:
case FUNCTION_ID:
return this
.renderFunctionCallAsync(
(FunctionIdBlock) this.tokens.get(0),
@@ -118,9 +118,9 @@ public final class CodeBlock extends Block implements CodeRendering {
return it.getValue();
});
case Undefined:
case Text:
case Code:
case UNDEFINED:
case TEXT:
case CODE:
default:
throw new RuntimeException("Unknown type");
}
@@ -185,7 +185,7 @@ public final class CodeBlock extends Block implements CodeRendering {
Object firstPositionalInputValue;
int namedArgsStartIndex = 1;
if (firstArg.getType() != BlockTypes.NamedArg) {
if (firstArg.getType() != BlockTypes.NAMED_ARG) {
// Gets the function first parameter name
firstPositionalParameterName = functionMetadata.getParameters().get(0).getName();
@@ -18,7 +18,7 @@ public final class FunctionIdBlock extends Block implements TextRendering {
* @param content The content.
*/
public FunctionIdBlock(String content) {
super(content, BlockTypes.FunctionId);
super(content, BlockTypes.FUNCTION_ID);
String[] functionNameParts = this.getContent().split("\\.", -1);
if (functionNameParts.length > 2) {
@@ -1,6 +1,6 @@
package com.microsoft.semantickernel.implementation.templateengine.tokenizer.blocks;
import static com.microsoft.semantickernel.implementation.templateengine.tokenizer.blocks.BlockTypes.NamedArg;
import static com.microsoft.semantickernel.implementation.templateengine.tokenizer.blocks.BlockTypes.NAMED_ARG;
import com.microsoft.semantickernel.exceptions.SKException;
import com.microsoft.semantickernel.implementation.Verify;
@@ -23,7 +23,7 @@ public class NamedArgBlock extends Block implements TextRendering {
private final ValBlock valBlock;
public NamedArgBlock(String content, String name, String value) {
super(content.trim(), NamedArg);
super(content.trim(), NAMED_ARG);
this.name = name.trim();
this.value = value.trim();
@@ -45,7 +45,7 @@ public class NamedArgBlock extends Block implements TextRendering {
VarBlock argNameAsVarBlock,
@Nullable VarBlock varBlock,
@Nullable ValBlock valBlock) {
super(content, NamedArg);
super(content, NAMED_ARG);
this.name = name;
this.value = value;
this.argNameAsVarBlock = argNameAsVarBlock;
@@ -7,7 +7,7 @@ import javax.annotation.Nullable;
public final class TextBlock extends Block implements TextRendering {
public TextBlock(String text) {
super(text, BlockTypes.Text);
super(text, BlockTypes.TEXT);
}
@Override
@@ -21,6 +21,6 @@ public final class TextBlock extends Block implements TextRendering {
}
public TextBlock(String text, int startIndex, int stopIndex) {
super(text.substring(startIndex, stopIndex), BlockTypes.Text);
super(text.substring(startIndex, stopIndex), BlockTypes.TEXT);
}
}
@@ -18,7 +18,7 @@ public final class ValBlock extends Block implements TextRendering {
private String value = "";
public ValBlock(String quotedValue) {
super(quotedValue.trim(), BlockTypes.Value);
super(quotedValue.trim(), BlockTypes.VALUE);
if (this.getContent().length() < 2) {
LOGGER.error("A value must have single quotes or double quotes on both sides");
@@ -14,7 +14,7 @@ public final class VarBlock extends Block implements TextRendering {
private final String name;
public VarBlock(String content) {
super(content, BlockTypes.Variable);
super(content, BlockTypes.VARIABLE);
if (content.length() < 2) {
LOGGER.error("The variable name is empty");
+1 -1
View File
@@ -6,7 +6,7 @@
<groupId>com.microsoft.semantic-kernel</groupId>
<artifactId>semantickernel-bom</artifactId>
<version>1.0.0-alpha.2-SNAPSHOT</version>
<version>1.0.0-rc1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Semantic Kernel Java BOM</name>