Skip to content

Commit

Permalink
Merge pull request #1309 from solliancenet/jdh-agent-form-updates
Browse files Browse the repository at this point in the history
Management Portal agent form updates
  • Loading branch information
ciprianjichici authored Aug 1, 2024
2 parents 1b9e35f + 7236bfd commit a956591
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 170 deletions.
58 changes: 10 additions & 48 deletions src/ui/ManagementPortal/js/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type {
AppConfigUnion,
AgentIndex,
AgentGatekeeper,
AIModel,
FilterRequest,
CreateAgentRequest,
CheckNameResponse,
Expand Down Expand Up @@ -463,59 +464,12 @@ export default {
return agentGetResult;
},

// async updateAgent(agentId: string, request: CreateAgentRequest): Promise<any> {
// return await this.fetch(
// `/instances/${this.instanceId}/providers/FoundationaLLM.Agent/agents/${agentId}?api-version=${this.apiVersion}`,
// {
// method: 'POST',
// body: request,
// },
// );
// },

async upsertAgent(agentId: string, agentData: CreateAgentRequest): Promise<any> {
// Deep copy the agent object to prevent modifiying its references
const agent = JSON.parse(JSON.stringify(agentData)) as CreateAgentRequest;

if (agent.orchestration_settings.orchestrator.toLowerCase() === 'langchain' ||
agent.orchestration_settings.orchestrator.toLowerCase() === 'semantickernel') {
for (const [propertyName, propertyValue] of Object.entries(
agent.orchestration_settings.endpoint_configuration,
)) {
if (!propertyValue) {
continue;
}

if (propertyValue.startsWith('FoundationaLLM:') &&
propertyName !== 'api_key') {
// Get the static value from the app config.
const appConfigResult = await this.getAppConfig(propertyValue);
// Set the static value to the endpoint configuration.
agent.orchestration_settings.endpoint_configuration[propertyName] = appConfigResult.resource.value;
}
}
}

for (const [propertyName, propertyValue] of Object.entries(
agent.orchestration_settings.model_parameters,
)) {
if (!propertyValue) {
continue;
}

if (propertyValue.startsWith('FoundationaLLM:')) {
// Get the static value from the app config.
const appConfigResult = await this.getAppConfig(propertyValue);
// Set the static value to the endpoint configuration.
agent.orchestration_settings.model_parameters[propertyName] = appConfigResult.resource.value;
}
}

return await this.fetch(
`/instances/${this.instanceId}/providers/FoundationaLLM.Agent/agents/${agentId}?api-version=${this.apiVersion}`,
{
method: 'POST',
body: agent,
body: agentData,
},
);
},
Expand Down Expand Up @@ -606,6 +560,14 @@ export default {
return data;
},

async getAIModels(): Promise<ResourceProviderGetResult<AIModel>[]> {
const data = await this.fetch(
`/instances/${this.instanceId}/providers/FoundationaLLM.AIModel/aiModels?api-version=${this.apiVersion}`,
) as ResourceProviderGetResult<AIModel>[];

return data;
},

/*
Role Assignments
*/
Expand Down
41 changes: 19 additions & 22 deletions src/ui/ManagementPortal/js/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export type Agent = ResourceBase & {
type: 'knowledge-management' | 'analytics';
inline_context: boolean;

ai_model_object_id: string;

vectorization: {
dedicated_pipeline: boolean;
indexing_profile_object_ids: string[];
Expand All @@ -44,22 +46,12 @@ export type Agent = ResourceBase & {
sessions_enabled: boolean;
orchestration_settings: {
orchestrator: string;
endpoint_configuration: {
endpoint: string;
api_key: string;
api_version: string;
operation_type: string;
};
model_parameters: {
temperature: number;
deployment_name: string;
};
};
conversation_history: {
enabled: boolean;
max_history: number;
};
gatekeeper: {
gatekeeper_settings: {
use_system_setting: boolean;
options: string[];
};
Expand Down Expand Up @@ -102,6 +94,19 @@ export type ExternalOrchestrationService = ResourceBase & {
resolved_api_key: string;
};

export type AIModel = ResourceBase & {
name: string;
type: string;
// The object id of the APIEndpointConfiguration object providing the configuration for the API endpoint used to interact with the model.
endpoint_object_id: string;
// The version of the AI model.
version?: string | null;
// The name of the deployment corresponding to the AI model.
deployment_name?: string | null;
// Dictionary with default values for the model parameters.
model_parameters: { [key: string]: any };
};

export interface ConfigurationReferenceMetadata {
isKeyVaultBacked: boolean;
}
Expand Down Expand Up @@ -296,6 +301,8 @@ export type CreateAgentRequest = ResourceBase & {
name: string;
inline_context: boolean;

ai_model_object_id: string;

language_model: {
type: string;
provider: string;
Expand All @@ -322,22 +329,12 @@ export type CreateAgentRequest = ResourceBase & {
sessions_enabled: boolean;
orchestration_settings: {
orchestrator: string;
endpoint_configuration: {
endpoint: string;
api_key: string;
api_version: string;
operation_type: string;
};
model_parameters: {
temperature: number;
deployment_name: string;
};
};
conversation_history: {
enabled: boolean;
max_history: number;
};
gatekeeper: {
gatekeeper_settings: {
use_system_setting: boolean;
options: string[];
};
Expand Down
Loading

0 comments on commit a956591

Please sign in to comment.