Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into release/jdk-17
Browse files Browse the repository at this point in the history
# Conflicts:
#	README.md
#	openai-api-coverage/pom.xml
#	openai-api-examples/pom.xml
#	openai-api-http/pom.xml
#	openai-api-models/pom.xml
#	openai-api-payload/pom.xml
#	openai-api-sdk/pom.xml
#	pom.xml
  • Loading branch information
ivanyonkov committed Feb 5, 2024
2 parents 91dacaf + 78c2665 commit 19289ce
Show file tree
Hide file tree
Showing 203 changed files with 10,845 additions and 78 deletions.
299 changes: 292 additions & 7 deletions README.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions openai-api-coverage/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>bg.codexio.ai</groupId>
<artifactId>openai-api</artifactId>
<version>0.8.2.BETA-JDK17-SNAPSHOT</version>
<version>0.9.0.BETA-JDK17</version>
</parent>

<artifactId>openai-api-coverage</artifactId>
Expand All @@ -15,7 +15,7 @@
<description>Codexio Ltd. Open AI API SDK Test Coverage Aggregate Module</description>

<properties>
<internal.modules.version>0.8.2.BETA-JDK17-SNAPSHOT</internal.modules.version>
<internal.modules.version>0.9.0.BETA-JDK17</internal.modules.version>
<skipDeploy>false</skipDeploy>
</properties>

Expand Down
4 changes: 2 additions & 2 deletions openai-api-examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>bg.codexio.ai</groupId>
<artifactId>openai-api</artifactId>
<version>0.8.2.BETA-JDK17-SNAPSHOT</version>
<version>0.9.0.BETA-JDK17</version>
</parent>

<artifactId>openai-api-examples</artifactId>
Expand All @@ -22,7 +22,7 @@
<dependency>
<groupId>bg.codexio.ai</groupId>
<artifactId>openai-api-sdk</artifactId>
<version>0.8.2.BETA-JDK17-SNAPSHOT</version>
<version>0.9.0.BETA-JDK17</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package bg.codexio.ai.openai.api.examples.assistant;

import bg.codexio.ai.openai.api.payload.assistant.tool.CodeInterpreter;
import bg.codexio.ai.openai.api.sdk.assistant.Assistants;
import bg.codexio.ai.openai.api.sdk.thread.Threads;

import java.io.File;
import java.io.IOException;

public class AssistantAsk {

public static void main(String[] args) throws IOException {
var file = new File(AssistantAsk.class.getClassLoader()
.getResource("fake-file.txt")
.getPath());
var fileDownloadLocation = new File(AssistantAsk.class.getClassLoader()
.getResource("")
.getPath()
+ "generated-files");

var answer = Threads.defaults()
.and()
.creating()
.deepConfigure()
.message()
.startWith("You are developer at Codexio.")
.attach(file)
.chat()
.withContent("Your language of choice is Java.")
.meta()
.awareOf(
"key",
"value"
)
.assistant()
.assist(Assistants.defaults()
.and()
.poweredByGPT40()
.from(new CodeInterpreter())
.called("Cody")
.instruct("Please focus on "
+ "explaining"
+ " the "
+ "topics as "
+ "senior "
+ "developer.")
.andRespond())
.instruction()
.instruct("It would be better to show me some "
+ "DevOps skills.")
.finish()
.waitForCompletion()
.result()
.answers()
.download(fileDownloadLocation);

System.out.println(answer);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package bg.codexio.ai.openai.api.examples.assistant;

import bg.codexio.ai.openai.api.payload.assistant.tool.CodeInterpreter;
import bg.codexio.ai.openai.api.payload.assistant.tool.Retrieval;
import bg.codexio.ai.openai.api.sdk.assistant.Assistants;

import java.io.File;

public class CreateAssistant {

public static void main(String[] args) {
var file = new File(CreateAssistant.class.getClassLoader()
.getResource("fake-file.txt")
.getPath());

var assistant = Assistants.defaults()
.and()
.turboPowered()
.from(
new CodeInterpreter(),
new Retrieval()
)
.called("Codexio")
.instruct("You are the best java developer,"
+ " you are going to "
+ "participate in new "
+ "interesting projects.")

.meta()
.awareOf(
"key1",
"value1",
"key2",
"value2"
)
.file()
.feed(file)
.andRespond();

System.out.println(assistant);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package bg.codexio.ai.openai.api.examples.file;

import bg.codexio.ai.openai.api.sdk.file.Files;

import java.io.File;
import java.io.IOException;

public class DownloadFile {

public static void main(String[] args) throws IOException {
var file = new File(DownloadFile.class.getClassLoader()
.getResource("")
.getPath() + "generated-files");

var downloadedFile = Files.defaults()
.and()
.download("file-zR7aSAvw1xFBjqLIGKnRpT1q")
.as("file.py")
.toFolder(file);

System.out.println(downloadedFile.getAbsoluteFile()
.getName());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package bg.codexio.ai.openai.api.examples.file;

import bg.codexio.ai.openai.api.sdk.file.FileResult;

import java.io.File;
import java.io.IOException;

public class DownloadFileWithFileResult {

public static void main(String[] args) throws IOException {
var targetFolder = new File(
DownloadFileWithFileResult.class.getClassLoader()
.getResource("")
.getPath() + "generated-files");

var downloadedFile = new FileResult(
"file-zR7aSAvw1xFBjqLIGKnRpT1q",
"file.py"
).download(targetFolder);

System.out.println(downloadedFile.getName());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package bg.codexio.ai.openai.api.examples.file;


import bg.codexio.ai.openai.api.payload.file.purpose.AssistantPurpose;
import bg.codexio.ai.openai.api.sdk.file.Files;

import java.io.File;

public class UploadFile {

public static void main(String[] args) {
var file = new File(UploadFile.class.getClassLoader()
.getResource("fake-file.txt")
.getPath());
var fileId = Files.defaults()
.and()
.upload()
.targeting(new AssistantPurpose())
.feed(file);

System.out.println(fileId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package bg.codexio.ai.openai.api.examples.message;

import bg.codexio.ai.openai.api.sdk.message.Messages;
import bg.codexio.ai.openai.api.sdk.thread.Threads;

public class CreateMessage {

public static void main(String[] args) {
var messageResponse = Messages.defaults(Threads.defaults()
.and()
.creating()
.empty())
.and()
.chat()
.withContent("How are you?")
.andRespond();

System.out.println(messageResponse);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package bg.codexio.ai.openai.api.examples.run;

import bg.codexio.ai.openai.api.payload.assistant.tool.CodeInterpreter;
import bg.codexio.ai.openai.api.sdk.assistant.Assistants;
import bg.codexio.ai.openai.api.sdk.run.Runnables;
import bg.codexio.ai.openai.api.sdk.thread.Threads;

public class CreateRun {

public static void main(String[] args) {
var run = Runnables.defaults(Threads.defaults()
.and()
.creating()
.empty())
.and()
.deepConfigure(Assistants.defaults()
.and()
.poweredByGPT40()
.from(new CodeInterpreter())
.called("Cody")
.instruct("Be intuitive")
.andRespond())
.andRespond();

System.out.println(run);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package bg.codexio.ai.openai.api.examples.thread;

import bg.codexio.ai.openai.api.sdk.thread.Threads;

public class CreateEmptyThread {

public static void main(String[] args) {
var thread = Threads.defaults()
.and()
.creating()
.empty();

System.out.println(thread);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package bg.codexio.ai.openai.api.examples.thread;

import bg.codexio.ai.openai.api.sdk.thread.Threads;

import java.io.File;

public class CreateThread {

public static void main(String[] args) {
var file = new File(CreateThread.class.getClassLoader()
.getResource("fake-file.txt")
.getPath());

var thread = Threads.defaults()
.and()
.creating()
.deepConfigure()
.meta()
.awareOf(
"key1",
"value1",
"key2",
"value2"
)
.file()
.attach(file)
.message()
.startWith("You're java developer.")
.feed(file);

System.out.println(thread);
}
}
1 change: 1 addition & 0 deletions openai-api-examples/src/main/resources/fake-file.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test
6 changes: 3 additions & 3 deletions openai-api-http/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>bg.codexio.ai</groupId>
<artifactId>openai-api</artifactId>
<version>0.8.2.BETA-JDK17-SNAPSHOT</version>
<version>0.9.0.BETA-JDK17</version>
</parent>

<artifactId>openai-api-http</artifactId>
Expand All @@ -22,13 +22,13 @@
<dependency>
<groupId>bg.codexio.ai</groupId>
<artifactId>openai-api-models</artifactId>
<version>0.8.2.BETA-JDK17-SNAPSHOT</version>
<version>0.9.0.BETA-JDK17</version>
</dependency>

<dependency>
<groupId>bg.codexio.ai</groupId>
<artifactId>openai-api-payload</artifactId>
<version>0.8.2.BETA-JDK17-SNAPSHOT</version>
<version>0.9.0.BETA-JDK17</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package bg.codexio.ai.openai.api.http;

public class CommonConstantsUtils {

public static final String ASSISTANTS_HEADER_NAME = "OpenAI-Beta";
public static final String ASSISTANTS_HEADER_VALUE = "assistants=v1";

private CommonConstantsUtils() {
}
}
Loading

0 comments on commit 19289ce

Please sign in to comment.