Skip to content

Commit

Permalink
fix: fix api key for base assistant (#92)
Browse files Browse the repository at this point in the history
Co-authored-by: Aliaksandr Stsiapanay <[email protected]>
  • Loading branch information
astsiapanay and astsiapanay authored Dec 15, 2023
1 parent 4145de2 commit b061ecb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 21 deletions.
3 changes: 2 additions & 1 deletion src/main/java/com/epam/aidial/core/config/Assistants.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

import lombok.Data;

import java.util.HashMap;
import java.util.Map;

@Data
public class Assistants {
private String endpoint;
private Features features;
private Map<String, Assistant> assistants = Map.of();
private Map<String, Assistant> assistants = new HashMap<>();
}
15 changes: 1 addition & 14 deletions src/main/java/com/epam/aidial/core/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,6 @@ public Deployment selectDeployment(String deploymentId) {
}

Assistants assistants = assistant;
Assistant assistant = assistants.getAssistants().get(deploymentId);
if (assistant != null) {
return assistant;
}

if (assistants.getEndpoint() != null && ASSISTANT.equals(deploymentId)) {
Assistant baseAssistant = new Assistant();
baseAssistant.setName(ASSISTANT);
baseAssistant.setEndpoint(assistants.getEndpoint());
baseAssistant.setFeatures(assistants.getFeatures());
return baseAssistant;
}

return null;
return assistants.getAssistants().get(deploymentId);
}
}
15 changes: 9 additions & 6 deletions src/main/java/com/epam/aidial/core/config/FileConfigStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,6 @@ private void load(boolean fail) {
}

Assistants assistants = config.getAssistant();
// base assistant
if (assistants.getEndpoint() != null) {
Assistant baseAssistant = new Assistant();
baseAssistant.setName(ASSISTANT);
associateDeploymentWithApiKey(config, baseAssistant);
}
for (Map.Entry<String, Assistant> entry : assistants.getAssistants().entrySet()) {
String name = entry.getKey();
Assistant assistant = entry.getValue();
Expand All @@ -83,6 +77,15 @@ private void load(boolean fail) {

setMissingFeatures(assistant, assistants.getFeatures());
}
// base assistant
if (assistants.getEndpoint() != null) {
Assistant baseAssistant = new Assistant();
baseAssistant.setName(ASSISTANT);
baseAssistant.setEndpoint(assistants.getEndpoint());
baseAssistant.setFeatures(assistants.getFeatures());
associateDeploymentWithApiKey(config, baseAssistant);
assistants.getAssistants().put(ASSISTANT, baseAssistant);
}

for (Map.Entry<String, Application> entry : config.getApplications().entrySet()) {
String name = entry.getKey();
Expand Down

0 comments on commit b061ecb

Please sign in to comment.