Skip to content

Commit

Permalink
fix ai-settings retrieval (#14221)
Browse files Browse the repository at this point in the history
The languageModelRequirements can be undefined and
this needs to be correcly handled by callers.
  • Loading branch information
eneufeld authored Sep 26, 2024
1 parent 1a7486e commit 81ba5a8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const LanguageModelRenderer: React.FC<LanguageModelSettingsProps> = (

const findLanguageModelRequirement = async (purpose: string): Promise<LanguageModelRequirement | undefined> => {
const requirementSetting = await aiSettingsService.getAgentSettings(agent.id);
return requirementSetting?.languageModelRequirements.find(e => e.purpose === purpose);
return requirementSetting?.languageModelRequirements?.find(e => e.purpose === purpose);
};

const [lmRequirementMap, setLmRequirementMap] = React.useState<Record<string, LanguageModelRequirement>>({});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ export class FrontendLanguageModelRegistryImpl

override async selectLanguageModels(request: LanguageModelSelector): Promise<LanguageModel[]> {
await this.initialized;
const userSettings = (await this.settingsService.getAgentSettings(request.agent))?.languageModelRequirements.find(req => req.purpose === request.purpose);
const userSettings = (await this.settingsService.getAgentSettings(request.agent))?.languageModelRequirements?.find(req => req.purpose === request.purpose);
if (userSettings?.identifier) {
const model = await this.getLanguageModel(userSettings.identifier);
if (model) {
Expand Down
4 changes: 2 additions & 2 deletions packages/ai-core/src/common/settings-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ export interface AISettingsService {
}
export type AISettings = Record<string, AgentSettings>;
export interface AgentSettings {
languageModelRequirements: LanguageModelRequirement[];
enable: boolean;
languageModelRequirements?: LanguageModelRequirement[];
enable?: boolean;
}

0 comments on commit 81ba5a8

Please sign in to comment.