Skip to content

Commit b71458a

Browse files
committed
Remove cache and updated testcase
1 parent 87dec3b commit b71458a

File tree

2 files changed

+5
-8
lines changed
  • aiservices/openai/src

2 files changed

+5
-8
lines changed

aiservices/openai/src/main/java/com/microsoft/semantickernel/aiservices/openai/chatcompletion/OpenAIFunction.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import javax.annotation.Nullable;
2626

2727
class OpenAIFunction {
28-
private static final ConcurrentHashMap<String, String> SCHEMA_CACHE = new ConcurrentHashMap<>();
2928

3029
private final String pluginName;
3130
private final String name;
@@ -230,15 +229,11 @@ private static String getJavaTypeToOpenAiFunctionType(String javaType) {
230229
}
231230

232231
private static String getObjectSchema(String type, String description){
233-
String schema= "";
232+
String schema= "{ \"type\" : \"object\" }";
234233
try {
235-
if(SCHEMA_CACHE.containsKey(type)) {
236-
schema= SCHEMA_CACHE.get(type);
237-
} else {
238234
Class<?> clazz = Class.forName(type);
239235
schema = ResponseSchemaGenerator.jacksonGenerator().generateSchema(clazz);
240-
SCHEMA_CACHE.put(type, schema);
241-
}
236+
242237
} catch (ClassNotFoundException | SKException ignored) {
243238

244239
}

aiservices/openai/src/test/java/com/microsoft/semantickernel/aiservices/openai/chatcompletion/JsonSchemaTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ public void openAIFunctionTest() {
4646
OpenAIFunction openAIFunction = OpenAIFunction.build(
4747
testFunction.getMetadata(),
4848
plugin.getName());
49-
System.out.println(openAIFunction.getFunctionDefinition());
49+
50+
String parameters = "{\"type\":\"object\",\"required\":[\"person\",\"input\"],\"properties\":{\"input\":{\"type\":\"string\",\"description\":\"input string\"},\"person\":{\"type\":\"object\",\"properties\":{\"age\":{\"type\":\"integer\",\"description\":\"The age of the person.\"},\"name\":{\"type\":\"string\",\"description\":\"The name of the person.\"},\"title\":{\"type\":\"string\",\"enum\":[\"MS\",\"MRS\",\"MR\"],\"description\":\"The title of the person.\"}},\"required\":[\"age\",\"name\",\"title\"],\"additionalProperties\":false,\"description\":\"input person\"}}}";
51+
Assertions.assertEquals(parameters, openAIFunction.getFunctionDefinition().getParameters().toString());
5052

5153
}
5254

0 commit comments

Comments
 (0)