Skip to content

Commit a69236d

Browse files
authored
[inference] propagate connector config to underlying adapter (#207202)
## Summary Related to #206710 Attach the `configuration` from the stack connector to the internal `InferenceConnector` structure we're passing down to inference adapters. This will allow the adapters to retrieve information from the stack connector, which will be useful to introduce more provider specific logic (for example, automatically detect if the underlying provider supports native function calling or not). This is also a requirement for the langchain bridge, as the chatModel will need to know which type of provider is used under the hood.
1 parent 3ca23fa commit a69236d

6 files changed

Lines changed: 23 additions & 0 deletions

File tree

x-pack/platform/packages/shared/ai-infra/inference-common/src/connectors.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,21 @@ export const COMPLETION_TASK_TYPE = 'chat_completion';
1919

2020
const allSupportedConnectorTypes = Object.values(InferenceConnectorType);
2121

22+
/**
23+
* Represents a stack connector that can be used for inference.
24+
*/
2225
export interface InferenceConnector {
26+
/** the type of the connector, see {@link InferenceConnectorType} */
2327
type: InferenceConnectorType;
28+
/** the name of the connector */
2429
name: string;
30+
/** the id of the connector */
2531
connectorId: string;
32+
/**
33+
* configuration (without secrets) of the connector.
34+
* the list of properties depends on the connector type (and subtype for inference)
35+
*/
36+
config: Record<string, string>;
2637
}
2738

2839
/**

x-pack/platform/plugins/shared/inference/server/chat_complete/utils/inference_executor.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ describe('createInferenceExecutor', () => {
1717
connectorId: 'foo',
1818
name: 'My Connector',
1919
type: InferenceConnectorType.OpenAI,
20+
config: {},
2021
};
2122

2223
beforeEach(() => {

x-pack/platform/plugins/shared/inference/server/routes/connectors.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export function registerConnectorsRoute({
4949
connectorId: connector.id,
5050
name: connector.name,
5151
type: connector.actionTypeId as InferenceConnectorType,
52+
config: connector.config ?? {},
5253
};
5354
});
5455

x-pack/platform/plugins/shared/inference/server/test_utils/inference_connector.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const createInferenceConnectorMock = (
1414
type: InferenceConnectorType.OpenAI,
1515
name: 'Inference connector',
1616
connectorId: 'connector-id',
17+
config: {},
1718
...parts,
1819
};
1920
};

x-pack/platform/plugins/shared/inference/server/util/get_connector_by_id.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ describe('getConnectorById', () => {
7878
id: 'my-id',
7979
name: 'My Name',
8080
actionTypeId: InferenceConnectorType.OpenAI,
81+
config: {
82+
propA: 'foo',
83+
propB: 42,
84+
},
8185
})
8286
);
8387

@@ -87,6 +91,10 @@ describe('getConnectorById', () => {
8791
connectorId: 'my-id',
8892
name: 'My Name',
8993
type: InferenceConnectorType.OpenAI,
94+
config: {
95+
propA: 'foo',
96+
propB: 42,
97+
},
9098
});
9199
});
92100
});

x-pack/platform/plugins/shared/inference/server/util/get_connector_by_id.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,6 @@ export const getConnectorById = async ({
4343
connectorId: connector.id,
4444
name: connector.name,
4545
type: connector.actionTypeId,
46+
config: connector.config ?? {},
4647
};
4748
};

0 commit comments

Comments
 (0)