Skip to content

Commit aaa3028

Browse files
committed
fix: api
1 parent 989af43 commit aaa3028

File tree

5 files changed

+8
-180
lines changed

5 files changed

+8
-180
lines changed

apps/api/src/ai/agents.ts

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
import { Agent } from "@ai-sdk-tools/agents";
22
import type { AppContext } from "./config/context";
3-
import {
4-
extendedMemoryConfig,
5-
maxMemoryConfig,
6-
memoryTools,
7-
minimalMemoryConfig,
8-
standardMemoryConfig,
9-
withUserProfile,
10-
} from "./config/memory";
3+
114
import { models } from "./config/models";
125
import { buildAnalyticsInstructions } from "./prompts/analytics";
136
import { buildReflectionInstructions } from "./prompts/reflection";
@@ -17,7 +10,6 @@ import { executeQueryBuilderTool } from "./tools/execute-query-builder";
1710
import { executeSqlQueryTool } from "./tools/execute-sql-query";
1811
import { createFunnelTools } from "./tools/funnels";
1912
import { getTopPagesTool } from "./tools/get-top-pages";
20-
import { competitorAnalysisTool, webSearchTool } from "./tools/web-search";
2113

2214
/**
2315
* Creates analytics tools with context-aware funnels tools.
@@ -44,23 +36,11 @@ function createAnalyticsTools(context: {
4436
get_top_pages: getTopPagesTool,
4537
execute_query_builder: executeQueryBuilderTool,
4638
execute_sql_query: executeSqlQueryTool,
47-
web_search: webSearchTool,
48-
competitor_analysis: competitorAnalysisTool,
4939
...funnelTools,
5040
...annotationTools,
51-
...(Object.keys(memoryTools).length > 0 ? memoryTools : {}),
5241
} as const;
5342
}
5443

55-
/**
56-
* Tools available to triage agent.
57-
*/
58-
const triageTools = {
59-
web_search: webSearchTool,
60-
competitor_analysis: competitorAnalysisTool,
61-
...(Object.keys(memoryTools).length > 0 ? memoryTools : {}),
62-
} as const;
63-
6444
/**
6545
* Creates an analytics specialist agent with user-specific memory.
6646
* Handles website traffic analysis, user behavior, and performance metrics.
@@ -82,11 +62,10 @@ export function createAnalyticsAgent(
8262

8363
return new Agent({
8464
name: "analytics",
85-
model: withUserProfile(models.analytics, userId),
65+
model: models.analytics,
8666
temperature: 0.3,
8767
instructions: buildAnalyticsInstructions,
8868
tools,
89-
memory: standardMemoryConfig,
9069
modelSettings: {
9170
failureMode: {
9271
maxAttempts: 2,
@@ -113,19 +92,16 @@ export const createReflectionAgent = (
11392
) => {
11493
const config = {
11594
standard: {
116-
model: withUserProfile(models.advanced, userId),
95+
model: models.advanced,
11796
maxTurns: 15,
118-
memory: extendedMemoryConfig, // 30 messages for Sonnet
11997
},
12098
haiku: {
121-
model: withUserProfile(models.analytics, userId),
99+
model: models.analytics,
122100
maxTurns: 15,
123-
memory: standardMemoryConfig, // 20 messages for Haiku
124101
},
125102
max: {
126-
model: withUserProfile(models.advanced, userId),
103+
model: models.advanced,
127104
maxTurns: 20,
128-
memory: maxMemoryConfig, // 40 messages for deep investigations
129105
},
130106
}[variant];
131107

@@ -160,11 +136,9 @@ export function createTriageAgent(
160136
) {
161137
return new Agent({
162138
name: "triage",
163-
model: withUserProfile(models.triage, userId),
139+
model: models.triage,
164140
temperature: 0.1,
165141
instructions: buildTriageInstructions,
166-
tools: triageTools,
167-
memory: minimalMemoryConfig,
168142
modelSettings: {
169143
toolChoice: {
170144
type: "tool",

apps/api/src/ai/config/memory.ts

Lines changed: 0 additions & 80 deletions
This file was deleted.

apps/api/src/ai/tools/web-search.ts

Lines changed: 0 additions & 67 deletions
This file was deleted.

apps/api/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ const app = new Elysia()
166166

167167
export default {
168168
fetch: app.fetch,
169-
port: 3001,
169+
port: Number.parseInt(process.env.PORT ?? "3001", 10),
170170
};
171171

172172
process.on("SIGINT", async () => {

bun.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,7 @@
482482
"@databuddy/auth": "workspace:*",
483483
"@databuddy/db": "workspace:*",
484484
"@databuddy/redis": "workspace:*",
485+
"@databuddy/services": "workspace:*",
485486
"@databuddy/shared": "workspace:*",
486487
"@databuddy/validation": "workspace:*",
487488
"@opentelemetry/api": "^1.9.0",

0 commit comments

Comments
 (0)