-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into release/jdk-17
# 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
Showing
203 changed files
with
10,845 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...-api-examples/src/main/java/bg/codexio/ai/openai/api/examples/assistant/AssistantAsk.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...i-examples/src/main/java/bg/codexio/ai/openai/api/examples/assistant/CreateAssistant.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
openai-api-examples/src/main/java/bg/codexio/ai/openai/api/examples/file/DownloadFile.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...ples/src/main/java/bg/codexio/ai/openai/api/examples/file/DownloadFileWithFileResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
openai-api-examples/src/main/java/bg/codexio/ai/openai/api/examples/file/UploadFile.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...i-api-examples/src/main/java/bg/codexio/ai/openai/api/examples/message/CreateMessage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
openai-api-examples/src/main/java/bg/codexio/ai/openai/api/examples/run/CreateRun.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...pi-examples/src/main/java/bg/codexio/ai/openai/api/examples/thread/CreateEmptyThread.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
openai-api-examples/src/main/java/bg/codexio/ai/openai/api/examples/thread/CreateThread.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
openai-api-http/src/main/java/bg/codexio/ai/openai/api/http/CommonConstantsUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() { | ||
} | ||
} |
Oops, something went wrong.