更新联系方式使用 SharkFly 公众号来进行 OpenAI 的测试

This commit is contained in:
YuCheng Hu 2023-03-07 08:38:15 -05:00
parent 4fd7096e65
commit 7d3b7c7eb1
5 changed files with 49 additions and 41 deletions

1
.idea/vcs.xml generated
View File

@ -2,5 +2,6 @@
<project version="4"> <project version="4">
<component name="VcsDirectoryMappings"> <component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" /> <mapping directory="" vcs="Git" />
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component> </component>
</project> </project>

View File

@ -16,14 +16,47 @@ We forked this API from: https://github.com/TheoKanning/openai-java/.
The major reason we rebuild this API was OpenAI-JAVA include lombok, we think it is better build this in plain java The major reason we rebuild this API was OpenAI-JAVA include lombok, we think it is better build this in plain java
code. code.
# 联系方式
请使用下面的联系方式和我们联系。
* [社区和讨论](https://www.ossez.com/tag/chat-gpt)
| 联系方式名称 | 联系方式 |
|------------------|-----------------------------------------------|
| 电子邮件Email | [yhu@ossez.com](mailto:yhu@ossez.com) |
| QQ 或微信WeChat | 103899765 |
| QQ 交流群 | 15186112 |
| 社区论坛 Community | https://www.ossez.com/c/computer-technology/7 |
# 公众平台
我们建议您通过社区论坛来和我们进行沟通,请关注我们公众平台上的账号
## 微信公众号
![](https://cdn.ossez.com/img/sharkfly/sharkfly-qr-wechat-search-w400.png)
## 头条号
我们也在头条号上创建了我们的公众号,请扫描下面的 QR 关注我们的头条号。
![](https://cdn.ossez.com/img/cwikius/cwikus-qr-toutiao.png)
## 知乎
请关注我们的知乎https://www.zhihu.com/people/huyuchengus
# Deprecated OpenAI API Endpoint # Deprecated OpenAI API Endpoint
The [Answers](https://help.openai.com/en/articles/6233728-answers-transition-guide), * [Answers](https://help.openai.com/en/articles/6233728-answers-transition-guide),
[Classifications](https://help.openai.com/en/articles/6272941-classifications-transition-guide), * [Classifications](https://help.openai.com/en/articles/6272941-classifications-transition-guide),
and [Searches](https://help.openai.com/en/articles/6272952-search-transition-guide) APIs are deprecated, and will stop * [Searches](https://help.openai.com/en/articles/6272952-search-transition-guide)
working on December 3rd, 2022.
APIs are deprecated, and will stop working on December 3rd, 2022.
OpenAI has deprecated all Engine-based APIs. OpenAI has deprecated all Engine-based APIs.
See [Deprecated Endpoints](https://github.com/TheoKanning/openai-java#deprecated-endpoints) below for more info. See [Deprecated Endpoints](https://github.com/TheoKanning/openai-java#deprecated-endpoints) below for more info.
# How To Use # How To Use
@ -108,36 +141,6 @@ I won't remove the old endpoints from this library until OpenAI shuts them down.
- [Answers](https://beta.openai.com/docs/api-reference/answers) - [Answers](https://beta.openai.com/docs/api-reference/answers)
- [Engines](https://beta.openai.com/docs/api-reference/engines) - [Engines](https://beta.openai.com/docs/api-reference/engines)
# 联系方式
请使用下面的联系方式和我们联系。
* [社区和讨论](https://www.ossez.com/tag/chat-gpt)
| 联系方式名称 | 联系方式 |
|------------------|-----------------------------------------------|
| 电子邮件Email | [yhu@ossez.com](mailto:yhu@ossez.com) |
| QQ 或微信WeChat | 103899765 |
| QQ 交流群 | 15186112 |
| 社区论坛 Community | https://www.ossez.com/c/computer-technology/7 |
# 公众平台
我们建议您通过社区论坛来和我们进行沟通,请关注我们公众平台上的账号
## 微信公众号
![](https://cdn.ossez.com/img/cwikius/cwikius-qr-wechat-search-w400.png)
## 头条号
我们也在头条号上创建了我们的公众号,请扫描下面的 QR 关注我们的头条号。
![](https://cdn.ossez.com/img/cwikius/cwikus-qr-toutiao.png)
## 知乎
请关注我们的知乎https://www.zhihu.com/people/huyuchengus
# License # License

View File

@ -8,6 +8,7 @@ package com.ossez.openai.engine;
*/ */
@Deprecated @Deprecated
public class Engine { public class Engine {
/** /**
* An identifier for this engine, used to specify an engine for completions or searching. * An identifier for this engine, used to specify an engine for completions or searching.

View File

@ -14,23 +14,25 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
public class CompletionTest { public class CompletionTest {
String token = System.getenv("OPENAI_TOKEN"); String token = "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"; //System.getenv("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");
OpenAiService service = new OpenAiService(token); OpenAiService service = new OpenAiService(token);
@Test @Test
void createCompletion() { void createCompletion() {
CompletionRequest completionRequest = new CompletionRequestBuilder() CompletionRequest completionRequest = new CompletionRequestBuilder()
.setModel("ada") .setModel("text-davinci-003")
.setPrompt("Somebody once told me the world is gonna roll me") .setPrompt("讲一个关于程序员的笑话")
.setEcho(true) .setEcho(true)
.setN(5) // .setN(0)
.setMaxTokens(50) .setMaxTokens(500)
.setUser("testing") .setUser("testing")
.setLogitBias(new HashMap<>()) .setLogitBias(new HashMap<>())
.createCompletionRequest(); .createCompletionRequest();
List<CompletionChoice> choices = service.createCompletion(completionRequest).getChoices(); List<CompletionChoice> choices = service.createCompletion(completionRequest).getChoices();
assertEquals(5, choices.size()); System.out.println(choices.get(0).getText());
// System.out.println(choices.get(1).getText());
// assertEquals(5, choices.get(0).getText());
} }
@Test @Test

View File

@ -9,7 +9,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
public class EditTest { public class EditTest {
String token = System.getenv("OPENAI_TOKEN"); String token = "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";
OpenAiService service = new OpenAiService(token); OpenAiService service = new OpenAiService(token);
@Test @Test
@ -21,6 +21,7 @@ public class EditTest {
.createEditRequest(); .createEditRequest();
EditResult result = service.createEdit( request); EditResult result = service.createEdit( request);
System.out.println(result.getChoices().get(0).getText());
assertNotNull(result.getChoices().get(0).getText()); assertNotNull(result.getChoices().get(0).getText());
} }