gull-api


Namegull-api JSON
Version 0.0.15 PyPI version JSON
download
home_pagehttps://github.com/mdbecker/gull_api
SummaryA REST API for running Large Language Models
upload_time2023-06-27 12:20:17
maintainer
docs_urlNone
authorMichael Becker
requires_python>=3.10,<4.0
licenseMIT
keywords api artificial-intelligence automation bot deep-learning fastapi gpt language-models large-language-models machine-learning microservices natural-language-processing nlp openai rest text text-generation web-api
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # GULL-API

![Test](https://github.com/mdbecker/gull_api/actions/workflows/test.yml/badge.svg)
![Docker Publish](https://github.com/mdbecker/gull_api/actions/workflows/docker-publish.yml/badge.svg?event=release)
![PyPI Publish](https://github.com/mdbecker/gull_api/actions/workflows/pypi-publish.yml/badge.svg?event=release)


GULL-API is a web application backend that can be used to run Large Language Models (LLMs). The interface between the front-end and the back-end is a JSON REST API.

## Features

- Exposes a `/api` route that returns a JSON file describing the parameters of the LLM.
- Provides a `/llm` route that accepts POST requests with JSON payloads to run the LLM with the specified parameters.

## Installation

### Using Docker

1. Build the Docker image:

   ```
   docker build -t gull-api .
   ```

2. Run the Docker container:

   ```
   docker run -p 8000:8000 gull-api
   ```

The API will be available at `http://localhost:8000`.

### Docker Test Mode

To build and run the Docker container in test mode, use the following commands:

```bash
docker build -t gull-api .
docker run -v $(pwd)/data:/app/data -v $(pwd)/example_cli.json:/app/cli.json -p 8000:8000 gull-api
```

In test mode, an included script echo_args.sh is used instead of a real LLM. This script echoes the arguments it receives, which can be helpful for local testing.


### Local Installation

1. Clone the repository:

   ```
   git clone https://github.com/yourusername/gull-api.git
   ```

2. Change to the project directory:

   ```
   cd gull-api
   ```

3. Install the dependencies:

   ```
   pip install poetry
   poetry install
   ```

4. Configure Environment Variables (Optional):

   `GULL-API` can be configured using environment variables. To do this, create a file named `.env` in the root of the project directory, and set the environment variables there. For example:

   ```
   DB_URI=sqlite:///mydatabase.db
   CLI_JSON_PATH=/path/to/cli.json
   ```

   `GULL-API` uses the `python-dotenv` package to load these environment variables when the application starts.


5. Run the application:

   ```
   uvicorn gull_api.main:app --host 0.0.0.0 --port 8000
   ```

The API will be available at `http://localhost:8000`.

## Usage

### `/api` Route

Send a GET request to the `/api` route to retrieve a JSON file describing the parameters of the LLM:

```
GET http://localhost:8000/api
```

### `/llm` Route

Send a POST request to the `/llm` route with a JSON payload containing the LLM parameters:

```
POST http://localhost:8000/llm
Content-Type: application/json

{
  "Prompt": "Once upon a time",
  "Top P": 0.5
}
```

### Example Requests

```bash
curl -X POST "http://localhost:8000/llm" -H  "accept: application/json" -H  "Content-Type: application/json" -d "{\"Instruct mode\":false, \"Maximum length\":256, \"Prompt\":\"Hello, world\", \"Stop sequences\":\"Goodbye, world\", \"Temperature\":0.7, \"Top P\":0.95}"
curl -X GET "http://localhost:8000/api" -H "accept: application/json" | python -mjson.tool
```

### Example CLI JSON

An example CLI JSON file is provided in the repository as `example_cli.json`. This file provides an example of the expected structure for defining the command-line arguments for the LLM.

## License

See LICENSE


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/mdbecker/gull_api",
    "name": "gull-api",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10,<4.0",
    "maintainer_email": "",
    "keywords": "api,artificial-intelligence,automation,bot,deep-learning,fastapi,GPT,language-models,large-language-models,machine-learning,microservices,natural-language-processing,NLP,openai,REST,text,text-generation,web-api",
    "author": "Michael Becker",
    "author_email": "mdbecker@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/ce/80/2460f474eb0f1573a592ad3bb2e74db592dad97c0b0ecd16710084301b5c/gull_api-0.0.15.tar.gz",
    "platform": null,
    "description": "# GULL-API\n\n![Test](https://github.com/mdbecker/gull_api/actions/workflows/test.yml/badge.svg)\n![Docker Publish](https://github.com/mdbecker/gull_api/actions/workflows/docker-publish.yml/badge.svg?event=release)\n![PyPI Publish](https://github.com/mdbecker/gull_api/actions/workflows/pypi-publish.yml/badge.svg?event=release)\n\n\nGULL-API is a web application backend that can be used to run Large Language Models (LLMs). The interface between the front-end and the back-end is a JSON REST API.\n\n## Features\n\n- Exposes a `/api` route that returns a JSON file describing the parameters of the LLM.\n- Provides a `/llm` route that accepts POST requests with JSON payloads to run the LLM with the specified parameters.\n\n## Installation\n\n### Using Docker\n\n1. Build the Docker image:\n\n   ```\n   docker build -t gull-api .\n   ```\n\n2. Run the Docker container:\n\n   ```\n   docker run -p 8000:8000 gull-api\n   ```\n\nThe API will be available at `http://localhost:8000`.\n\n### Docker Test Mode\n\nTo build and run the Docker container in test mode, use the following commands:\n\n```bash\ndocker build -t gull-api .\ndocker run -v $(pwd)/data:/app/data -v $(pwd)/example_cli.json:/app/cli.json -p 8000:8000 gull-api\n```\n\nIn test mode, an included script echo_args.sh is used instead of a real LLM. This script echoes the arguments it receives, which can be helpful for local testing.\n\n\n### Local Installation\n\n1. Clone the repository:\n\n   ```\n   git clone https://github.com/yourusername/gull-api.git\n   ```\n\n2. Change to the project directory:\n\n   ```\n   cd gull-api\n   ```\n\n3. Install the dependencies:\n\n   ```\n   pip install poetry\n   poetry install\n   ```\n\n4. Configure Environment Variables (Optional):\n\n   `GULL-API` can be configured using environment variables. To do this, create a file named `.env` in the root of the project directory, and set the environment variables there. For example:\n\n   ```\n   DB_URI=sqlite:///mydatabase.db\n   CLI_JSON_PATH=/path/to/cli.json\n   ```\n\n   `GULL-API` uses the `python-dotenv` package to load these environment variables when the application starts.\n\n\n5. Run the application:\n\n   ```\n   uvicorn gull_api.main:app --host 0.0.0.0 --port 8000\n   ```\n\nThe API will be available at `http://localhost:8000`.\n\n## Usage\n\n### `/api` Route\n\nSend a GET request to the `/api` route to retrieve a JSON file describing the parameters of the LLM:\n\n```\nGET http://localhost:8000/api\n```\n\n### `/llm` Route\n\nSend a POST request to the `/llm` route with a JSON payload containing the LLM parameters:\n\n```\nPOST http://localhost:8000/llm\nContent-Type: application/json\n\n{\n  \"Prompt\": \"Once upon a time\",\n  \"Top P\": 0.5\n}\n```\n\n### Example Requests\n\n```bash\ncurl -X POST \"http://localhost:8000/llm\" -H  \"accept: application/json\" -H  \"Content-Type: application/json\" -d \"{\\\"Instruct mode\\\":false, \\\"Maximum length\\\":256, \\\"Prompt\\\":\\\"Hello, world\\\", \\\"Stop sequences\\\":\\\"Goodbye, world\\\", \\\"Temperature\\\":0.7, \\\"Top P\\\":0.95}\"\ncurl -X GET \"http://localhost:8000/api\" -H \"accept: application/json\" | python -mjson.tool\n```\n\n### Example CLI JSON\n\nAn example CLI JSON file is provided in the repository as `example_cli.json`. This file provides an example of the expected structure for defining the command-line arguments for the LLM.\n\n## License\n\nSee LICENSE\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A REST API for running Large Language Models",
    "version": "0.0.15",
    "project_urls": {
        "Documentation": "https://github.com/mdbecker/gull_api/blob/main/README.md",
        "Homepage": "https://github.com/mdbecker/gull_api",
        "Repository": "https://github.com/mdbecker/gull_api"
    },
    "split_keywords": [
        "api",
        "artificial-intelligence",
        "automation",
        "bot",
        "deep-learning",
        "fastapi",
        "gpt",
        "language-models",
        "large-language-models",
        "machine-learning",
        "microservices",
        "natural-language-processing",
        "nlp",
        "openai",
        "rest",
        "text",
        "text-generation",
        "web-api"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b4a13bbe2325265f94de23d07e2ffcd1614ec14b04edec87ad561d5ca90a431e",
                "md5": "71b9f91095f1039b7ca2b948f56cb2fc",
                "sha256": "cf1676278f2eee525736e40bf4a85aae2fc0b5509f2e80bf75c91600508db560"
            },
            "downloads": -1,
            "filename": "gull_api-0.0.15-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "71b9f91095f1039b7ca2b948f56cb2fc",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10,<4.0",
            "size": 8333,
            "upload_time": "2023-06-27T12:20:16",
            "upload_time_iso_8601": "2023-06-27T12:20:16.021886Z",
            "url": "https://files.pythonhosted.org/packages/b4/a1/3bbe2325265f94de23d07e2ffcd1614ec14b04edec87ad561d5ca90a431e/gull_api-0.0.15-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ce802460f474eb0f1573a592ad3bb2e74db592dad97c0b0ecd16710084301b5c",
                "md5": "4b9192074940b5f9a17abd0e40997c1c",
                "sha256": "885a7e2a6e94843c1160edf1cd11097f61bec8039c25c56887ea20a0757d7d42"
            },
            "downloads": -1,
            "filename": "gull_api-0.0.15.tar.gz",
            "has_sig": false,
            "md5_digest": "4b9192074940b5f9a17abd0e40997c1c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10,<4.0",
            "size": 6883,
            "upload_time": "2023-06-27T12:20:17",
            "upload_time_iso_8601": "2023-06-27T12:20:17.318090Z",
            "url": "https://files.pythonhosted.org/packages/ce/80/2460f474eb0f1573a592ad3bb2e74db592dad97c0b0ecd16710084301b5c/gull_api-0.0.15.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-27 12:20:17",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mdbecker",
    "github_project": "gull_api",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "gull-api"
}
        
Elapsed time: 0.08487s