Skip to content

Commit

Permalink
fixing dp to cp flow ai configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
CrowleyRajapakse committed Oct 18, 2024
1 parent d005635 commit 8056f7b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
24 changes: 12 additions & 12 deletions apim-apk-agent/pkg/managementserver/rest_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,17 +160,18 @@ func createAPIYaml(apiCPEvent *APICPEvent) (string, string) {
if apiCPEvent.API.APIType == "GraphQL" {
apiType = "GRAPHQL"
}
apiSubType := "DEFAULT"
if apiCPEvent.API.APISubType != "" {
apiSubType = apiCPEvent.API.APISubType
}
var aiConfiguration = make(map[string]interface{})
if apiCPEvent.API.AIConfiguration.LLMProviderName != "" || apiCPEvent.API.AIConfiguration.LLMProviderAPIVersion != "" {

var subTypeConfiguration = make(map[string]interface{})
if apiCPEvent.API.APISubType != "" || apiCPEvent.API.AIConfiguration.LLMProviderID != "" ||
apiCPEvent.API.AIConfiguration.LLMProviderName != "" ||
apiCPEvent.API.AIConfiguration.LLMProviderAPIVersion != "" {
logger.LoggerMgtServer.Debugf("AI Configuration: %+v", apiCPEvent.API.AIConfiguration)
aiConfiguration["llmProviderName"] = apiCPEvent.API.AIConfiguration.LLMProviderName
aiConfiguration["llmProviderApiVersion"] = apiCPEvent.API.AIConfiguration.LLMProviderAPIVersion
subTypeConfiguration["subtype"] = apiCPEvent.API.APISubType
subTypeConfiguration["_configuration"] = "{\"llmProviderId\":\"" +
apiCPEvent.API.AIConfiguration.LLMProviderID + "\"}"
}
logger.LoggerMgtServer.Debugf("Recieved AI Configuration: %+v", aiConfiguration)
logger.LoggerMgtServer.Debugf("Subtype Configuration: %+v", subTypeConfiguration)

data := map[string]interface{}{
"type": "api",
"version": "v4.4.0",
Expand All @@ -189,7 +190,6 @@ func createAPIYaml(apiCPEvent *APICPEvent) (string, string) {
"enableSchemaValidation": false,
"enableSubscriberVerification": false,
"type": apiType,
"subType": apiSubType,
"transport": []string{"http", "https"},
"endpointConfig": map[string]interface{}{
"endpoint_type": apiCPEvent.API.EndpointProtocol,
Expand All @@ -211,8 +211,8 @@ func createAPIYaml(apiCPEvent *APICPEvent) (string, string) {
"scopes": scopes,
},
}
if len(aiConfiguration) > 0 {
data["data"].(map[string]interface{})["aiConfiguration"] = aiConfiguration
if len(subTypeConfiguration) > 0 {
data["data"].(map[string]interface{})["subtypeConfiguration"] = subTypeConfiguration
}
// TODO when we start to process sandbox we need to have this if condition. For now we remove sandbox endpoint always.
// if apiCPEvent.API.SandEndpoint == "" {
Expand Down
1 change: 1 addition & 0 deletions apim-apk-agent/pkg/managementserver/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ type AIRL struct {

// AIConfiguration holds the AI configuration
type AIConfiguration struct {
LLMProviderID string `json:"llmProviderID"`
LLMProviderName string `json:"llmProviderName"`
LLMProviderAPIVersion string `json:"llmProviderApiVersion"`
}
Expand Down

0 comments on commit 8056f7b

Please sign in to comment.