Skip to content

Latest commit

 

History

History
232 lines (201 loc) · 6.63 KB

Readme.md

File metadata and controls

232 lines (201 loc) · 6.63 KB

Database Interface

Entity Relationship Diagram of Database

erDiagram
    CodeSnippet {
        text id PK
        datetime created_at
        datetime updated_at
        text code
        integer start_line
        integer end_line
        text prediction FK
    }
    Prediction ||--o{ CodeSnippet: "generated"

    FollowUpType {
        text id PK
        datetime created_at
        datetime updated_at
        text name FK "UNIQUE"
    }

    FollowUp {
        text id PK
        datetime created_at
        datetime updated_at
        text parent_prediction FK
        text follow_up_type FK
    }
    FollowUp }o--|| FollowUpType: "is of type"
    FollowUp }o--|| Prediction: "is follow up of"

    FrameworkItem {
        text id PK
        datetime created_at
        datetime updated_at
        text name "UNIQUE"
        text url "NULL"
        text description
        text source "NULL"
        text framework FK
    }
    FrameworkItem }o--|| Framework: "belongs to"

    Framework {
        text id PK
        datetime created_at
        datetime updated_at
        text name "UNIQUE"
        text url "NULL"
    }

    Llm {
        text id PK
        datetime created_at
        datetime updated_at
        text name "UNIQUE"
    }

    Prediction {
        text id PK
        datetime created_at
        datetime updated_at
        text text
        integer token_amount
        float repeat_penalty
        integer max_tokens
        integer seed
        float temperature
        top_p float
        text parent_follow_up FK "NULL"
        text framework_item FK
        text llm FK
        text system_prompt FK "NULL"
    }
    FollowUp ||--o{ Prediction: "is follow up of"
    Prediction }o--|| FrameworkItem: "belongs to"
    Prediction }o--|| Llm: "generated by"
    SystemPrompt ||--o{ Prediction: "used for"

    PromptPartUsage {
        text id PK
        datetime created_at
        datetime updated_at
        integer position
        text prompt_part FK
        text prediction FK
    }
    PromptPartUsage }o--|| PromptPart: "uses"
    PromptPartUsage }o--|| Prediction: "for"

    PromptPart {
        text id PK
        datetime created_at
        datetime updated_at
        text text
    }

    StopSequenceUsage {
        text id PK
        datetime created_at
        datetime updated_at
        text stop_sequence FK
        text prediction FK
    }
    StopSequenceUsage }o--|| StopSequence: "uses"
    StopSequenceUsage }o--|| Prediction: "for"

    StopSequence {
        text id PK
        datetime created_at
        datetime updated_at
        text text "UNIQUE"
    }

    SystemPrompt {
        text id PK
        datetime created_at
        datetime updated_at
        text text
        text name
    }

    SymbolReference {
        text symbol
        integer start_line
        integer end_line
        integer start_column
        integer end_column
        text code_Snippet FK
    }
    CodeSnippet ||--o{ SymbolReference: "contains"

    UserRatingType {
        text symbol
        integer start_line
        integer end_line
        text name "UNIQUE"
    }

    UserRating {
        text symbol
        integer start_line
        integer end_line
        float value
        text user_rating_type FK
        text prediction FK
    }
    UserRating ||--o{ UserRatingType: "is of type"
    UserRating }o--|| Prediction: "rates"
Loading

Endpoints

GET /

This endpoint only exists for debugging purposes. It doesn't take any further parameters and always returns

{"message": "Hello, world! This is 'db_interface'."}

GET /<table_name>/by-name/<name>

This endpoint returns a database object from <table_name> with name <name>. Note that the object has to have a column called name. Possible tables names are:

  1. follow_up_types
  2. user_rating_types
  3. llms
  4. frameworks
  5. framework_items
  6. system_prompts

DELETE /<table_name>/by-name/<name>

This endpoint deletes an existing database object from <table_name> with name <name>. Note that the object has to have a column called name. Possible tables names are:

  1. follow_up_types
  2. user_rating_types
  3. llms
  4. frameworks
  5. framework_items
  6. system_prompts

GET /<table_name>

This endpoint returns a list of all database objects from <table_name>. Possible tables names are:

  1. code_snippets
  2. follow_up_types
  3. follow_ups
  4. framework_items
  5. frameworks
  6. llms
  7. predictions
  8. prompt_part_usages
  9. prompt_parts
  10. stop_sequence_usages
  11. stop_sequences
  12. symbol_references
  13. system_prompts
  14. user_rating_types
  15. user_ratings

POST /<table_name>

This endpoint will create a new database object. You have to provide a json body with the necessary column values. Necessary columns are all columns that don't have a NOT NULL constraint and are not one of (id, created_at, updated_at). When you provide references to other database objects you have to give them as database ids.

To create a new user rating for example you would have to make a POST request to http://HOST:5003/user_ratings with a body like this:

{
    "value": VALUE,
    "user_rating_type": "USER_RATING_TYPE_ID",
    "prediction": "PREDICTION_ID"
}

On success the response status code is 201.

GET /<table_name>/<id>

This endpoint returns a database object from <table_name> with id <id>. You can find all possible table names here.

PATCH /<table_name>/<id>

This endpoint updates an existing database object from <table_name> with id <id>. You have to provide a json body (like here) with all column values you want to update.

DELETE /<table_name>/<id>

This endpoint deletes an existing database object from <table_name> with id <id>. Note that you cannot delete an object if that would violate an ON DELETE constraint.

POST /db/create

A call to this endpoint creates all the database tables.

POST /db/drop

A call to this endpoint drops all the database tables.

POST /db/reset

A call to this endpoint is equivalent to subsequent call to /db/drop and /db/create.

POST /db/populate

A call to this endpoint populates the database with some initial data. This is necessary for the entire system to work.