Skip to content

Commit

Permalink
[inference] propagate connector config to underlying adapter (elastic…
Browse files Browse the repository at this point in the history
…#207202)

## Summary

Related to elastic#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.
  • Loading branch information
pgayvallet authored and JoseLuisGJ committed Jan 27, 2025
1 parent 94eb4c5 commit 8c71607
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,21 @@ export const COMPLETION_TASK_TYPE = 'chat_completion';

const allSupportedConnectorTypes = Object.values(InferenceConnectorType);

/**
* Represents a stack connector that can be used for inference.
*/
export interface InferenceConnector {
/** the type of the connector, see {@link InferenceConnectorType} */
type: InferenceConnectorType;
/** the name of the connector */
name: string;
/** the id of the connector */
connectorId: string;
/**
* configuration (without secrets) of the connector.
* the list of properties depends on the connector type (and subtype for inference)
*/
config: Record<string, string>;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ describe('createInferenceExecutor', () => {
connectorId: 'foo',
name: 'My Connector',
type: InferenceConnectorType.OpenAI,
config: {},
};

beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export function registerConnectorsRoute({
connectorId: connector.id,
name: connector.name,
type: connector.actionTypeId as InferenceConnectorType,
config: connector.config ?? {},
};
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const createInferenceConnectorMock = (
type: InferenceConnectorType.OpenAI,
name: 'Inference connector',
connectorId: 'connector-id',
config: {},
...parts,
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ describe('getConnectorById', () => {
id: 'my-id',
name: 'My Name',
actionTypeId: InferenceConnectorType.OpenAI,
config: {
propA: 'foo',
propB: 42,
},
})
);

Expand All @@ -87,6 +91,10 @@ describe('getConnectorById', () => {
connectorId: 'my-id',
name: 'My Name',
type: InferenceConnectorType.OpenAI,
config: {
propA: 'foo',
propB: 42,
},
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@ export const getConnectorById = async ({
connectorId: connector.id,
name: connector.name,
type: connector.actionTypeId,
config: connector.config ?? {},
};
};

0 comments on commit 8c71607

Please sign in to comment.