Cockpit

REST API für Localmind Cockpit

Das Cockpit selbst hat eine REST API, mit welcher du Agenten erstellen, bearbeiten, befragen und löschen, sowie Datenpools und Daten anlegen, bearbeiten und löschen kannst. Damit kannst du das Localmind Cockpit direkt in deine Applikationen anbinden.

Den API-Schlüssel findest du direkt im Cockpit unter “Einstellungen” im Reiter “API Schlüssel”.

Dieser API-Schlüssel ermöglicht Lese- und Schreibrechte auf das Localmind Cockpit, beachte deshalb alle gängigen Best Practices im sicheren Umgang mit API-Schlüsseln.

Inhaltsverzeichnis

Agent Endpoints

Agent - Query

POST /api/agents/{id}/query

  • Erforderlich im Path: ID des Agenten (id) – die ID findest du im Einstellungen-Menü deines Agenten
  • Erforderlich im Header: API-Schlüssel (Bearer DEIN_API_TOKEN)
  • Erforderlich im Body: query

Request

curl --request POST \
  --url https://api.cockpit.localmind.ai/agents/{id}/query \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "conversationId": "<string>",
  "filters": {
    "custom_ids": [],
    "datasource_ids": []
  },
  "frequencyPenalty": 123,
  "maxTokens": 123,
  "modelName": "localmind-pro",
  "presencePenalty": 123,
  "promptTemplate": "<string>",
  "promptType": "raw",
  "query": "<string>",
  "streaming": true,
  "systemPrompt": "<string>",
  "temperature": 123,
  "topP": 123,
  "userPrompt": "<string>",
  "visitorId": "<string>"
}'

Response

curl --request POST \
  --url https://api.cockpit.localmind.ai/agents \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "description": "<string>",
  "modelName": "localmind-pro",
  "name": "<string>",
  "promptTemplate": "<string>",
  "promptType": "raw",
  "systemPrompt": "<string>",
  "temperature": 123,
  "userPrompt": "<string>",
  "visibility": "public"
}'

Agent - Create

POST /api/agents

  • Erforderlich im Header: API-Schlüssel (Bearer DEIN_API_TOKEN)
  • Erforderlich im Body: description

Request

curl --request POST \
  --url https://api.cockpit.localmind.ai/agents \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "description": "<string>",
  "modelName": "localmind-pro",
  "name": "<string>",
  "promptTemplate": "<string>",
  "promptType": "raw",
  "systemPrompt": "<string>",
  "temperature": 0.2,
  "userPrompt": "<string>",
  "visibility": "public"
}'

Response

{
  "description": "<string>",
  "id": "<string>",
  "modelName": "localmind-pro",
  "name": "<string>",
  "promptTemplate": "<string>",
  "promptType": "raw",
  "systemPrompt": "<string>",
  "temperature": 123,
  "userPrompt": "<string>",
  "visibility": "public"
}

Agent - Get

GET /api/agents/{id}

  • Erforderlich im Header: API-Schlüssel (Bearer DEIN_API_TOKEN)
  • Erforderlich im Path: ID des Agenten (id)

Request

curl --request GET \
  --url https://api.cockpit.localmind.ai/agents/{id} \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{}'

Response

{
  "description": "<string>",
  "id": "<string>",
  "modelName": "localmind-pro",
  "name": "<string>",
  "promptTemplate": "<string>",
  "promptType": "raw",
  "systemPrompt": "<string>",
  "temperature": 123,
  "userPrompt": "<string>",
  "visibility": "public"
}

Agent - Update

PATCH /agents/{id}

  • Erforderlich im Header: API-Schlüssel (Bearer DEIN_API_TOKEN)
  • Erforderlich im Path: ID des Agenten (id)
  • Erforderlich im Body: description

Request

curl --request PATCH \
  --url https://api.cockpit.localmind.ai/agents/{id} \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "description": "<string>",
  "modelName": "localmind-pro",
  "name": "<string>",
  "promptTemplate": "<string>",
  "promptType": "raw",
  "systemPrompt": "<string>",
  "temperature": 123,
  "userPrompt": "<string>",
  "visibility": "public"
}'

Response

{
  "description": "<string>",
  "id": "<string>",
  "modelName": "localmind-pro",
  "name": "<string>",
  "promptTemplate": "<string>",
  "promptType": "raw",
  "systemPrompt": "<string>",
  "temperature": 123,
  "userPrompt": "<string>",
  "visibility": "public"
}

Agent - Delete

DELETE /api/agents/{id}

  • Erforderlich im Header: API-Schlüssel (Bearer DEIN_API_TOKEN)
  • Erforderlich im Path: ID des Agenten (id)

Request

curl --request DELETE \
  --url https://api.cockpit.localmind.ai/agents/{id} \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{}'

Response

{
  "description": "<string>",
  "id": "<string>",
  "modelName": "localmind-pro",
  "name": "<string>",
  "promptTemplate": "<string>",
  "promptType": "raw",
  "systemPrompt": "<string>",
  "temperature": 123,
  "userPrompt": "<string>",
  "visibility": "public"
}

Datenpool Endpoints

Datenpool - Query

POST /api/datastores/{id}/query

  • Erforderlich im Header: API-Schlüssel (Bearer DEIN_API_TOKEN)
  • Erforderlich im Path: ID des Datenpools (id)
  • Erforderlich im Body: query
  • Mithilfe des topK Parameters bestimmst du die maximale anzahl an Resultaten, die zu retreiven sind.

Request

curl --request POST \
  --url https://api.cockpit.localmind.ai/datastores/{id}/query \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "filters": {
    "custom_ids": [],
    "datasource_ids": []
  },
  "query": "<string>",
  "topK": 5
}'

Response

[
  {
    "datasource_id": "<string>",
    "datasource_name": "<string>",
    "score": 123,
    "source": "<string>",
    "text": "<string>"
  }
]

Datenpool - Create

POST /api/datastores

  • Erforderlich im Header: API-Schlüssel (Bearer DEIN_API_TOKEN)
  • Erforderlich im Path: ID des Datenpools (id)
  • Erforderlich im Body: description, type (type ist immer qdrant)

Request

curl --request POST \
  --url https://api.cockpit.localmind.ai/datastores \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "description": "<string>",
  "name": "<string>",
  "type": "qdrant"
}'

Response

{
  "description": "<string>",
  "id": "<string>",
  "name": "<string>",
  "type": "qdrant",
  "visibility": "public"
}

Datenpool - Get

GET /api/datastores/{id}

  • Erforderlich im Header: API-Schlüssel (Bearer DEIN_API_TOKEN)
  • Erforderlich im Path: ID des Datenpools (id)

Request

curl --request GET \
  --url https://api.cockpit.localmind.ai/datastores/{id} \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{}'

Response

{
  "description": "<string>",
  "id": "<string>",
  "name": "<string>",
  "type": "qdrant",
  "visibility": "public"
}

Datenpool - Update

PATCH /api/datastores/{id}

  • Erforderlich im Header: API-Schlüssel (Bearer DEIN_API_TOKEN)
  • Erforderlich im Path: ID des Datenpools (id)
  • Erforderlich im Body: description, type (type ist immer qdrant)

Request

curl --request PATCH \
  --url https://api.cockpit.localmind.ai/datastores/{id} \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "description": "<string>",
  "name": "<string>",
  "type": "qdrant"
}'

Response

{
  "description": "<string>",
  "id": "<string>",
  "name": "<string>",
  "type": "qdrant",
  "visibility": "public"
}

Datenpool - Delete

PATCH /api/datastores/{id}

  • Erforderlich im Header: API-Schlüssel (Bearer DEIN_API_TOKEN)
  • Erforderlich im Path: ID des Datenpools (id)

Request

curl --request DELETE \
  --url https://api.chaindesk.ai/datastores/{id} \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{}'

Response

{
  "description": "<string>",
  "id": "<string>",
  "name": "<string>",
  "type": "qdrant",
  "visibility": "public"
}

Daten Endpoints

Daten - Create

POST /api/datasources

  • Erforderlich im Header: API-Schlüssel (Bearer DEIN_API_TOKEN)
  • Erforderlich im Body: config, datastoreId, type (file, web_site, web_page)

Request

curl --request POST \
  --url https://api.cockpit.localmind.ai/datasources \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "config": {
    "sitemap": "<string>",
    "source_url": "<string>"
  },
  "custom_id": "<string>",
  "datastoreId": "<string>",
  "type": "web_page"
}'

Response

{
  "config": {},
  "createdAt": "2023-12-25",
  "groupId": "<string>",
  "id": "<string>",
  "lastSynch": "2023-12-25",
  "name": "<string>",
  "status": "unsynched",
  "type": "<string>",
  "updatedAt": "2023-12-25"
}

Datei-Upload: Unterstützte Dateitypen (mime types)

  • text/csv
  • text/plain
  • text/markdown
  • application/pdf
  • application/json
  • application/vnd.openxmlformats-officedocument.presentationml.presentation
  • application/vnd.openxmlformats-officedocument.wordprocessingml.document
  • application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

JavaScript Beispiel für Daten des Typs "file"

const apiUrl = 'https://api.cockpit.localmind.ai';
const apiKey = 'XXX';
const datastoreId = 'XXX';

const fileName = 'test.pdf';
const buffer = fs.readFileSync(fileName);

const formData = new FormData();

formData.append(
  'file',
  new Blob([buffer], {
    type: 'application/pdf',
  }),
  fileName
);

formData.append('type', 'file');
formData.append('datastoreId', datastoreId);
formData.append('fileName', fileName);

const res = await fetch(`${apiUrl}/datasources`, {
  method: 'POST',
  body: formData,
  headers: {
    Authorization: `Bearer ${apiKey}`,
  },
});

JavaScript Beispiel für Daten des Typs "web_page"

const apiUrl = 'https://api.cockpit.localmind.ai';
const apiKey = 'XXX';
const datastoreId = 'XXX';

const res = await fetch(`${apiUrl}/datasources`, {
  method: 'POST',
  body: JSON.stringify({
    datastoreId,
    type: 'web_page',
    name: 'Nuclear Fusion - Wikipedia',
    config: {
      source_url: 'https://en.wikipedia.org/wiki/Nuclear_fusion',
    },
  }),
  headers: {
    ContentType: 'application/json',
    Authorization: `Bearer ${apiKey}`,
  },
});

JavaScript Beispiel für Daten des Typs "web_site" mit XML Sitemap

const apiUrl = 'https://api.cockpit.localmind.ai';
const apiKey = 'XXX';
const datastoreId = 'XXX';

const res = await fetch(`${apiUrl}/datasources`, {
  method: 'POST',
  body: JSON.stringify({
    datastoreId,
    type: 'web_site',
    name: 'Chaindesk Docs',
    config: {
      // Sitemap
      sitemap: 'https://docs.chaindesk.ai/sitemap.xml',

      // Or Auto Discovery
      source_url: 'https://docs.databerry.ai',
    },
  }),
  headers: {
    ContentType: 'application/json',
    Authorization: `Bearer ${apiKey}`,
  },
});

Daten - Get

GET /api/datasources/{id}

  • Erforderlich im Header: API-Schlüssel (Bearer DEIN_API_TOKEN)
  • Erforderlich im Path: ID deiner Datei (id)

Request

curl --request GET \
  --url https://api.cockpit.localmind.ai/datasources/{id} \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{}'

Response

{
  "config": {},
  "createdAt": "2023-12-25",
  "groupId": "<string>",
  "id": "<string>",
  "lastSynch": "2023-12-25",
  "name": "<string>",
  "status": "unsynched",
  "type": "<string>",
  "updatedAt": "2023-12-25"
}

Daten - Delete

DELETE /api/datasources/{id}

  • Erforderlich im Header: API-Schlüssel (Bearer DEIN_API_TOKEN)
  • Erforderlich im Path: ID deiner Datei (id)

Request

curl --request DELETE \
  --url https://api.cockpit.localmind.ai/datasources/{id} \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{}'

Response

{
  "config": {},
  "createdAt": "2023-12-25",
  "groupId": "<string>",
  "id": "<string>",
  "lastSynch": "2023-12-25",
  "name": "<string>",
  "status": "unsynched",
  "type": "<string>",
  "updatedAt": "2023-12-25"
}

Lokale und sichere KI-Lösungen.

Kontaktiere uns bei Fragen unter hello@localmind.ai