generated from oracle-devrel/repo-template
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from oracle-devrel/support-meta-models
support meta models
- Loading branch information
Showing
5 changed files
with
127 additions
and
40 deletions.
There are no files selected for viewing
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
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
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
44 changes: 44 additions & 0 deletions
44
.../src/main/java/dev/victormartin/oci/genai/backend/backend/service/GenAIModelsService.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,44 @@ | ||
package dev.victormartin.oci.genai.backend.backend.service; | ||
|
||
import com.oracle.bmc.generativeai.GenerativeAiClient; | ||
import com.oracle.bmc.generativeai.model.ModelCapability; | ||
import com.oracle.bmc.generativeai.requests.ListModelsRequest; | ||
import com.oracle.bmc.generativeai.responses.ListModelsResponse; | ||
import dev.victormartin.oci.genai.backend.backend.dao.GenAiModel; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@Service | ||
public class GenAIModelsService { | ||
Logger log = LoggerFactory.getLogger(GenAIModelsService.class); | ||
|
||
@Value("${genai.compartment_id}") | ||
private String COMPARTMENT_ID; | ||
|
||
@Autowired | ||
private GenAiClientService generativeAiClientService; | ||
|
||
public List<GenAiModel> getModels() { | ||
log.info("getModels()"); | ||
ListModelsRequest listModelsRequest = ListModelsRequest.builder() | ||
.compartmentId(COMPARTMENT_ID) | ||
.build(); | ||
GenerativeAiClient client = generativeAiClientService.getClient(); | ||
ListModelsResponse response = client.listModels(listModelsRequest); | ||
return response.getModelCollection().getItems().stream() | ||
.map(m -> { | ||
List<String> capabilities = m.getCapabilities().stream() | ||
.map(ModelCapability::getValue).collect(Collectors.toList()); | ||
GenAiModel model = new GenAiModel( | ||
m.getId(), m.getDisplayName(), m.getVendor(), | ||
m.getVersion(), capabilities, m.getTimeCreated()); | ||
return model; | ||
}).collect(Collectors.toList()); | ||
} | ||
} |
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