Skip to content

Commit d1553a0

Browse files
committed
added cloud genAI service detection
1 parent ce799a4 commit d1553a0

File tree

1 file changed

+114
-0
lines changed

1 file changed

+114
-0
lines changed

dist/cloud_genAI_services.js

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
//[genAI-Service-Detection]
2+
// uncomment for webpagetest
3+
4+
// not sure if the list is exhaustive
5+
console.log("Running genAI-Service-Detection metric");
6+
try{
7+
const patterns = {
8+
// GenAI Services
9+
'Azure AI Services': {
10+
regEx: /https:\/\/[^\/]+\.services\.ai\.azure\.com\/models/,
11+
},
12+
'AWS SageMaker': {
13+
regEx: /https:\/\/runtime\.sagemaker\.[^\/]+\.amazonaws\.com/,
14+
},
15+
'IBM Watson ML': {
16+
regEx: /https:\/\/[^\/]+\.ml\.cloud\.ibm\.com/,
17+
},
18+
'Alibaba Cloud ML': {
19+
regEx: /https:\/\/[^\/]+\.fc\.[^\/]+\.aliyuncs\.com/,
20+
},
21+
'Huawei Cloud AI': {
22+
regEx: /https:\/\/iam\.[^\/]+\.myhuaweicloud\.com\/v3/,
23+
},
24+
'Google Vertex AI': {
25+
regEx: /https:\/\/[^\/]+\/v1\/[^\/]+:predict/,
26+
},
27+
'Amazon Bedrock': {
28+
regEx: /https:\/\/bedrock\.[^\/]+\.amazonaws\.com/,
29+
},
30+
'Azure OpenAI': {
31+
regEx: /https:\/\/[^\/]+\.openai\.azure\.com\/openai\/deployments\/[^\/]+/,
32+
},
33+
34+
// Common GenAI APIs
35+
'OpenAI': {
36+
regEx: /api\.openai\.com/,
37+
},
38+
'ChatGPT':{
39+
regEx: /chatgpt\.com/,
40+
},
41+
'Anthropic': {
42+
regEx: /api\.anthropic\.com/,
43+
},
44+
'Google PaLM': {
45+
regEx: /generativelanguage\.googleapis\.com/,
46+
},
47+
'Cohere': {
48+
regEx: /api\.cohere\.ai/,
49+
},
50+
'Hugging Face': {
51+
regEx: /(.*\.)?huggingface\.co/,
52+
},
53+
'Mistral': {
54+
regEx: /(.*\.)?mistral\.ai/,
55+
},
56+
'Perplexity': {
57+
regEx: /(.*\.)?perplexity\.ai/,
58+
},
59+
'Bard': {
60+
regEx: /(.*\.)?bard\.google\.com/,
61+
},
62+
'Groq': {
63+
regEx: /api\.groq\.com/,
64+
},
65+
'Cerebras': {
66+
regEx: /api\.cerebras\.ai/,
67+
},
68+
69+
// Proxy Services
70+
'OpenRouter (Proxy)': {
71+
regEx: /https:\/\/openrouter\.ai\/api\/v1/,
72+
},
73+
'LangChain (Proxy)': {
74+
regEx: /\/langserve\/|\/agent\/|\/llm(-invoke)?\/|\/chain\/|\/tools?\/|\/predict\/|\/invoke\//i,
75+
},
76+
'Flowise (Proxy)': {
77+
regEx: /\/api\/v1\/prediction|\/flowise-api/i,
78+
},
79+
'Poe': {
80+
regEx: /(.*\.)?poe\.com/,
81+
},
82+
'Replicate': {
83+
regEx: /(.*\.)?replicate\.com/,
84+
},
85+
}
86+
87+
const requestBodies = $WPT_REQUESTS;
88+
89+
// Iterate over all response bodies and over all patterns and populate the
90+
// result object.
91+
const result = {};
92+
93+
94+
requestBodies.forEach((har) => {
95+
const url = har.url
96+
if (!url){
97+
return
98+
}
99+
for (const [key, value] of Object.entries(patterns)) {
100+
if (value.regEx.test(har.url)) {
101+
if (result[key] && !result[key].includes(url)) {
102+
result[key].push(url.trim().replace(/\/$/, ""));
103+
} else {
104+
result[key] = [url.trim().replace(/\/$/, "")];
105+
}
106+
}
107+
}
108+
});
109+
110+
return result
111+
}
112+
catch(e){
113+
return{error: e.message}
114+
}

0 commit comments

Comments
 (0)