1)、system,它设定了 AI 的行为和角色,和背景,可以帮助设定对话的语境,以便 AI 更好地理解其在对话中的角色 2)、user,就是我们输入的问题或请求 3)、assistant,指的是模型自己,ChatGPT它自己的回答 messages=[ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "...
publicstaticList<ChatMessage> chatList=newArrayList<>();publicstaticString chatModel="gpt-3.5-turbo";publicstaticString roleSystem="system";publicstaticString roleUser="user";publicstaticString roleAssistant="assistant";/*** 一轮对话的完成 *以start为开始标志--true开始,以finish为结束标志--true结束,...
{ 'id': 'chatcmpl-6p9XYPYSTTRi0xEviKjjilqrWU2Ve', 'object': 'chat.completion', 'created': 1677649420, 'model': 'gpt-3.5-turbo', 'usage': {'prompt_tokens': 56, 'completion_tokens': 31, 'total_tokens': 87}, 'choices': [ { 'message': { 'role': 'assistant', 'content': ...
AzureOpenAIServiceClientazureOpenAIServiceClient=newAzureOpenAIServiceClient(apiKey,deployment,endpoint,apiVersion);ChatRequestrequest=newChatRequest();request.setTemperature(0.9);request.setMessages(Arrays.asList(newChatMessage(ChatMessage.Role.SYSTEM,"You are an AI assistant that helps people find fun and...
"role": "assistant", "content": "\n\nHello there, how may I assist you today?", }, "finish_reason": "stop" }], "usage": { "prompt_tokens": 9, "completion_tokens": 12, "total_tokens": 21 } } 所以,我们只需要获取到content字段, 就能我们和收到ChatGPT聊天的结果了。
chatgpt-java是一个OpenAI的Java版SDK,支持开箱即用。目前以支持官网全部Api。支持最新版本GPT-3.5-Turbo模型以及whisper-1模型。增加chat聊天对话以及语音文件转文字,语音翻译。开源地址:https://github.com/Grt1228/chatgpt-java 快速开始 导入pom依赖 <dependency><groupId>com.unfbx</groupId><artifactId>chatgpt...
{"id":"chatcmpl-7DZFY2pLRRhg6ZabTrjrPA8EJpwCr","object":"chat.completion","created":1683468120,"model":"gpt-3.5-turbo-0301","usage":{"prompt_tokens":46,"completion_tokens":7,"total_tokens":53},"choices":[{"message":{"role":"assistant","content":"The weather is really nice tod...
我在前一段时间突发奇想,就使用java来调用chatgpt的接口,然后写了一个简单小程序,也上了热榜第一,java调用chatgpt接口,实现专属于自己的人工智能助手,事实上,这个程序毛病挺多的,最不能让人接受的一点就是返回速度非常缓慢(即使使用非常好的外网服务器)。
RequestBody body = RequestBody.create(mediaType, “{\”model\”: \”gpt-3.5-turbo\”,\”messages\”:[{\”role\”:\”system\”,\”content\”:\”You are a helpful assistant.\”},{\”role\”:\”user\”,\”content\”:\”Who won the world series in 2020?\”},{\”role\”:\”...
{"id": "chatcmpl-123","object": "chat.completion","created": 1677652288,"model": "gpt-3.5-turbo-0125","system_fingerprint": "fp_44709d6fcb","choices": [{"index": 0,"message": {"role": "assistant","content": "\n\nHello there, how may I assist you today?",},"logprobs"...