Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit bb8502e

Browse files
normalize lind endings and add assistants
1 parent f538803 commit bb8502e

File tree

132 files changed

+1753
-167
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+1753
-167
lines changed

‎.gitattributes

100644100755
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
1-
#
2-
# https://help.github.com/articles/dealing-with-line-endings/
3-
#
4-
# These are explicitly windows files and should use crlf
51
*.bat text eol=crlf
6-
2+
*texteol=lf

‎.github/FUNDING.yml

100644100755
File mode changed.

‎.github/workflows/dokka-publish.yml

100644100755
File mode changed.

‎.gitignore

100644100755
File mode changed.

‎LICENSE

100644100755
File mode changed.

‎README.md

100644100755
File mode changed.

‎build.gradle.kts

100644100755
File mode changed.

‎examples/build.gradle.kts

100644100755
File mode changed.
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package assistant;
2+
3+
import com.cjcrafter.openai.OpenAI;
4+
import com.cjcrafter.openai.assistants.CreateAssistantRequest;
5+
import io.github.cdimascio.dotenv.Dotenv;
6+
7+
import java.util.Scanner;
8+
9+
public class Assistant {
10+
11+
// To use dotenv, you need to add the "io.github.cdimascio:dotenv-kotlin:version"
12+
// dependency. Then you can add a .env file in your project directory.
13+
public static final OpenAI openai = OpenAI.builder()
14+
.apiKey(Dotenv.load().get("OPENAI_TOKEN"))
15+
.build();
16+
17+
public static final Scanner scan = new Scanner(System.in);
18+
19+
public static void main(String[] args) {
20+
21+
int input;
22+
do {
23+
System.out.println("1. Create");
24+
System.out.println("2. Retrieve");
25+
System.out.println("3. List");
26+
System.out.println("4. Delete");
27+
System.out.println("5. Modify");
28+
System.out.println("6. Exit");
29+
30+
System.out.print("Code: ");
31+
input = Integer.parseInt(scan.nextLine());
32+
switch (input) {
33+
case 1:
34+
create();
35+
break;
36+
case 2:
37+
retrieve();
38+
break;
39+
case 3:
40+
list();
41+
break;
42+
case 4:
43+
delete();
44+
break;
45+
case 5:
46+
modify();
47+
break;
48+
case 6:
49+
System.out.println("Goodbye!");
50+
break;
51+
default:
52+
System.out.println("Invalid code!");
53+
}
54+
} while (input != 6);
55+
}
56+
57+
public static void create() {
58+
System.out.print("Model: ");
59+
String model = scan.nextLine();
60+
System.out.print("Name: ");
61+
String name = scan.nextLine();
62+
System.out.print("Description: ");
63+
String description = scan.nextLine();
64+
System.out.print("Instructions: ");
65+
String instructions = scan.nextLine();
66+
67+
CreateAssistantRequest request = CreateAssistantRequest.builder()
68+
.model(model)
69+
.name(name)
70+
.description(description)
71+
.instructions(instructions)
72+
.build();
73+
74+
System.out.println("Request: " + request);
75+
System.out.println("Response: " + openai.getAssistants().create(request));
76+
}
77+
}

‎examples/src/main/java/chat/ChatCompletion.java

100644100755
File mode changed.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /