Zum Hauptinhalt springen

PeakPrivacy Assistants API

Mit der Assistants API von PeakPrivacy können Sie KI-Assistenten mit Modellen wie GPT-4 oder Mistral erstellen, aktualisieren, löschen, auflisten und abfragen, mit Optionen für Temperatur, Anweisungen und Anonymisierung.

K
Verfasst von Katja Gersdorf
Vor über 3 Monaten aktualisiert

Auth

HEADERS

Key

Value

Api-token

X-Requested-With

XMLHttpRequest

Accept

application/json

401 - Unauthenticated; API Token is invalid or expired OR Subscription is inactive

{
"error": "Unauthenticated"
}

POST Create Assistant

https://api.peakprivacy.ch/v1/ai/assistants

REQUEST BODY SCHEMA: application/json

Key

Value

name

string (required)
Name des Assistenten

model

string (required)
Gibt das Modell an, das standardmäßig auf den Assistenten angewendet wird.
Unterstützte Modelle:
gpt-4-1106-preview
gpt-4
gpt-3.5-turbo-1106
mistral-tiny
mistral-small
mistral-medium
mistral-swiss

instructions

text (optional)
Zusätzliche Anweisungen für den Assistenten. Beispiel: „Bitte gib die Antwort auf Spanisch an.“

temperature

number (required)
[ 0 .. 1 ]
Welche Temperatur, zwischen 0,0 und 1,0, soll verwendet werden? Höhere Werte wie 0,8 machen die Ausgabe zufälliger, während niedrigere Werte wie 0,2 sie fokussierter und deterministischer machen.

anonymize

boolean (required)
Default: true
Ob für den Prompt eine Anonymisierung verwendet werden soll. Die Antwortzeit kann sich aufgrund der Anonymisierungs- und Deanonymisierungsalgorithmen geringfügig verlängern.

file_ids

array of strings (optional)
IDs der Dateien, die dem Assistenten beigefügt werden sollen

REQUEST BODY EXAMPLE

{
"name": "Invoices",
"model": "mistral-swiss",
"instructions": "Please provide the answer in Spanish",

"temperature": 0.5,
"anonymize": true,
"file_ids": ["b7454f54-aa96-4306-b64d-83343d7bf4a4"]
}

Example request

curl --location --request POST 'https://api.peakprivacy.ch/v1/ai/assistants' \
--header 'Api-token: api-token' \
--header 'X-Requested-With: XMLHttpRequest' \
--header 'Accept: application/json' \
--header 'Content-Type:/ application/json' \
--data '{
"name": "Invoices",
"model": "mistral-swiss",
"instructions": "Please provide the answer in Spanish",

"temperature": 0.5,
"anonymize": true,
"file_ids": ["b7454f54-aa96-4306-b64d-83343d7bf4a4"]
}'

Mögliche Rückmeldungen

201 - Erfolgreich

{
"id": "7ca6999d-3ed4-47d7-8915-4df8aab6c989",
"name": "Invoices",
"model": "mistral-swiss",
"instructions": "Please provide the answer in Spanish",
"temperature": 0.5,
"anonymize": true,
"files": [
{
"id": "b7454f54-aa96-4306-b64d-83343d7bf4a4",
"name": "twint_pat_instructions_1.pdf",
"ext": "pdf",
"size": "2371319",
"mimetype": "application/pdf"
}
]
}

422 - Validation Error

{
"message": "Validation error",
"errors": {
"model": [
"The model field must be a string.",
"The selected model is invalid."
],
"name": [
"The name field is required."
]
}
}

PUT Update Assistant

https://api.peakprivacy.ch/v1/ai/assistants/{id}

REQUEST BODY SCHEMA: application/json

Key

Value

name

string
Name des Assistenten

model

string

Gibt das Modell an, das standardmäßig auf den Assistenten angewendet wird.

Unterstützte Modelle:

gpt-4-1106-preview
gpt-4
gpt-3.5-turbo-1106
mistral-tiny
mistral-small
mistral-medium
mistral-swiss

instructions

text

Zusätzliche Anweisungen für den Assistenten.

Beispiel: „Bitte geben Sie die Antwort auf Spanisch an.“

temperature

number

[ 0 .. 1 ]

Welche Abtasttemperatur soll verwendet werden, zwischen 0,0 und 1,0? Höhere Werte wie 0,8 machen die Ausgabe zufälliger, während niedrigere Werte wie 0,2 sie fokussierter und deterministischer machen.

anonymize

boolean

Ob für die Eingabeaufforderung eine Anonymisierung verwendet werden soll. Die Antwortzeit kann sich aufgrund der Anonymisierungs- und Deanonymisierungsalgorithmen geringfügig verlängern.

file_ids

array of strings (optional)

IDs der Dateien, die dem Assistenten beigefügt werden sollen

HINWEIS: Die Aktualisierung erfolgt mit der „Sync“-Logik. Wenn also einige der angehängten Dateien im bereitgestellten Array fehlen, werden sie vom Assistenten entfernt. Ein leeres Array entfernt alle Dateien. Um die Dateiliste unverändert zu lassen, senden Sie diesen Parameter nicht.

REQUEST BODY EXAMPLE

{
"name": "Assistant Name UPDATED",
"model": "mistral-swiss",
"instructions": "Please provide the answer in Spanish",
"temperature": 0.7,
"anonymize": true,
"file_ids": ["b7454f54-aa96-4306-b64d-83343d7bf4a4"]
}

Example request

curl --location --request PUT 'https://api.peakprivacy.ch/v1/ai/assistants/d9ba620b-4b8b-4ded-89be-d93b08ad786d' \
--header 'Api-token: api-token' \
--header 'X-Requested-With: XMLHttpRequest' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"name": "Assistant Name UPDATED",
"model": "mistral-swiss",
"instructions": "Please provide the answer in Spanish",
"temperature": 0.7,
"anonymize": true,
"file_ids": ["b7454f54-aa96-4306-b64d-83343d7bf4a4"]
}'

Possible Responses

200 - Erfolgreich

{
"id": "d9ba620b-4b8b-4ded-89be-d93b08ad786d",
"name": "Assistant Name UPDATED",
"model": "mistral-swiss",
"instructions": "Please provide the answer in Spanish",
"temperature": 0.7,
"anonymize": true,
"files": [
{
"id": "b7454f54-aa96-4306-b64d-83343d7bf4a4",
"name": "twint_pat_instructions_1.pdf",
"ext": "pdf",
"size": "2371319",
"mimetype": "application/pdf"
}
]
}

422 - Validation Error

{
"message": "Validation error",
"errors": {
"model": [
"The model field must be a string.",
"The selected model is invalid."
],
"name": [
"The name field is required."
]
}
}

404 - Not Found

{
"error": "Not found"
}

GET Retrieve Assistant

GET Assistants paginated list

https://api.peakprivacy.ch/v1/ai/assistants

GET Parameters

Key

Value

limit

int (optional)

default: 20

Pro Seite Artikel

cursor

string (optional)

Seitenzahl-Cursor

Example request

curl --location --request GET 'https://api.peakprivacy.ch/v1/ai/assistants?limit=6' \
--header 'API-TOKEN: api-token' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json'

Possible Responses

200 - Erfolgreich

{
"data": [
{
"uuid": "8147e92d-2b98-4719-8ba1-d6a3a968e4cf",
"name": "Invoices",
"model": null,
"instructions": null,
"files": []
},
{
"uuid": "98369e03-2aaa-4810-89c6-d05157965738",
"name": "Invoices",
"model": null,
"instructions": null,
"files": [
{
"id": "fc2930a6-8d3f-4d8f-bb2f-5f75cced1aa6",
"name": "test-2",
"ext": "txt",
"size": "12345",
"mimetype": "text/plain-text"
}
]
}
],
"links": {
"first": null,
"last": null,
"prev": null,
"next": "{{ $frontmatter.global.apiUrl }}/v1/ai/assistants?cursor=eyJhc3Npc3RhbnRzLmlkIjoyLCJfcG9pbnRzVG9OZXh0SXRlbXMiOnRydWV9"
},
"meta": {
"path": "{{ $frontmatter.global.apiUrl }}/v1/ai/assistants",
"per_page": 2,
"next_cursor": "eyJhc3Npc3RhbnRzLmlkIjoyLCJfcG9pbnRzVG9OZXh0SXRlbXMiOnRydWV9",
"prev_cursor": null
}
}

DELETE Delete Assistant

https://api.peakprivacy.ch/v1/ai/assistants/{id}

Example request

curl --location --request DELETE 'https://api.peakprivacy.ch/v1/ai/assistants/a4904bba-e854-4709-9e48-8cbc149fff35' \
--header 'Api-token: api_token' \
--header 'X-Requested-With: XMLHttpRequest' \
--header 'Accept: application/json' \

Possible Responses

204 - Erfolgreich

NO CONTENT

404 - Not Found

{
"error": "Not found"
}

POST Ask Assistant

https://api.peakprivacy.ch/v1/ai/assistants/{id}/ask

REQUEST BODY SCHEMA: application/json

Key

Value

messages

required

Array of objects

Die Eingabeaufforderung(en) zur Generierung von Vervollständigungen, codiert als Liste von Dict mit Rolle und Inhalt.

Die folgenden Parameter sind optional und überschreiben die entsprechenden Assistant-Parameter.

model

string

Gibt die Version des zu verwendenden GPT-Modells an.

Unterstützte Modelle:

gpt-4-1106-preview
gpt-4
gpt-3.5-turbo-1106
mistral-tiny
mistral-small
mistral-medium
mistral-swiss

temperature

number or null [ 0 .. 1 ]

Welche Abtasttemperatur soll verwendet werden, zwischen 0,0 und 1,0? Höhere Werte wie 0,8 machen die Ausgabe zufälliger, während niedrigere Werte wie 0,2 sie fokussierter und deterministischer machen.

anonymize

boolean or null

Ob für die Eingabeaufforderung eine Anonymisierung verwendet werden soll. Die Antwortzeit kann sich aufgrund der Anonymisierungs- und Deanonymisierungsalgorithmen geringfügig verlängern.

messages SCHEMA:

Key

Value

role

string

system user assistant

Gibt das LLM an, an das die Eingabeaufforderung gesendet wird.

content

string

BODY raw

{
"model": "mistral-swiss",
"messages": [

{
"role": "user",
"content": "Create a summary of all my documents"
}
],
"temperature": 0.2,
"anonymize" : true
}

Example request

curl --location --request POST 'https://api.peakprivacy.ch/v1/ai/assistants/c33a8b18-c82a-4955-a449-515001848b1f/ask' \
--header 'API-TOKEN: api-token' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"messages": [
{
"role": "user",
"content": "create document summary"
}
]
}'

Possible Responses

RESPONSE SCHEMA: application/json

Key

Value

id

string

object

string

created

integer

model

string

choices

Array of objects

usage

object

choices SCHEMA: application/json

Key

Value

finish_reason

string

index

string

message

object

message SCHEMA: application/json

Key

Value

role

string

content

string

usage SCHEMA: application/json

Key

Value

completion_tokens

integer

prompt_tokens

integer

total_tokens

integer

Possible Responses

200 - Erfolgreich

{
"id": "2820e9eb-22e9-40c6-a2fb-07d7ee06453d",
"object": "chat.completion",
"created": 1710243743,
"model": "mistral-swiss",
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "The document contains instructions for downloading and using the TWINT configurator app, including information on selecting the app environment, version, and build, onboarding the app, topping up credit, and updating the app. It also provides details for iOS and Android devices.",
"role": "assistant"
}
}
],
"usage": {
"completion_tokens": 54,
"prompt_tokens": 1196,
"total_tokens": 1250
}
}

422 - Unprocessable Entity; Validation Error

{
"message": "The model field is required.",
"errors": {
"model": [
"The selected model is invalid."
]
}
}

404 - Assistant Not Found

{
"error": "Not found"
}

Hat dies deine Frage beantwortet?