-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ad9fe28
commit 12e3630
Showing
4 changed files
with
97 additions
and
85 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
dotCMS/src/main/java/com/dotcms/ai/service/OpenAIService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.dotcms.ai.service; | ||
|
||
import com.dotmarketing.util.json.JSONObject; | ||
|
||
public interface OpenAIService { | ||
|
||
JSONObject getSupportedModels(); | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
dotCMS/src/main/java/com/dotcms/ai/service/OpenAIServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.dotcms.ai.service; | ||
|
||
import com.dotcms.ai.app.AppConfig; | ||
import com.dotcms.ai.util.OpenAIRequest; | ||
import com.dotmarketing.util.json.JSONObject; | ||
|
||
import javax.ws.rs.HttpMethod; | ||
|
||
public class OpenAIServiceImpl implements OpenAIService { | ||
|
||
private static final String AI_MODELS_URL = "https://api.openai.com/v1/models"; | ||
|
||
private final AppConfig appConfig; | ||
|
||
public OpenAIServiceImpl(final AppConfig appConfig) { | ||
this.appConfig = appConfig; | ||
} | ||
|
||
@Override | ||
public JSONObject getSupportedModels() { | ||
final String response = OpenAIRequest.doRequest(AI_MODELS_URL, HttpMethod.GET, appConfig.getApiKey(), null); | ||
return new JSONObject(response); | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters