Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

fix: purchase order tool location

Brad Barbinf6dc79f329db
diff --git a/apps/erp/app/routes/api+/ai+/chat+/tools/create-purchase-order.ts b/apps/erp/app/routes/api+/ai+/chat+/tools/create-purchase-order.ts
index 0a69e8691d..a8f7bd725d 100644
--- a/apps/erp/app/routes/api+/ai+/chat+/tools/create-purchase-order.ts
+++ b/apps/erp/app/routes/api+/ai+/chat+/tools/create-purchase-order.ts
@@ -11,6 +11,7 @@ import {
import { getAppUrl, getCarbonServiceRole } from "@carbon/auth";
import { LuShoppingCart } from "react-icons/lu";
+import { getEmployeeJob } from "~/modules/people/people.service";
import { getNextSequence } from "~/modules/settings";
import { path } from "~/utils/path";
import type { ChatContext } from "../agents/shared/context";
@@ -50,6 +51,7 @@ export const createPurchaseOrderTool = tool({
supplier,
supplierPayment,
supplierShipping,
+ employeeJob,
// purchaser
] = await Promise.all([
getNextSequence(
@@ -65,7 +67,7 @@ export const createPurchaseOrderTool = tool({
getSupplierById(context.client, args.supplierId),
getSupplierPayment(context.client, args.supplierId),
getSupplierShipping(context.client, args.supplierId),
- // getEmployeeJob(client, context.userId, context.companyId),
+ getEmployeeJob(context.client, context.userId, context.companyId),
]);
if (!supplierInteraction.data) {
@@ -133,7 +135,7 @@ export const createPurchaseOrderTool = tool({
}
const purchaseOrderId = order.data?.[0]?.id ?? "";
- const locationId = null; // TODO
+ const locationId = employeeJob.data?.locationId ?? null;
if (!purchaseOrderId) {
return {
diff --git a/packages/database/supabase/functions/embed/index.ts b/packages/database/supabase/functions/embed/index.ts
index 01aa295218..452866f86c 100644
--- a/packages/database/supabase/functions/embed/index.ts
+++ b/packages/database/supabase/functions/embed/index.ts
@@ -3,12 +3,11 @@ import { sql } from "https://esm.sh/[email protected]";
import { Kysely } from "https://esm.sh/v135/[email protected]/dist/cjs/kysely.d.ts";
import "jsr:@supabase/functions-js/edge-runtime.d.ts";
import z from "npm:zod@^3.24.1";
-import { DB, getConnectionPool, getDatabaseClient } from "../lib/database.ts";
import { generateEmbedding } from "../lib/ai/embedding.ts";
+import { DB, getConnectionPool, getDatabaseClient } from "../lib/database.ts";
const pool = getConnectionPool(1);
const db = getDatabaseClient<DB>(pool);
-const model = new Supabase.ai.Session("gte-small");
const jobSchema = z.object({
jobId: z.number(),
diff --git a/scripts/create-agent.ts b/scripts/create-agent.ts
index 94b8f7e33c..b34d5acb62 100644
--- a/scripts/create-agent.ts
+++ b/scripts/create-agent.ts
@@ -74,7 +74,7 @@ export const ${agentName}Agent = createAgent({
// exampleTool: exampleToolTool,
},
handoffs: [],
- maxTurns: 5,
+ maxTurns: 10,
});
`;
@@ -86,7 +86,9 @@ try {
console.log(`2. Add tools to the tools object`);
console.log(`3. Update the instructions and capabilities`);
console.log(`4. Configure handoffs to other agents if needed`);
- console.log(`5. Add the agent to the AgentStatus type in app/components/Chat/lib/types.ts`);
+ console.log(
+ `5. Add the agent to the AgentStatus type in app/components/Chat/lib/types.ts`
+ );
console.log(
`6. Import and add the agent to handoffs in orchestration-agent.ts if needed`
);