Skip to content
This repository has been archived by the owner on Apr 8, 2024. It is now read-only.

Commit

Permalink
新增转发copilot接口(支持流式传输,接入one-api) /v1/chat/completions
Browse files Browse the repository at this point in the history
PandoraNext-tokensTool v 0.5.7版本
1.新增转发copilot接口(支持流式传输,接入one-api) /v1/chat/completions\n
2.新增查看copilot模型接口 /v1/models
3.修改已知bug
  • Loading branch information
Yanyutin753 committed Dec 27, 2023
1 parent cc9d042 commit 0400a38
Show file tree
Hide file tree
Showing 57 changed files with 551 additions and 91 deletions.
7 changes: 1 addition & 6 deletions rearServer/.idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions rearServer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<properties>
<java.version>11</java.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down Expand Up @@ -81,6 +82,12 @@
<artifactId>netty-common</artifactId>
<version>4.1.97.Final</version>
</dependency>
<!-- plexpt chatGpt依赖-->
<dependency>
<groupId>com.github.plexpt</groupId>
<artifactId>chatgpt</artifactId>
<version>4.3.0</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.tokensTool.pandoraNext.chat;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ChatCompletionResult {

private String id;

private String object;

private Long created;

private String model;

private List<Choice> choices;

private Usage usage;

private String system_fingerprint;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.tokensTool.pandoraNext.chat;

import com.plexpt.chatgpt.entity.chat.Message;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class Choice {

private long index;

private Message message;

private String finish_reason;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.tokensTool.pandoraNext.chat;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ContentChoice {

private String text;


private int index;


private String logprobs;


private String finish_reason;




}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package com.tokensTool.pandoraNext.chat;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ContentCompletion {

/**
* 指定要使用的模型
*/
private String model;


/**
* 提供一个文本片段,作为模型生成文本的启动点或上下文
*/
private String prompt;


/**
* 限制生成文本的最大长度,以一定数量的 tokens(标记)为单位。
*/
private int max_tokens;


/**
* 控制生成文本的创造性,较高的值增加随机性,较低的值使生成更加确定性。
*/
private int temperature;


/**
* 仅考虑概率累积最高的 tokens,而忽略其他概率较低的 tokens。
*/
private int top_p;


/**
* 生成多少个不同的文本样本。
*/
private int n;


/**
* 指定是否启用流式传输,即是否在生成文本时逐步接收输出。
*/
private Boolean stream;


/**
* 是否返回每个 token 的对数概率。
*/
private String logprobs;


/**
* 指定在生成文本时的停止条件,即遇到哪个字符串时停止生成。
*/
private String stop;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.tokensTool.pandoraNext.chat;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;


/**
* 内容补全返回结果
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ContentResult {

private String id;

private String object;

private Long created;

private String model;

private List<ContentChoice> choices;

private Usage usage;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.tokensTool.pandoraNext.chat;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.plexpt.chatgpt.entity.chat.Message;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class Conversation {

private String model;

private List<Message> messages;

private Boolean stream;

private int temperature;

@JsonProperty("presence_penalty")
private int presencePenalty;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.tokensTool.pandoraNext.chat;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class Model {

private String id;

private String object;

private Long created;

private String owned_by;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.tokensTool.pandoraNext.chat;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ModelResult {

private String object;

private List<Model> data;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.tokensTool.pandoraNext.chat;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class Usage {

/**
* 提示词消耗的tokens
*/
@JsonProperty("prompt_tokens")
private long promptTokens;

/**
* 回答消耗的tokens
*/
@JsonProperty("completion_tokens")
private long completionTokens;

/**
* 本次对话消耗的tokens
*/
@JsonProperty("total_tokens")
private long totalTokens;




}
Loading

0 comments on commit 0400a38

Please sign in to comment.