-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.ts
More file actions
55 lines (50 loc) · 1.46 KB
/
Copy pathapp.ts
File metadata and controls
55 lines (50 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { createRuntime, Intent, Proposal } from "@yav-ai/clp";
import { classifierContract } from "./contract";
// Simulated LLM that classifies text
// In production, this would call OpenAI, Anthropic, etc.
const classifierAI = async (intent: Intent): Promise<Proposal> => {
if (intent.name === "classifyText" && intent.payload.text) {
const text = intent.payload.text.toLowerCase();
// Simple keyword-based classification (simulates LLM)
let category = "general";
if (
text.includes("ai") ||
text.includes("software") ||
text.includes("code") ||
text.includes("tech")
) {
category = "tech";
} else if (
text.includes("football") ||
text.includes("soccer") ||
text.includes("game") ||
text.includes("player")
) {
category = "sports";
} else if (
text.includes("stock") ||
text.includes("market") ||
text.includes("company") ||
text.includes("money")
) {
category = "business";
} else if (
text.includes("movie") ||
text.includes("music") ||
text.includes("celebrity") ||
text.includes("film")
) {
category = "entertainment";
} else if (
text.includes("research") ||
text.includes("study") ||
text.includes("discovery") ||
text.includes("space")
) {
category = "science";
}
return { category };
}
return {};
};
export const app = createRuntime(classifierContract, classifierAI);