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

Release 1.2.4 #32

Merged
merged 3 commits into from
Dec 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .devfile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
schemaVersion: 2.2.2
metadata:
attributes:
metadata-name-field: generateName
metadata-name-original-value: simple-openai
name: simple-openai
namespace: sashirestela-dev
attributes:
che-theia.eclipse.org/sidecar-policy: mergeImage
projects:
- name: simple-openai
git:
remotes:
origin: https://github.com/sashirestela/simple-openai.git
components:
- name: universal-developer-image
container:
image: quay.io/devfile/universal-developer-image:ubi8-latest
volumeMounts:
- name: m2
path: /home/user/.m2
mountSources: true
- name: m2
volume:
size: 5Gi
commands: []
3 changes: 3 additions & 0 deletions .sdkmanrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Enable auto-env through the sdkman_auto_env config
# Add key=value pairs of SDKs to use below
java=11.0.15-tem
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.github.sashirestela</groupId>
<artifactId>simple-openai</artifactId>
<version>1.2.3</version>
<version>1.2.4</version>
<packaging>jar</packaging>

<name>simple-openai</name>
Expand Down Expand Up @@ -52,7 +52,7 @@
<maven.compiler.release>11</maven.compiler.release>
<!-- Dependencies Versions -->
<slf4j.version>[2.0.9,3.0.0)</slf4j.version>
<cleverclient.version>0.11.1</cleverclient.version>
<cleverclient.version>0.12.0</cleverclient.version>
<lombok.version>[1.18.30,2.0.0)</lombok.version>
<jackson.version>[2.15.2,3.0.0)</jackson.version>
<json.schema.version>[4.31.1,5.0.0)</json.schema.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public <T> T execute(ChatFunctionCall functionToCall) {
}
try {
var function = mapFunctions.get(functionName);
var object = JsonUtil.jsonToObjectStrict(functionToCall.getArguments(), function.getFunctionalClass());
var object = JsonUtil.jsonToObject(functionToCall.getArguments(), function.getFunctionalClass());
return (T) object.execute();
} catch (RuntimeException e) {
throw new SimpleUncheckedException("Cannot execute the function {0}.", functionName, e);
Expand Down
20 changes: 10 additions & 10 deletions src/test/java/io/github/sashirestela/openai/SimpleOpenAITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.mockito.ArgumentCaptor;

import io.github.sashirestela.cleverclient.CleverClient;
import io.github.sashirestela.cleverclient.http.HttpInvocationHandler;
import io.github.sashirestela.cleverclient.http.HttpProcessor;
import io.github.sashirestela.cleverclient.util.ReflectUtil;
import io.github.sashirestela.openai.domain.chat.ChatRequest;

Expand Down Expand Up @@ -128,7 +128,7 @@ void shouldInstanceAudioServiceOnlyOnceWhenItIsCalledSeveralTimes() {
when(cleverClient.create(any()))
.thenReturn(ReflectUtil.createProxy(
OpenAI.Audios.class,
new HttpInvocationHandler(null)));
new HttpProcessor(null, null, null)));
repeat(NUMBER_CALLINGS, () -> openAI.audios());
verify(cleverClient, times(NUMBER_INVOCATIONS)).create(any());
}
Expand All @@ -138,7 +138,7 @@ void shouldInstanceChatCompletionServiceOnlyOnceWhenItIsCalledSeveralTimes() {
when(cleverClient.create(any()))
.thenReturn(ReflectUtil.createProxy(
OpenAI.ChatCompletions.class,
new HttpInvocationHandler(null)));
new HttpProcessor(null, null, null)));
repeat(NUMBER_CALLINGS, () -> openAI.chatCompletions());
verify(cleverClient, times(NUMBER_INVOCATIONS)).create(any());
}
Expand All @@ -148,7 +148,7 @@ void shouldInstanceCompletionServiceOnlyOnceWhenItIsCalledSeveralTimes() {
when(cleverClient.create(any()))
.thenReturn(ReflectUtil.createProxy(
OpenAI.Completions.class,
new HttpInvocationHandler(null)));
new HttpProcessor(null, null, null)));
repeat(NUMBER_CALLINGS, () -> openAI.completions());
verify(cleverClient, times(NUMBER_INVOCATIONS)).create(any());
}
Expand All @@ -158,7 +158,7 @@ void shouldInstanceEmbeddingServiceOnlyOnceWhenItIsCalledSeveralTimes() {
when(cleverClient.create(any()))
.thenReturn(ReflectUtil.createProxy(
OpenAI.Embeddings.class,
new HttpInvocationHandler(null)));
new HttpProcessor(null, null, null)));
repeat(NUMBER_CALLINGS, () -> openAI.embeddings());
verify(cleverClient, times(NUMBER_INVOCATIONS)).create(any());
}
Expand All @@ -168,7 +168,7 @@ void shouldInstanceFilesServiceOnlyOnceWhenItIsCalledSeveralTimes() {
when(cleverClient.create(any()))
.thenReturn(ReflectUtil.createProxy(
OpenAI.Files.class,
new HttpInvocationHandler(null)));
new HttpProcessor(null, null, null)));
repeat(NUMBER_CALLINGS, () -> openAI.files());
verify(cleverClient, times(NUMBER_INVOCATIONS)).create(any());
}
Expand All @@ -178,7 +178,7 @@ void shouldInstanceFineTunningServiceOnlyOnceWhenItIsCalledSeveralTimes() {
when(cleverClient.create(any()))
.thenReturn(ReflectUtil.createProxy(
OpenAI.FineTunings.class,
new HttpInvocationHandler(null)));
new HttpProcessor(null, null, null)));
repeat(NUMBER_CALLINGS, () -> openAI.fineTunings());
verify(cleverClient, times(NUMBER_INVOCATIONS)).create(any());
}
Expand All @@ -188,7 +188,7 @@ void shouldInstanceImageServiceOnlyOnceWhenItIsCalledSeveralTimes() {
when(cleverClient.create(any()))
.thenReturn(ReflectUtil.createProxy(
OpenAI.Images.class,
new HttpInvocationHandler(null)));
new HttpProcessor(null, null, null)));
repeat(NUMBER_CALLINGS, () -> openAI.images());
verify(cleverClient, times(NUMBER_INVOCATIONS)).create(any());
}
Expand All @@ -198,7 +198,7 @@ void shouldInstanceModelsServiceOnlyOnceWhenItIsCalledSeveralTimes() {
when(cleverClient.create(any()))
.thenReturn(ReflectUtil.createProxy(
OpenAI.Models.class,
new HttpInvocationHandler(null)));
new HttpProcessor(null, null, null)));
repeat(NUMBER_CALLINGS, () -> openAI.models());
verify(cleverClient, times(NUMBER_INVOCATIONS)).create(any());
}
Expand All @@ -208,7 +208,7 @@ void shouldInstanceModerationServiceOnlyOnceWhenItIsCalledSeveralTimes() {
when(cleverClient.create(any()))
.thenReturn(ReflectUtil.createProxy(
OpenAI.Moderations.class,
new HttpInvocationHandler(null)));
new HttpProcessor(null, null, null)));
repeat(NUMBER_CALLINGS, () -> openAI.moderations());
verify(cleverClient, times(NUMBER_INVOCATIONS)).create(any());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void shouldThrownAnExceptionWhenTryingToExecuteANonEnrolledFunction() {
@Test
void shouldThrowAnExceptionWhenTryingToExecuteFunctionArgumentsThatDoNotMatchItsClassStructure() {
var executor = new FunctionExecutor(functionList);
var functionToCall = new ChatFunctionCall("exponentiation", "{\"base\":2.0,\"power\":10.0}");
var functionToCall = new ChatFunctionCall("exponentiation", "{\"base\":2.0,\"exponent\":\"ten\"}");
var exception = assertThrows(SimpleUncheckedException.class,
() -> executor.execute(functionToCall));
var actualErrorMessage = exception.getMessage();
Expand Down