Skip to content

Commit

Permalink
feat: Rename paranoidMode to approvalMode (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnjcsmith authored Dec 4, 2024
1 parent 70c5660 commit 6e6dc78
Show file tree
Hide file tree
Showing 15 changed files with 37 additions and 38 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,6 @@ jobs:
VERSION=${{ github.sha }}
SHORT_VERSION=$(echo ${{ github.sha }} | cut -c 1-6)
docker buildx build \
--target run \
--push \
--build-arg="VERSION=$VERSION" \
--build-arg="SHORT_VERSION=$SHORT_VERSION" \
Expand Down
2 changes: 1 addition & 1 deletion control-plane/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ configs:
# content: |
# {
# "privacyMode": 0,
# "paranoidMode": 0,
# "approvalMode": 0,
# "connectors": [
# {
# "type": "postgres",
Expand Down
16 changes: 8 additions & 8 deletions data-connector/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Inferable Data Connector is a bridge between your data systems and Inferable. Co
- 🧩 **Extensible**: Adding a new data source is as simple as writing a new connector. See the [Postgres](./src/postgres.ts) connector for an example.
- 🔄 **Adapts to schema changes**: The connector automatically adapts to schema changes by periodically fetching the data system schema. (Table definitions, API definitions, etc.)
- 🤿 **Optional Privacy Mode**: Query outputs are never sent to the model. Instead, the function returns results directly to the end user without any model involvement.
- 🔍 **Optional Paranoid Mode**: Adds an additional safety layer by requiring manual approval before executing any query so you can review the query and data before it is executed.
- 🔍 **Optional Approval Mode**: Adds an additional safety layer by requiring manual approval before executing any query so you can review the query and data before it is executed.

## Connectors

Expand Down Expand Up @@ -81,7 +81,7 @@ Example configuration:
```json
{
"privacyMode": 0,
"paranoidMode": 0,
"approvalMode": 0,
"connectors": [
{
"type": "postgres",
Expand Down Expand Up @@ -125,7 +125,7 @@ configs:
content: |
{
"privacyMode": 0,
"paranoidMode": 0,
"approvalMode": 0,
"connectors": [
{
"type": "postgres",
Expand All @@ -144,7 +144,7 @@ Each connector is defined in the `config.connectors` array.
- `config.connectors[].type`: The type of connector. Currently only `postgres` is supported.
- `config.connectors[].name`: The name of the connector. This is the Inferable service name. One will be generated if not provided.
- `config.connectors[].privacyMode`: The privacy mode. Set to `1` to enable `privacyMode` (Overrides the value at `config.privacyMode`)
- `config.connectors[].paranoidMode`: The paranoid mode. Set to `1` to enable `paranoidMode` (Overrides the value at `config.paranoidMode`)
- `config.connectors[].approvalMode`: The approval mode. Set to `1` to enable `approvalMode` (Overrides the value at `config.approvalMode`)

<details>
<summary>Postgres Connector Configuration</summary>
Expand Down Expand Up @@ -200,11 +200,11 @@ Note: This may limit some advanced reasoning capabilities that require direct da

![Privacy Mode](./assets/privacy.png)

### config.paranoidMode
### config.approvalMode

Adds an additional safety layer by requiring manual approval before executing any queries. Enable with `config.paranoidMode=1`. This can get annoying really quickly, so we've disabled it by default.
Adds an additional safety layer by requiring manual approval before executing any queries. Enable with `config.approvalMode=1`. This can get annoying really quickly, so we've disabled it by default.

![Paranoid Mode](./assets/paranoid.gif)
![Approval Mode](./assets/paranoid.gif)

## Production Deployment

Expand All @@ -219,7 +219,7 @@ When deploying to production, follow these security best practices:

3. **Query Approval**:

- Set `config.paranoidMode=1` to require manual approval of queries.
- Set `config.approvalMode=1` to require manual approval of queries.
- This provides an additional layer of control over database interactions

## Architecture
Expand Down
2 changes: 1 addition & 1 deletion data-connector/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"privacyMode": 0,
"paranoidMode": 0,
"approvalMode": 0,
"maxResultLength": 20000,
"connectors": [
{
Expand Down
6 changes: 3 additions & 3 deletions data-connector/src/graphql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ sequenceDiagram
%% Query Execution
LLM->>Connector: Execute operation
alt Paranoid Mode
alt Approval Mode
Connector->>Human: Request approval
Human-->>Connector: Approve request
end
Expand All @@ -63,7 +63,7 @@ sequenceDiagram
- **Schema Introspection**: Provides detailed type information for constructing queries
- **Automatic Function Generation**: Creates Inferable functions from GraphQL operations
- **Privacy Mode**: Prevents sensitive API responses from passing through the LLM
- **Paranoid Mode**: Requires human approval for API requests
- **Approval Mode**: Requires human approval for API requests
- **Type Validation**: Ensures queries match the GraphQL schema

## Important Considerations
Expand Down Expand Up @@ -121,7 +121,7 @@ query user($id: ID!) {

- **Authentication**: Configure through defaultHeaders
- **Privacy Mode**: Prevents sensitive API responses from reaching the LLM
- **Paranoid Mode**: Requires approval before making requests
- **Approval Mode**: Requires approval before making requests
- **Schema Validation**: Ensures queries match the GraphQL schema

### GraphQL-Specific Features
Expand Down
4 changes: 2 additions & 2 deletions data-connector/src/graphql/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class GraphQLClient implements DataConnector {
maxResultLength: number;
defaultHeaders?: Record<string, string>;
privacyMode: boolean;
paranoidMode: boolean;
approvalMode: boolean;
},
) {}

Expand Down Expand Up @@ -139,7 +139,7 @@ To understand the input and output types for this operation, use the searchGraph
},
ctx: ContextInput,
) => {
if (this.params.paranoidMode) {
if (this.params.approvalMode) {
if (!ctx.approved) {
console.log("Request requires approval");
return approvalRequest();
Expand Down
10 changes: 5 additions & 5 deletions data-connector/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const parseConfig = (connector: any) => {

if (connector.type === "postgres") {
const postgresClient = new PostgresClient({
paranoidMode: config.paranoidMode === 1,
approvalMode: config.approvalMode === 1,
privacyMode: config.privacyMode === 1,
maxResultLength: Number(config.maxResultLength),
...connector,
Expand All @@ -67,7 +67,7 @@ const parseConfig = (connector: any) => {
services.push(service);
} else if (connector.type === "open-api") {
const openAPIClient = new OpenAPIClient({
paranoidMode: config.paranoidMode === 1,
approvalMode: config.approvalMode === 1,
privacyMode: config.privacyMode === 1,
maxResultLength: Number(config.maxResultLength),
...connector,
Expand All @@ -77,7 +77,7 @@ const parseConfig = (connector: any) => {
services.push(service);
} else if (connector.type === "graphql") {
const graphQLClient = new GraphQLClient({
paranoidMode: config.paranoidMode === 1,
approvalMode: config.approvalMode === 1,
privacyMode: config.privacyMode === 1,
maxResultLength: Number(config.maxResultLength),
...connector,
Expand All @@ -87,7 +87,7 @@ const parseConfig = (connector: any) => {
services.push(service);
} else if (connector.type === "mysql") {
const mysqlClient = new MySQLClient({
paranoidMode: config.paranoidMode === 1,
approvalMode: config.approvalMode === 1,
privacyMode: config.privacyMode === 1,
maxResultLength: Number(config.maxResultLength),
...connector,
Expand All @@ -97,7 +97,7 @@ const parseConfig = (connector: any) => {
services.push(service);
} else if (connector.type === "sqlite") {
const sqliteClient = new SQLiteClient({
paranoidMode: config.paranoidMode === 1,
approvalMode: config.approvalMode === 1,
privacyMode: config.privacyMode === 1,
maxResultLength: Number(config.maxResultLength),
...connector,
Expand Down
4 changes: 2 additions & 2 deletions data-connector/src/mysql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ sequenceDiagram
%% Query Execution
LLM->>Connector: executeMysqlQuery()
alt Paranoid Mode
alt Approval Mode
Connector->>Human: Request approval
Human-->>Connector: Approve query
end
Expand All @@ -54,7 +54,7 @@ sequenceDiagram

- **Schema Analysis**: Automatically maps database structure for LLM context
- **Privacy Mode**: Prevents sensitive data from passing through the LLM
- **Paranoid Mode**: Requires human approval for query execution
- **Approval Mode**: Requires human approval for query execution
- **Sample Data**: Provides example rows to help LLM understand data patterns

## Important Considerations
Expand Down
4 changes: 2 additions & 2 deletions data-connector/src/mysql/mysql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class MySQLClient implements DataConnector {
connectionString: string;
maxResultLength: number;
privacyMode: boolean;
paranoidMode: boolean;
approvalMode: boolean;
},
) {
assert(params.schema, "Schema parameter is required");
Expand Down Expand Up @@ -107,7 +107,7 @@ export class MySQLClient implements DataConnector {
};

executeMysqlQuery = async (input: { query: string }, ctx: ContextInput) => {
if (this.params.paranoidMode) {
if (this.params.approvalMode) {
if (!ctx.approved) {
console.log("Query requires approval");
return approvalRequest();
Expand Down
6 changes: 3 additions & 3 deletions data-connector/src/open-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ sequenceDiagram
%% Request Execution
LLM->>Connector: Execute operation
alt Paranoid Mode
alt Approval Mode
Connector->>Human: Request approval
Human-->>Connector: Approve request
end
Expand All @@ -57,7 +57,7 @@ sequenceDiagram

- **Automatic Function Generation**: Creates Inferable functions from OpenAPI operations
- **Privacy Mode**: Prevents sensitive API responses from passing through the LLM
- **Paranoid Mode**: Requires human approval for API requests
- **Approval Mode**: Requires human approval for API requests
- **Parameter Validation**: Ensures requests match the OpenAPI specification
- **Default Headers**: Supports global headers for authentication
- **OperationId Filtering**: Explicitly allow certain OpenAPI operations
Expand Down Expand Up @@ -93,7 +93,7 @@ By default, the connector will attach **all** operations in the OpenAPI spec to

- **Authentication**: Configure through defaultHeaders
- **Privacy Mode**: Prevents sensitive API responses from reaching the LLM
- **Paranoid Mode**: Requires approval before making requests
- **Approval Mode**: Requires approval before making requests
- **URL Validation**: Ensures requests match the OpenAPI spec paths

### OpenAPI-Specific Features
Expand Down
4 changes: 2 additions & 2 deletions data-connector/src/open-api/open-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class OpenAPIClient implements DataConnector {
maxResultLength: number;
defaultHeaders?: Record<string, string>;
privacyMode: boolean;
paranoidMode: boolean;
approvalMode: boolean;
},
) {}

Expand Down Expand Up @@ -183,7 +183,7 @@ export class OpenAPIClient implements DataConnector {
},
ctx: ContextInput,
) => {
if (this.params.paranoidMode) {
if (this.params.approvalMode) {
if (!ctx.approved) {
console.log("Request requires approval");
return approvalRequest();
Expand Down
4 changes: 2 additions & 2 deletions data-connector/src/postgres/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ sequenceDiagram
%% Query Execution
LLM->>Connector: executePostgresQuery()
alt Paranoid Mode
alt Approval Mode
Connector->>Human: Request approval
Human-->>Connector: Approve query
end
Expand All @@ -54,7 +54,7 @@ sequenceDiagram

- **Schema Analysis**: Automatically maps database structure for LLM context
- **Privacy Mode**: Prevents sensitive data from passing through the LLM
- **Paranoid Mode**: Requires human approval for query execution
- **Approval Mode**: Requires human approval for query execution
- **Sample Data**: Provides example rows to help LLM understand data patterns

## Important Considerations
Expand Down
4 changes: 2 additions & 2 deletions data-connector/src/postgres/postgres.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class PostgresClient implements DataConnector {
connectionString: string;
maxResultLength: number;
privacyMode: boolean;
paranoidMode: boolean;
approvalMode: boolean;
},
) {
assert(params.schema, "Schema parameter is required");
Expand Down Expand Up @@ -114,7 +114,7 @@ export class PostgresClient implements DataConnector {
input: { query: string },
ctx: ContextInput,
) => {
if (this.params.paranoidMode) {
if (this.params.approvalMode) {
if (!ctx.approved) {
console.log("Query requires approval");
return approvalRequest();
Expand Down
4 changes: 2 additions & 2 deletions data-connector/src/sqlite/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ sequenceDiagram
%% Query Execution
LLM->>Connector: executeSqliteQuery()
alt Paranoid Mode
alt Approval Mode
Connector->>Human: Request approval
Human-->>Connector: Approve query
end
Expand All @@ -53,7 +53,7 @@ sequenceDiagram

- **Schema Analysis**: Automatically maps database structure for LLM context
- **Privacy Mode**: Prevents sensitive data from passing through the LLM
- **Paranoid Mode**: Requires human approval for query execution
- **Approval Mode**: Requires human approval for query execution
- **Sample Data**: Provides example rows to help LLM understand data patterns
- **File-Based**: Works with local SQLite database files

Expand Down
4 changes: 2 additions & 2 deletions data-connector/src/sqlite/sqlite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class SQLiteClient implements DataConnector {
filePath: string;
maxResultLength: number;
privacyMode: boolean;
paranoidMode: boolean;
approvalMode: boolean;
},
) {
assert(params.filePath, "File path parameter is required");
Expand Down Expand Up @@ -105,7 +105,7 @@ export class SQLiteClient implements DataConnector {
};

executeSqliteQuery = async (input: { query: string }, ctx: ContextInput) => {
if (this.params.paranoidMode) {
if (this.params.approvalMode) {
if (!ctx.approved) {
console.log("Query requires approval");
return approvalRequest();
Expand Down

0 comments on commit 6e6dc78

Please sign in to comment.