forked from XiaoMi/mone
-
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.
[enhancement] JCommon MongoDB supports pagination queries XiaoMi#851 (X…
- Loading branch information
Showing
7 changed files
with
112 additions
and
17 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
56 changes: 56 additions & 0 deletions
56
jcommon/ai/bytedance/src/main/java/run/mone/ai/bytedance/DoubaoClient.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,56 @@ | ||
package run.mone.ai.bytedance; | ||
|
||
|
||
import okhttp3.*; | ||
|
||
/** | ||
* @author [email protected] | ||
* @date 2024/5/18 17:20 | ||
*/ | ||
public class DoubaoClient { | ||
|
||
private static String ARK_API_KEY = ""; | ||
|
||
public static void main(String[] args) { | ||
OkHttpClient client = new OkHttpClient(); | ||
String json = "{\n" + | ||
" \"model\": \"\",\n" + | ||
" \"messages\": [\n" + | ||
" {\n" + | ||
" \"role\": \"system\",\n" + | ||
" \"content\": \"You are a helpful assistant.\"\n" + | ||
" },\n" + | ||
" {\n" + | ||
" \"role\": \"user\",\n" + | ||
" \"content\": \"Hello!\"\n" + | ||
" }\n" + | ||
" ],\n" + | ||
" \"stream\": false\n" + | ||
"}"; | ||
|
||
MediaType JSON = MediaType.get("application/json; charset=utf-8"); | ||
RequestBody body = RequestBody.create(json, JSON); | ||
|
||
Request request = new Request.Builder() | ||
.url("") | ||
.addHeader("Content-Type", "application/json") | ||
.addHeader("Authorization", "Bearer " + ARK_API_KEY) // 确保你已经设置了 ARK_API_KEY 变量 | ||
.post(body) | ||
.build(); | ||
|
||
try (Response response = client.newCall(request).execute()) { | ||
// 处理响应 | ||
if (response.isSuccessful()) { | ||
String responseBody = response.body().string(); | ||
System.out.println(responseBody); | ||
} else { | ||
System.out.println(response); | ||
} | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
|
||
} | ||
|
||
} |
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
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
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