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

chore: bump version to 0.0.8 & update model list #621

Merged
merged 2 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
13 changes: 13 additions & 0 deletions java/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,16 @@ response.getResults().forEach(data -> {
System.out.println(data.getRelevanceScore());
});
```

### 插件编排

千帆 SDK 支持调用插件编排后的服务,用于大模型 + 插件能力的组合。

```java
PluginResponse response = new Qianfan().plugin()
.endpoint("plugin-service-endpoint")
.fileurl("https://www.baidu.com/img/flexible/logo/pc/[email protected]")
.query("这个图片是什么")
.execute();
System.out.println(response.getResult());
```
2 changes: 1 addition & 1 deletion java/example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<dependency>
<groupId>com.baidubce</groupId>
<artifactId>qianfan</artifactId>
<version>0.0.6</version>
<version>0.0.7</version>
</dependency>
</dependencies>
</project>
27 changes: 27 additions & 0 deletions java/example/src/main/java/com/baidubce/PluginExample.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.baidubce;

import com.baidubce.qianfan.Qianfan;
import com.baidubce.qianfan.model.plugin.PluginResponse;

/**
* 本示例实现了Plugin调用流程
*/
public class PluginExample {
public static void main(String[] args) {
chatOcr();
}

private static void chatOcr() {
Qianfan qianfan = new Qianfan();
PluginResponse response = qianfan.plugin()
// 请前往千帆大模型平台控制台->插件编排->配置插件应用服务
// 配置完成后进行上线,并进入详情页获取服务endpoint
// 示例: https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/plugin/endpoint/
.endpoint("endpoint")
// 智慧图问场景通过fileurl传入图片
.fileurl("https://www.baidu.com/img/flexible/logo/pc/[email protected]")
.query("这个图片是什么")
.execute();
System.out.println(response.getResult());
}
}
2 changes: 1 addition & 1 deletion java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.baidubce</groupId>
<artifactId>qianfan</artifactId>
<version>0.0.7</version>
<version>0.0.8</version>
<packaging>jar</packaging>

<name>qianfan</name>
Expand Down
2 changes: 1 addition & 1 deletion java/src/main/java/com/baidubce/qianfan/QianfanClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import java.util.Map;

class QianfanClient {
private static final String SDK_VERSION = "0.0.7";
private static final String SDK_VERSION = "0.0.8";
private static final String QIANFAN_URL_TEMPLATE = "%s/rpc/2.0/ai_custom/v1/wenxinworkshop%s";
private static final String EXTRA_PARAM_REQUEST_SOURCE = "request_source";
private static final String REQUEST_SOURCE_PREFIX = "qianfan_java_sdk_v";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,28 +74,24 @@ public ModelEndpointRetriever(IAuth auth) {
dynamicTypeModelEndpointMap.put(type, new HashMap<>());
}

typeModelEndpointMap.get(ModelType.CHAT).put("ernie-4.0-8k-latest", "ernie-4.0-8k-latest");
typeModelEndpointMap.get(ModelType.CHAT).put("ernie-4.0-8k-0613", "ernie-4.0-8k-0613");
typeModelEndpointMap.get(ModelType.CHAT).put("ernie-3.5-8k-0613", "ernie-3.5-8k-0613");
typeModelEndpointMap.get(ModelType.CHAT).put("ernie-4.0-8k", "completions_pro");
typeModelEndpointMap.get(ModelType.CHAT).put("ernie-4.0-8k-preemptible", "completions_pro_preemptible");
typeModelEndpointMap.get(ModelType.CHAT).put("ernie-4.0-8k-preview", "ernie-4.0-8k-preview");
typeModelEndpointMap.get(ModelType.CHAT).put("ernie-4.0-8k-preview-0518", "completions_adv_pro");
typeModelEndpointMap.get(ModelType.CHAT).put("ernie-4.0-8k-latest", "ernie-4.0-8k-latest");
typeModelEndpointMap.get(ModelType.CHAT).put("ernie-4.0-8k-0329", "ernie-4.0-8k-0329");
typeModelEndpointMap.get(ModelType.CHAT).put("ernie-4.0-8k-0104", "ernie-4.0-8k-0104");
typeModelEndpointMap.get(ModelType.CHAT).put("ernie-4.0-8k-0613", "ernie-4.0-8k-0613");
typeModelEndpointMap.get(ModelType.CHAT).put("ernie-3.5-8k", "completions");
typeModelEndpointMap.get(ModelType.CHAT).put("ernie-3.5-8k-0205", "ernie-3.5-8k-0205");
typeModelEndpointMap.get(ModelType.CHAT).put("ernie-3.5-8k-1222", "ernie-3.5-8k-1222");
typeModelEndpointMap.get(ModelType.CHAT).put("ernie-3.5-4k-0205", "ernie-3.5-4k-0205");
typeModelEndpointMap.get(ModelType.CHAT).put("ernie-3.5-8k-preemptible", "completions_preemptible");
typeModelEndpointMap.get(ModelType.CHAT).put("ernie-3.5-8k-preview", "ernie-3.5-8k-preview");
typeModelEndpointMap.get(ModelType.CHAT).put("ernie-3.5-8k-0329", "ernie-3.5-8k-0329");
typeModelEndpointMap.get(ModelType.CHAT).put("ernie-3.5-128k", "ernie-3.5-128k");
typeModelEndpointMap.get(ModelType.CHAT).put("ernie-3.5-8k-0613", "ernie-3.5-8k-0613");
typeModelEndpointMap.get(ModelType.CHAT).put("ernie-speed-8k", "ernie_speed");
typeModelEndpointMap.get(ModelType.CHAT).put("ernie-speed-128k", "ernie-speed-128k");
typeModelEndpointMap.get(ModelType.CHAT).put("ernie-character-8k-0321", "ernie-char-8k");
typeModelEndpointMap.get(ModelType.CHAT).put("ernie-character-8k", "ernie-char-8k");
typeModelEndpointMap.get(ModelType.CHAT).put("ernie-character-fiction-8k", "ernie-char-fiction-8k");
typeModelEndpointMap.get(ModelType.CHAT).put("ernie-lite-8k-0922", "eb-instant");
typeModelEndpointMap.get(ModelType.CHAT).put("ernie-lite-8k-0308", "ernie-lite-8k");
typeModelEndpointMap.get(ModelType.CHAT).put("ernie-lite-8k", "ernie-lite-8k");
typeModelEndpointMap.get(ModelType.CHAT).put("ernie-functions-8k", "ernie-func-8k");
typeModelEndpointMap.get(ModelType.CHAT).put("ernie-tiny-8k", "ernie-tiny-8k");
Expand All @@ -117,15 +113,21 @@ public ModelEndpointRetriever(IAuth auth) {
typeModelEndpointMap.get(ModelType.CHAT).put("xuanyuan-70b-chat-4bit", "xuanyuan_70b_chat");
typeModelEndpointMap.get(ModelType.CHAT).put("chatlaw", "chatlaw");
typeModelEndpointMap.get(ModelType.CHAT).put("aquilachat-7b", "aquilachat_7b");

typeModelEndpointMap.get(ModelType.COMPLETIONS).put("sqlcoder-7b", "sqlcoder_7b");
typeModelEndpointMap.get(ModelType.COMPLETIONS).put("codellama-7b-instruct", "codellama_7b_instruct");

typeModelEndpointMap.get(ModelType.EMBEDDINGS).put("embedding-v1", "embedding-v1");
typeModelEndpointMap.get(ModelType.EMBEDDINGS).put("bge-large-zh", "bge_large_zh");
typeModelEndpointMap.get(ModelType.EMBEDDINGS).put("bge-large-en", "bge_large_en");
typeModelEndpointMap.get(ModelType.EMBEDDINGS).put("tao-8k", "tao_8k");

typeModelEndpointMap.get(ModelType.TEXT_2_IMAGE).put("stable-diffusion-xl", "sd_xl");

typeModelEndpointMap.get(ModelType.IMAGE_2_TEXT).put("fuyu-8b", "fuyu_8b");

typeModelEndpointMap.get(ModelType.RERANKER).put("bce-reranker-base_v1", "bce_reranker_base");

// Compatibility for old model names
typeModelEndpointMap.get(ModelType.CHAT).put("ernie-bot-turbo", "eb-instant");
typeModelEndpointMap.get(ModelType.CHAT).put("ernie-bot", "completions");
Expand All @@ -135,6 +137,12 @@ public ModelEndpointRetriever(IAuth auth) {
typeModelEndpointMap.get(ModelType.CHAT).put("ernie-bot-turbo-ai", "ai_apaas");
typeModelEndpointMap.get(ModelType.CHAT).put("eb-turbo-appbuilder", "ai_apaas");
typeModelEndpointMap.get(ModelType.CHAT).put("qianfan-chinese-llama-2-13b", "qianfan_chinese_llama_2_13b");
typeModelEndpointMap.get(ModelType.CHAT).put("ernie-4.0-8k-preemptible", "completions_pro_preemptible");
typeModelEndpointMap.get(ModelType.CHAT).put("ernie-3.5-8k-preemptible", "completions_preemptible");
typeModelEndpointMap.get(ModelType.CHAT).put("ernie-3.5-8k-1222", "ernie-3.5-8k-1222");
typeModelEndpointMap.get(ModelType.CHAT).put("ernie-3.5-4k-0205", "ernie-3.5-4k-0205");
typeModelEndpointMap.get(ModelType.CHAT).put("ernie-character-8k-0321", "ernie-char-8k");
typeModelEndpointMap.get(ModelType.CHAT).put("ernie-lite-8k-0308", "ernie-lite-8k");
}

private static String parseEndpoint(String url) {
Expand Down