-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathAiBotClassification.java
More file actions
39 lines (34 loc) · 1.59 KB
/
AiBotClassification.java
File metadata and controls
39 lines (34 loc) · 1.59 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
package com.mixpanel.mixpanelapi;
/**
* Result of classifying a user-agent string against the AI bot database.
* If matched, {@link #isAiBot()} returns true and bot details are available.
* If not matched, {@link #isAiBot()} returns false and all other fields are null.
* Instances are immutable and thread-safe.
*
* @see AiBotClassifier
*/
public class AiBotClassification {
private static final AiBotClassification NOT_A_BOT = new AiBotClassification(false, null, null, null);
private final boolean mIsAiBot;
private final String mBotName;
private final String mProvider;
private final String mCategory;
private AiBotClassification(boolean isAiBot, String botName, String provider, String category) {
mIsAiBot = isAiBot;
mBotName = botName;
mProvider = provider;
mCategory = category;
}
static AiBotClassification match(String botName, String provider, String category) {
return new AiBotClassification(true, botName, provider, category);
}
static AiBotClassification noMatch() { return NOT_A_BOT; }
/** @return true if the user-agent was identified as an AI bot */
public boolean isAiBot() { return mIsAiBot; }
/** @return the bot name (e.g., "GPTBot"), or null if not an AI bot */
public String getBotName() { return mBotName; }
/** @return the bot provider (e.g., "OpenAI"), or null if not an AI bot */
public String getProvider() { return mProvider; }
/** @return the bot category ("indexing", "retrieval", or "agent"), or null if not an AI bot */
public String getCategory() { return mCategory; }
}