Skip to content

Commit

Permalink
Agent config: remove scope column (#1368)
Browse files Browse the repository at this point in the history
  • Loading branch information
PopDaph authored Sep 11, 2023
1 parent e948c6f commit c330da5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 27 deletions.
12 changes: 4 additions & 8 deletions front/lib/api/assistant/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export async function renderAgentConfigurationByModelId(
return {
id: agent.id,
sId: agent.sId,
scope: agent.scope,
scope: "workspace",
name: agent.name,
pictureUrl: agent.pictureUrl,
status: agent.status,
Expand Down Expand Up @@ -140,10 +140,7 @@ export async function getAgentConfiguration(
});

// If not found or found but non-global and not on the current workspace, return null.
if (
!agent ||
(agent.workspaceId !== owner.id && agent.scope === "workspace")
) {
if (!agent || agent.workspaceId !== owner.id) {
return null;
}

Expand All @@ -162,7 +159,7 @@ export async function getAgentConfigurations(
}
const agents = await AgentConfiguration.findAll({
where: {
[Op.or]: [{ workspaceId: owner.id }, { scope: "global" }],
workspaceId: owner.id,
},
});

Expand Down Expand Up @@ -203,7 +200,6 @@ export async function createAgentConfiguration(
status: status,
name: name,
pictureUrl: pictureUrl,
scope: "workspace",
workspaceId: owner.id,
generationConfigurationId: generation?.id || null,
retrievalConfigurationId: action?.id || null,
Expand All @@ -212,7 +208,7 @@ export async function createAgentConfiguration(
return {
id: agentConfig.id,
sId: agentConfig.sId,
scope: agentConfig.scope,
scope: "workspace",
name: agentConfig.name,
pictureUrl: agentConfig.pictureUrl,
status: agentConfig.status,
Expand Down
20 changes: 1 addition & 19 deletions front/lib/models/assistant/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ import {
import { front_sequelize } from "@app/lib/databases";
import { AgentRetrievalConfiguration } from "@app/lib/models/assistant/actions/retrieval";
import { Workspace } from "@app/lib/models/workspace";
import {
AgentConfigurationScope,
AgentConfigurationStatus,
} from "@app/types/assistant/agent";
import { AgentConfigurationStatus } from "@app/types/assistant/agent";

/**
* Configuration of Agent generation.
Expand Down Expand Up @@ -82,7 +79,6 @@ export class AgentConfiguration extends Model<
declare status: AgentConfigurationStatus;
declare name: string;
declare pictureUrl: string | null;
declare scope: AgentConfigurationScope;

declare workspaceId: ForeignKey<Workspace["id"]>;
declare generationConfigurationId: ForeignKey<
Expand Down Expand Up @@ -130,11 +126,6 @@ AgentConfiguration.init(
type: DataTypes.TEXT,
allowNull: true,
},
scope: {
type: DataTypes.STRING,
allowNull: false,
defaultValue: "workspace",
},
},
{
modelName: "agent_configuration",
Expand All @@ -148,15 +139,6 @@ AgentConfiguration.init(
{ fields: ["workspaceId", "name", "scope"], unique: true },
{ fields: ["sId"], unique: true },
],
hooks: {
beforeValidate: (agent: AgentConfiguration) => {
if (agent.scope !== "workspace" && agent.workspaceId) {
throw new Error("Workspace id must be null for global agent");
} else if (agent.scope === "workspace" && !agent.workspaceId) {
throw new Error("Workspace id must be set for non-global agent");
}
},
},
}
);

Expand Down

0 comments on commit c330da5

Please sign in to comment.