2 changed files with 2 additions and 118 deletions
@ -1,73 +0,0 @@ |
|||
package com.bfd; |
|||
|
|||
<<<<<<< HEAD |
|||
import java.util.ArrayList; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import com.alibaba.fastjson.JSON; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.bfd.qanda.token.TokenManagerV3; |
|||
import com.bfd.qanda.utils.DownLoadUtil; |
|||
|
|||
|
|||
/** |
|||
* @author jian.mao |
|||
* @date 2023年11月13日 |
|||
* @description |
|||
*/ |
|||
public class AppTest { |
|||
public static void main(String[] args) { |
|||
// String token = TokenManagerV3.getToken("46d834d33699ab5cc2cba4d1f9ffa96d", "XqIB1P3mxTMYGa5D"); |
|||
String token = TokenManagerV3.getToken("9b1539749531dfc4d7615f51df700875", "HP0azw6gD0yIsbvt"); |
|||
// String url = "https://open.bigmodel.cn/api/paas/v3/model-api/chatglm_turbo/invoke"; |
|||
// String url = "https://open.bigmodel.cn/api/paas/v4/chat/completions"; |
|||
String url = "https://open.bigmodel.cn/api/paas/v4/chat/completions"; |
|||
Map<String, Object> headers = new HashMap<String, Object>(16); |
|||
Map<String, Object> params = new HashMap<String, Object>(16); |
|||
List<Map<String, Object>> prompt = new ArrayList<Map<String,Object>>(); |
|||
Map<String, Object> chat1 = new HashMap<String, Object>(16); |
|||
String chatContent = "从下文中提取带有数字、产能等内容的关键句,没有相关内同请返回null。文本如下:共同富裕是社会主义的本质要求,是中国式现代化的重要特征。习近平总书记强调,“随着我国全面建成小康社会、开启全面建设社会主义现代化国家新征程,我们必须把促进全体人民共同富裕摆在更加重要的位置,脚踏实地,久久为功,向着这个目标更加积极有为地进行努力”。习近平总书记关于共同富裕的一系列重要论述,丰富和发展了马克思主义理论,丰富和发展了新时代中国共产党执政理念和治国方略,是对中国共产党人带领全体人民实现共同富裕奋斗目标的当代探索与实践,为我国实现第二个百年奋斗目标指明了方向、提供了遵循。"; |
|||
chat1.put("role", "user"); |
|||
chat1.put("content", chatContent); |
|||
|
|||
prompt.add(chat1); |
|||
params.put("model", "glm-3-turbo"); |
|||
params.put("messages", prompt); |
|||
params.put("temperature", 0.95); |
|||
params.put("top_p", 0.7); |
|||
headers.put("Authorization", "Bearer "+token); |
|||
headers.put("Content-Type", "application/json"); |
|||
String html = DownLoadUtil.doPost(url, JSONObject.toJSONString(params),headers); |
|||
System.out.println(html); |
|||
Map<String, Object> map = JSONObject.parseObject(html); |
|||
List<Map<String, Object>> choices = (List<Map<String, Object>>) map.get("choices"); |
|||
Map<String, Object> message = (Map<String, Object>) choices.get(0).get("message"); |
|||
String content = (String) message.get("content"); |
|||
System.out.println(content); |
|||
// List<String> parseArray = JSONObject.parseArray(content, String.class); |
|||
// System.out.println(parseArray); |
|||
// Map<String, Object> result = JSONObject.parseObject(content.replace("\\n", "")); |
|||
// System.out.println(result); |
|||
} |
|||
======= |
|||
import static org.junit.Assert.assertTrue; |
|||
|
|||
import org.junit.Test; |
|||
|
|||
/** |
|||
* Unit test for simple App. |
|||
*/ |
|||
public class AppTest |
|||
{ |
|||
/** |
|||
* Rigorous Test :-) |
|||
*/ |
|||
@Test |
|||
public void shouldAnswerWithTrue() |
|||
{ |
|||
assertTrue( true ); |
|||
} |
|||
>>>>>>> branch 'master' of http://82.156.111.58:3000/maojian/appliction_manager.git |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue