mirror of
https://github.com/YuWanTingbb/unofficial-gpt4.git
synced 2025-10-15 06:39:54 +00:00
add
This commit is contained in:
4
.idea/compiler.xml
generated
4
.idea/compiler.xml
generated
@@ -7,14 +7,14 @@
|
||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<module name="benchmark-jibber" />
|
||||
<module name="gpt-4-copilot-native" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
<bytecodeTargetLevel target="17" />
|
||||
</component>
|
||||
<component name="JavacSettings">
|
||||
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
|
||||
<module name="benchmark-jibber" options="-parameters" />
|
||||
<module name="gpt-4-copilot-native" options="-parameters" />
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
1
.idea/misc.xml
generated
1
.idea/misc.xml
generated
@@ -1,4 +1,3 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CodeInsightWorkspaceSettings">
|
||||
<option name="optimizeImportsOnTheFly" value="true" />
|
||||
|
1
.idea/vcs.xml
generated
1
.idea/vcs.xml
generated
@@ -2,5 +2,6 @@
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
32
pom.xml
32
pom.xml
@@ -8,9 +8,9 @@
|
||||
<version>3.2.0</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>com.example</groupId>
|
||||
<artifactId>benchmark-jibber</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<groupId>com.gpt4.copilot</groupId>
|
||||
<artifactId>gpt-4-copilot-native</artifactId>
|
||||
<version>gpt-4-copilot-native</version>
|
||||
<name>benchmark-jibber</name>
|
||||
<description>Demo project for Spring Boot with GraalVM Native Image</description>
|
||||
<properties>
|
||||
@@ -40,6 +40,32 @@
|
||||
<artifactId>rita</artifactId>
|
||||
<version>2.4.501</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<!-- json-->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>2.0.32</version>
|
||||
</dependency>
|
||||
<!-- okhttp依赖-->
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<version>2.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.vaadin.external.google</groupId>
|
||||
<artifactId>android-json</artifactId>
|
||||
<version>0.0.20131108.vaadin1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright © 2023, Oracle and/or its affiliates.
|
||||
* Released under the Universal Permissive License v1.0 as shown at https://oss.oracle.com/licenses/upl/.
|
||||
*/
|
||||
|
||||
package com.example.benchmarks.jibber;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
||||
@SpringBootApplication
|
||||
@RestController
|
||||
public class DemoApplication {
|
||||
|
||||
@Autowired
|
||||
Jabberwocky j;
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(DemoApplication.class, args);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, path = "/jibber")
|
||||
ResponseEntity<String> jibber() {
|
||||
return ResponseEntity.ok(j.generate());
|
||||
}
|
||||
}
|
@@ -1,68 +0,0 @@
|
||||
/*
|
||||
* Copyright © 2023, Oracle and/or its affiliates.
|
||||
* Released under the Universal Permissive License v1.0 as shown at https://oss.oracle.com/licenses/upl/.
|
||||
*/
|
||||
|
||||
package com.example.benchmarks.jibber;
|
||||
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import rita.RiMarkov;
|
||||
|
||||
@Service
|
||||
@Scope("singleton")
|
||||
public class Jabberwocky {
|
||||
//
|
||||
private RiMarkov r;
|
||||
|
||||
public Jabberwocky() {
|
||||
loadModel();
|
||||
}
|
||||
|
||||
private void loadModel() {
|
||||
//
|
||||
String text = "’Twas brillig, and the slithy toves " +
|
||||
"Did gyre and gimble in the wabe: " +
|
||||
"All mimsy were the borogoves, " +
|
||||
"And the mome raths outgrabe. " +
|
||||
"Beware the Jabberwock, my son! " +
|
||||
"The jaws that bite, the claws that catch! " +
|
||||
"Beware the Jubjub bird, and shun " +
|
||||
"The frumious Bandersnatch! " +
|
||||
"He took his vorpal sword in hand; " +
|
||||
"Long time the manxome foe he sought— " +
|
||||
"So rested he by the Tumtum tree " +
|
||||
"And stood awhile in thought. " +
|
||||
"And, as in uffish thought he stood, " +
|
||||
"The Jabberwock, with eyes of flame, " +
|
||||
"Came whiffling through the tulgey wood, " +
|
||||
"And burbled as it came! " +
|
||||
"One, two! One, two! And through and through " +
|
||||
"The vorpal blade went snicker-snack! " +
|
||||
"He left it dead, and with its head " +
|
||||
"He went galumphing back. " +
|
||||
"And hast thou slain the Jabberwock? " +
|
||||
"Come to my arms, my beamish boy! " +
|
||||
"O frabjous day! Callooh! Callay! " +
|
||||
"He chortled in his joy. " +
|
||||
"’Twas brillig, and the slithy toves " +
|
||||
"Did gyre and gimble in the wabe: " +
|
||||
"All mimsy were the borogoves, " +
|
||||
"And the mome raths outgrabe.";
|
||||
this.r = new RiMarkov(3);
|
||||
this.r.addText(text);
|
||||
}
|
||||
public String generate() {
|
||||
String[] lines = this.r.generate(10);
|
||||
StringBuilder b = new StringBuilder();
|
||||
//
|
||||
for (String line : lines ) {
|
||||
b.append(line);
|
||||
b.append("<br/>\n");
|
||||
}
|
||||
//
|
||||
return b.toString();
|
||||
}
|
||||
|
||||
}
|
29
src/main/java/com/gpt4/copilot/config/CorsConfig.java
Normal file
29
src/main/java/com/gpt4/copilot/config/CorsConfig.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package com.gpt4.copilot.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
||||
import org.springframework.web.filter.CorsFilter;
|
||||
|
||||
/**
|
||||
* @author Yangyang
|
||||
* @create 2023-09-21 17:00
|
||||
*/
|
||||
@Configuration
|
||||
public class CorsConfig {
|
||||
@Bean
|
||||
public CorsFilter corsFilter() {
|
||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||
CorsConfiguration config = new CorsConfiguration();
|
||||
// 允许本地所有端口,也可以设置具体的域名
|
||||
config.addAllowedOrigin("*");
|
||||
// 允许所有请求头
|
||||
config.addAllowedHeader("*");
|
||||
// 允许所有HTTP方法
|
||||
config.addAllowedMethod("*");
|
||||
source.registerCorsConfiguration("/**", config);
|
||||
return new CorsFilter(source);
|
||||
}
|
||||
}
|
||||
|
18
src/main/java/com/gpt4/copilot/config/WebConfig.java
Normal file
18
src/main/java/com/gpt4/copilot/config/WebConfig.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package com.gpt4.copilot.config;
|
||||
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.AsyncSupportConfigurer;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Configuration
|
||||
public class WebConfig implements WebMvcConfigurer {
|
||||
|
||||
@Override
|
||||
public void configureAsyncSupport(AsyncSupportConfigurer configurer) {
|
||||
// 设置默认异步请求超时时间,例如设置为6分钟
|
||||
configurer.setDefaultTimeout(TimeUnit.MINUTES.toMillis(6));
|
||||
}
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
package com.gpt4.copilot.controller;
|
||||
|
||||
import org.springframework.boot.web.servlet.error.ErrorController;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author Yangyang
|
||||
* @create 2024-02-05 1:18
|
||||
*/
|
||||
@RestController
|
||||
public class CustomErrorController implements ErrorController {
|
||||
|
||||
private static final String PATH = "/error";
|
||||
|
||||
@RequestMapping(value = PATH)
|
||||
public ResponseEntity<String> error() {
|
||||
return new ResponseEntity<>("<!DOCTYPE html>\n" +
|
||||
"<html lang=\"en\">\n" +
|
||||
"<head>\n" +
|
||||
" <meta charset=\"UTF-8\">\n" +
|
||||
" <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n" +
|
||||
" <title>Document</title>\n" +
|
||||
"</head>\n" +
|
||||
"<body>\n" +
|
||||
" <p>Thanks you use gpt4-copilot-java</p>\n" +
|
||||
" <p><a href=\"https://apifox.com/apidoc/shared-4301e565-a8df-48a0-85a5-bda2c4c3965a\">详细使用文档</a></p>\n" +
|
||||
" <p><a href=\"https://github.com/Yanyutin753/gpt4-copilot-java-sh\">项目地址</a></p>\n" +
|
||||
"</body>\n" +
|
||||
"</html>\n", HttpStatus.OK);
|
||||
}
|
||||
}
|
1003
src/main/java/com/gpt4/copilot/controller/chatController.java
Normal file
1003
src/main/java/com/gpt4/copilot/controller/chatController.java
Normal file
File diff suppressed because it is too large
Load Diff
45
src/main/java/com/gpt4/copilot/copilotApplication.java
Normal file
45
src/main/java/com/gpt4/copilot/copilotApplication.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package com.gpt4.copilot;
|
||||
|
||||
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
/**
|
||||
* @author YANGYANG
|
||||
*/
|
||||
|
||||
/**
|
||||
* 定时注解
|
||||
* @author YANGYANG
|
||||
*/
|
||||
@Slf4j
|
||||
@EnableScheduling
|
||||
@SpringBootApplication
|
||||
public class copilotApplication {
|
||||
|
||||
@Value("${server.servlet.context-path}")
|
||||
private String contextPath;
|
||||
@Value("${server.port}")
|
||||
private String serverPort;
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(copilotApplication.class, args);
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void initialize() {
|
||||
System.out.println("------------------------------------------------------");
|
||||
System.out.println("----------原神gpt4-copilot-java v0.0.3启动成功------------");
|
||||
System.out.println("* 优化打字机输出");
|
||||
System.out.println("* 增加自定义获取token渠道");
|
||||
System.out.println("* 增加反代/copilot_internal/v2/token接口");
|
||||
System.out.println("URL地址:http://0.0.0.0:" + serverPort + contextPath +"");
|
||||
System.out.println("------------------------------------------------------");
|
||||
}
|
||||
}
|
||||
|
47
src/main/java/com/gpt4/copilot/pojo/Result.java
Normal file
47
src/main/java/com/gpt4/copilot/pojo/Result.java
Normal file
@@ -0,0 +1,47 @@
|
||||
package com.gpt4.copilot.pojo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Result {
|
||||
|
||||
/**
|
||||
* 响应码,1 代表成功; 0 代表失败
|
||||
*/
|
||||
|
||||
private Integer code;
|
||||
/**
|
||||
* 响应信息 描述字符串
|
||||
*/
|
||||
|
||||
private String msg;
|
||||
/**
|
||||
* 返回的数据
|
||||
*/
|
||||
private Object data;
|
||||
|
||||
/**
|
||||
* 增删改 成功响应
|
||||
*/
|
||||
public static Result success() {
|
||||
return new Result(1, "success", null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询 成功响应
|
||||
*/
|
||||
public static Result success(Object data) {
|
||||
return new Result(1, "success", data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 失败响应
|
||||
*/
|
||||
public static Result error(String msg) {
|
||||
return new Result(0, msg, null);
|
||||
}
|
||||
}
|
@@ -1 +1,15 @@
|
||||
management.endpoints.web.exposure.include=metrics,health,info,prometheus
|
||||
# server.port
|
||||
server.port=8081
|
||||
# SpringBoot 2.* prefix
|
||||
server.servlet.context-path=/
|
||||
# gpt4 sleep time
|
||||
gpt4_sleepTime=100
|
||||
# gpt3 sleep time
|
||||
gpt3_sleepTime=0
|
||||
# changeSleepTime's password
|
||||
password=gpt4-copilot-java
|
||||
# self-define get_token_url
|
||||
get_token_url=https://api.cocopilot.org/copilot_internal/v2/token
|
||||
|
||||
|
||||
|
@@ -1 +1,15 @@
|
||||
management.endpoints.web.exposure.include=metrics,health,info,prometheus
|
||||
# server.port
|
||||
server.port=8081
|
||||
# SpringBoot 2.* prefix
|
||||
server.servlet.context-path=/
|
||||
# gpt4 sleep time
|
||||
gpt4_sleepTime=100
|
||||
# gpt3 sleep time
|
||||
gpt3_sleepTime=0
|
||||
# changeSleepTime's password
|
||||
password=gpt4-copilot-java
|
||||
# self-define get_token_url
|
||||
get_token_url=https://api.cocopilot.org/copilot_internal/v2/token
|
||||
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
BIN
target/classes/com/gpt4/copilot/config/CorsConfig.class
Normal file
BIN
target/classes/com/gpt4/copilot/config/CorsConfig.class
Normal file
Binary file not shown.
BIN
target/classes/com/gpt4/copilot/config/WebConfig.class
Normal file
BIN
target/classes/com/gpt4/copilot/config/WebConfig.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
target/classes/com/gpt4/copilot/controller/chatController.class
Normal file
BIN
target/classes/com/gpt4/copilot/controller/chatController.class
Normal file
Binary file not shown.
BIN
target/classes/com/gpt4/copilot/copilotApplication.class
Normal file
BIN
target/classes/com/gpt4/copilot/copilotApplication.class
Normal file
Binary file not shown.
BIN
target/classes/com/gpt4/copilot/pojo/Result.class
Normal file
BIN
target/classes/com/gpt4/copilot/pojo/Result.class
Normal file
Binary file not shown.
Reference in New Issue
Block a user