Skip to content

Commit 37ecedf

Browse files
authored
Merge branch 'main' into fix/azure-plugin-custom-host
2 parents 83493d9 + a314f5f commit 37ecedf

File tree

16 files changed

+307
-11
lines changed

16 files changed

+307
-11
lines changed

plugins/panw-prisma-airs/manifest.json

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@
22
"id": "panwPrismaAirs",
33
"name": "PANW Prisma AIRS Guardrail",
44
"description": "Blocks prompt/response when Palo Alto Networks Prisma AI Runtime Security returns action=block.",
5-
"credentials": [
6-
{
7-
"id": "AIRS_API_KEY",
8-
"name": "AIRS API Key",
9-
"type": "string",
10-
"required": true
11-
}
12-
],
5+
"credentials": {
6+
"type": "object",
7+
"properties": {
8+
"AIRS_API_KEY": {
9+
"type": "string",
10+
"label": "AIRS API Key",
11+
"description": "The API key for Palo Alto Networks Prisma AI Runtime Security",
12+
"encrypted": true
13+
}
14+
},
15+
"required": ["AIRS_API_KEY"]
16+
},
1317
"functions": [
1418
{
1519
"id": "intercept",

src/globals.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ export const RECRAFTAI: string = 'recraft-ai';
9292
export const MILVUS: string = 'milvus';
9393
export const REPLICATE: string = 'replicate';
9494
export const LEPTON: string = 'lepton';
95+
export const KLUSTER_AI: string = 'kluster-ai';
9596
export const NSCALE: string = 'nscale';
97+
export const HYPERBOLIC: string = 'hyperbolic';
9698

9799
export const VALID_PROVIDERS = [
98100
ANTHROPIC,
@@ -150,7 +152,9 @@ export const VALID_PROVIDERS = [
150152
REPLICATE,
151153
POWERED_BY,
152154
LEPTON,
155+
KLUSTER_AI,
153156
NSCALE,
157+
HYPERBOLIC,
154158
];
155159

156160
export const CONTENT_TYPES = {

src/providers/anthropic/chatComplete.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import { AnthropicStreamState } from './types';
2121

2222
interface AnthropicTool extends PromptCache {
2323
name: string;
24-
description: string;
25-
input_schema: {
24+
description?: string;
25+
input_schema?: {
2626
type: string;
2727
properties: Record<
2828
string,
@@ -32,7 +32,12 @@ interface AnthropicTool extends PromptCache {
3232
}
3333
>;
3434
required: string[];
35+
$defs: Record<string, any>;
3536
};
37+
type?: string;
38+
display_width_px?: number;
39+
display_height_px?: number;
40+
display_number?: number;
3641
}
3742

3843
interface AnthropicToolResultContentItem {
@@ -130,7 +135,9 @@ const transformAssistantMessage = (msg: Message): AnthropicMessage => {
130135
type: 'tool_use',
131136
name: toolCall.function.name,
132137
id: toolCall.id,
133-
input: JSON.parse(toolCall.function.arguments),
138+
input: toolCall.function.arguments?.length
139+
? JSON.parse(toolCall.function.arguments)
140+
: {},
134141
});
135142
});
136143
}
@@ -336,11 +343,18 @@ export const AnthropicChatCompleteConfig: ProviderConfig = {
336343
type: tool.function.parameters?.type || 'object',
337344
properties: tool.function.parameters?.properties || {},
338345
required: tool.function.parameters?.required || [],
346+
$defs: tool.function.parameters?.['$defs'] || {},
339347
},
340348
...(tool.cache_control && {
341349
cache_control: { type: 'ephemeral' },
342350
}),
343351
});
352+
} else if (tool.computer) {
353+
tools.push({
354+
...tool.computer,
355+
name: 'computer',
356+
type: tool.computer.name,
357+
});
344358
}
345359
});
346360
}

src/providers/google-vertex-ai/chatComplete.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,10 @@ export const VertexGoogleChatCompleteConfig: ProviderConfig = {
341341
param: 'generationConfig',
342342
transform: (params: Params) => transformGenerationConfig(params),
343343
},
344+
seed: {
345+
param: 'generationConfig',
346+
transform: (params: Params) => transformGenerationConfig(params),
347+
},
344348
};
345349

346350
interface AnthorpicTextContentItem {

src/providers/google-vertex-ai/transformGenerationConfig.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ export function transformGenerationConfig(params: Params) {
3434
if (params['top_logprobs']) {
3535
generationConfig['logprobs'] = params['top_logprobs']; // range 1-5, openai supports 1-20
3636
}
37+
if (params['seed']) {
38+
generationConfig['seed'] = params['seed'];
39+
}
3740
if (params?.response_format?.type === 'json_schema') {
3841
generationConfig['responseMimeType'] = 'application/json';
3942
recursivelyDeleteUnsupportedParameters(

src/providers/google/chatComplete.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ const transformGenerationConfig = (params: Params) => {
5757
if (params['top_logprobs']) {
5858
generationConfig['logprobs'] = params['top_logprobs']; // range 1-5, openai supports 1-20
5959
}
60+
if (params['seed']) {
61+
generationConfig['seed'] = params['seed'];
62+
}
6063
if (params?.response_format?.type === 'json_schema') {
6164
generationConfig['responseMimeType'] = 'application/json';
6265
recursivelyDeleteUnsupportedParameters(
@@ -415,6 +418,10 @@ export const GoogleChatCompleteConfig: ProviderConfig = {
415418
param: 'generationConfig',
416419
transform: (params: Params) => transformGenerationConfig(params),
417420
},
421+
seed: {
422+
param: 'generationConfig',
423+
transform: (params: Params) => transformGenerationConfig(params),
424+
},
418425
};
419426

420427
export interface GoogleErrorResponse {

src/providers/hyperbolic/api.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { ProviderAPIConfig } from '../types';
2+
3+
const HYPERBOLIC_API_URL = 'https://api.hyperbolic.xyz';
4+
5+
const HyperbolicAPIConfig: ProviderAPIConfig = {
6+
getBaseURL: () => HYPERBOLIC_API_URL,
7+
headers: ({ providerOptions, fn }) => {
8+
const headersObj: Record<string, string> = {
9+
Authorization: `Bearer ${providerOptions.apiKey}`,
10+
};
11+
return headersObj;
12+
},
13+
getEndpoint: ({ fn }) => {
14+
switch (fn) {
15+
case 'chatComplete':
16+
return '/v1/chat/completions';
17+
case 'imageGenerate':
18+
return '/v1/image/generation';
19+
default:
20+
return '';
21+
}
22+
},
23+
};
24+
25+
export default HyperbolicAPIConfig;
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import { HYPERBOLIC } from '../../globals';
2+
interface HyperbolicStreamChunk {
3+
id: string;
4+
object: string;
5+
created: number;
6+
model: string;
7+
choices: {
8+
index: number;
9+
message: {
10+
role?: string | null;
11+
content?: string;
12+
};
13+
finish_reason: string | null;
14+
}[];
15+
usage: {
16+
prompt_tokens: number;
17+
total_tokens: number;
18+
completion_tokens: number;
19+
};
20+
}
21+
22+
export const HyperbolicChatCompleteStreamChunkTransform = (
23+
responseChunk: string
24+
) => {
25+
let chunk = responseChunk.trim();
26+
chunk = chunk.replace(/^data: /, '');
27+
chunk = chunk.trim();
28+
29+
if (chunk === '[DONE]') {
30+
return `data: ${chunk}\n\n`;
31+
}
32+
33+
try {
34+
const parsedChunk: HyperbolicStreamChunk = JSON.parse(chunk);
35+
return (
36+
`data: ${JSON.stringify({
37+
id: parsedChunk.id,
38+
object: parsedChunk.object,
39+
created: parsedChunk.created,
40+
model: parsedChunk.model,
41+
provider: HYPERBOLIC,
42+
choices: [
43+
{
44+
index: parsedChunk.choices[0].index,
45+
message: parsedChunk.choices[0].message,
46+
finish_reason: parsedChunk.choices[0].finish_reason,
47+
},
48+
],
49+
usage: {
50+
prompt_tokens: parsedChunk.usage.prompt_tokens,
51+
total_tokens: parsedChunk.usage.total_tokens,
52+
completion_tokens: parsedChunk.usage.completion_tokens,
53+
},
54+
})}` + '\n\n'
55+
);
56+
} catch (error) {
57+
console.error('Error parsing Hyperbolic stream chunk:', error);
58+
return `data: ${chunk}\n\n`;
59+
}
60+
};
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { HYPERBOLIC } from '../../globals';
2+
import { ErrorResponse, ProviderConfig } from '../types';
3+
import { OpenAIErrorResponseTransform } from '../openai/utils';
4+
5+
export const HyperbolicImageGenerateConfig: ProviderConfig = {
6+
model: {
7+
param: 'model',
8+
required: true,
9+
},
10+
prompt: {
11+
param: 'prompt',
12+
required: true,
13+
},
14+
height: {
15+
param: 'height',
16+
},
17+
width: {
18+
param: 'width',
19+
},
20+
backend: {
21+
param: 'backend',
22+
},
23+
};
24+
25+
interface HyperbolicImageObject {
26+
url?: string;
27+
b64_json?: string;
28+
seed?: number;
29+
}
30+
31+
interface HyperbolicImageGenerateResponse {
32+
images: HyperbolicImageObject[];
33+
model: string;
34+
prompt: string;
35+
}
36+
37+
export const HyperbolicImageGenerateResponseTransform: (
38+
response: HyperbolicImageGenerateResponse | ErrorResponse,
39+
responseStatus: number
40+
) => HyperbolicImageGenerateResponse | ErrorResponse = (
41+
response,
42+
responseStatus
43+
) => {
44+
if (responseStatus !== 200 && 'error' in response) {
45+
return OpenAIErrorResponseTransform(response, HYPERBOLIC);
46+
}
47+
48+
return response;
49+
};

src/providers/hyperbolic/index.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { HYPERBOLIC } from '../../globals';
2+
import { chatCompleteParams, responseTransformers } from '../open-ai-base';
3+
import { ProviderConfigs } from '../types';
4+
import HyperbolicAPIConfig from './api';
5+
import { HyperbolicChatCompleteStreamChunkTransform } from './chatComplete';
6+
import {
7+
HyperbolicImageGenerateConfig,
8+
HyperbolicImageGenerateResponseTransform,
9+
} from './imageGenerate';
10+
11+
const HyperbolicConfig: ProviderConfigs = {
12+
chatComplete: chatCompleteParams(
13+
[],
14+
{},
15+
{
16+
top_k: { param: 'top_k', default: -1 },
17+
min_p: { param: 'min_p', default: 0, min: 0, max: 1 },
18+
repetition_penalty: { param: 'repetition_penalty', default: 1 },
19+
}
20+
),
21+
imageGenerate: HyperbolicImageGenerateConfig,
22+
api: HyperbolicAPIConfig,
23+
responseTransforms: {
24+
...responseTransformers(HYPERBOLIC, {
25+
chatComplete: true,
26+
}),
27+
'stream-chatComplete': HyperbolicChatCompleteStreamChunkTransform,
28+
imageGenerate: HyperbolicImageGenerateResponseTransform,
29+
},
30+
};
31+
32+
export default HyperbolicConfig;

0 commit comments

Comments
 (0)