justai


Namejustai JSON
Version 3.2.10 PyPI version JSON
download
home_pageNone
SummaryMakes working with OpenAI's GPT API and other LLM's super easy
upload_time2024-04-05 13:29:50
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseThis is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. For more information, please refer to <https://unlicense.org>
keywords chatgpt gpt4 gpt3.5 api claude anthropic lllama
VCS
bugtrack_url
requirements python-dateutil openai python-dotenv rich tenacity requests setuptools packaging pip pytest tiktoken
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # JustAI

Package to make working with Large Language models in Python super easy.

Author: Hans-Peter Harmsen (hp@harmsen.nl) \
Current version: 3.2.10

## Installation
1. Install the package:
~~~~bash
python -m pip install justai
~~~~
2. Create an OpenAI acccount (for GPT3.5 / 4) [here](https://platform.openai.com/) or an Anthropic account [here](https://console.anthropic.com/)
3. Create an OpenAI api key (for Claude) [here](https://platform.openai.com/account/api-keys) or an Anthropic api key [here](https://console.anthropic.com/settings/keys)
4. Create a .env file with the following content:
```bash
OPENAI_API_KEY=your-openai-api-key
OPENAI_ORGANIZATION=your-openai-organization-id
ANTHROPIC_API_KEY=your-anthropic-api-key
```
## Usage

```Python
from justai import Agent

if __name__ == "__main__":
    agent = Agent('gpt-3.5-turbo')
    agent.system = "You are a movie critic. I feed you with movie titles and you give me a review in 50 words."

    message = agent.chat("Forrest Gump")
    print(message)
```
output
```
Forrest Gump is an American classic that tells the story of
a man with a kind heart and simple mind who experiences major
events in history. Tom Hanks gives an unforgettable performance, 
making us both laugh and cry. A heartwarming and nostalgic 
movie that still resonates with audiences today.
```
## Other models
Justai can use different types of models:

**OpenAI** models like GPT-3.5, GPT-4-turbo-preview\
**Anthropic** models like claude-3-opus-20240229 and claude-3-sonnet-20240229\
**Open source** models like Llama2-7b or Mixtral-8x7b-instruct as long as they are in the GGUF format.

The provider is chosen depending on the model name. E.g. if a model name starts with gpt, OpenAI is chosen as the provider.
To use an open source model, just pass the full path to the .gguf file as the model name.


## Using the examples
Install dependencies:
```bash
python -m pip install -r requirements.txt
```


### Basic
```bash
python examples/basic.py
```
Starts an interactive session. In the session you dan chat with GPT-4 or another model.

### Returning json
```bash
python examples/return_types.py
```
You can specify a specific return type (like a list of dicts) for the completion. 
This is useful when you want to extract structured data from the completion.

To define a return type, just pass return_json=True to agent.chat().

See the example code for more details.

### Interactive
```bash
python examples/interactive.py
```
Starts an interactive session. In the session you dan chat with GPT-4 or another model.

#### Special commands
In the interactive mode you can use these special commands which each start with a colon:

| Syntax                            | Description                                                         |
|-----------------------------------|---------------------------------------------------------------------|
| :reset                            | resets the conversation                                             |
| :load _name_                      | loads the saved conversation with the specified name                |
| :save _name_                      | saves the conversation under the specified name                     |
| :input _filename_                 | loads an input from the specified file                              |
| :model _gpt-4_                    | Sets the AI model                                                   |
| :max_tokens _800_                 | The maximum number of tokens to generate in the completion          |
| :temperature _0.9_                | What sampling temperature to use, between 0 and 2                   |
| :n _1_                            | Specifies the number answers given                                  |
| :stop _["\n", " Human:", " AI:"]_ | Up to 4 sequences where the API will stop generating further tokens |
| :bye                              | quits but saves the conversation first                              |
| :exit or :quit                    | quits the program                                                   |


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "justai",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "ChatGPT, GPT4, GPT3.5, api, Claude, Anthropic, Lllama",
    "author": null,
    "author_email": "HP Harmsen <hp@harmsen.nl>",
    "download_url": "https://files.pythonhosted.org/packages/13/ec/c94e8854401d2920ee895751d5fca4d00929d3ddadfb39b02fa6dd6dee47/justai-3.2.10.tar.gz",
    "platform": null,
    "description": "# JustAI\n\nPackage to make working with Large Language models in Python super easy.\n\nAuthor: Hans-Peter Harmsen (hp@harmsen.nl) \\\nCurrent version: 3.2.10\n\n## Installation\n1. Install the package:\n~~~~bash\npython -m pip install justai\n~~~~\n2. Create an OpenAI acccount (for GPT3.5 / 4) [here](https://platform.openai.com/) or an Anthropic account [here](https://console.anthropic.com/)\n3. Create an OpenAI api key (for Claude) [here](https://platform.openai.com/account/api-keys) or an Anthropic api key [here](https://console.anthropic.com/settings/keys)\n4. Create a .env file with the following content:\n```bash\nOPENAI_API_KEY=your-openai-api-key\nOPENAI_ORGANIZATION=your-openai-organization-id\nANTHROPIC_API_KEY=your-anthropic-api-key\n```\n## Usage\n\n```Python\nfrom justai import Agent\n\nif __name__ == \"__main__\":\n    agent = Agent('gpt-3.5-turbo')\n    agent.system = \"You are a movie critic. I feed you with movie titles and you give me a review in 50 words.\"\n\n    message = agent.chat(\"Forrest Gump\")\n    print(message)\n```\noutput\n```\nForrest Gump is an American classic that tells the story of\na man with a kind heart and simple mind who experiences major\nevents in history. Tom Hanks gives an unforgettable performance, \nmaking us both laugh and cry. A heartwarming and nostalgic \nmovie that still resonates with audiences today.\n```\n## Other models\nJustai can use different types of models:\n\n**OpenAI** models like GPT-3.5, GPT-4-turbo-preview\\\n**Anthropic** models like claude-3-opus-20240229 and claude-3-sonnet-20240229\\\n**Open source** models like Llama2-7b or Mixtral-8x7b-instruct as long as they are in the GGUF format.\n\nThe provider is chosen depending on the model name. E.g. if a model name starts with gpt, OpenAI is chosen as the provider.\nTo use an open source model, just pass the full path to the .gguf file as the model name.\n\n\n## Using the examples\nInstall dependencies:\n```bash\npython -m pip install -r requirements.txt\n```\n\n\n### Basic\n```bash\npython examples/basic.py\n```\nStarts an interactive session. In the session you dan chat with GPT-4 or another model.\n\n### Returning json\n```bash\npython examples/return_types.py\n```\nYou can specify a specific return type (like a list of dicts) for the completion. \nThis is useful when you want to extract structured data from the completion.\n\nTo define a return type, just pass return_json=True to agent.chat().\n\nSee the example code for more details.\n\n### Interactive\n```bash\npython examples/interactive.py\n```\nStarts an interactive session. In the session you dan chat with GPT-4 or another model.\n\n#### Special commands\nIn the interactive mode you can use these special commands which each start with a colon:\n\n| Syntax                            | Description                                                         |\n|-----------------------------------|---------------------------------------------------------------------|\n| :reset                            | resets the conversation                                             |\n| :load _name_                      | loads the saved conversation with the specified name                |\n| :save _name_                      | saves the conversation under the specified name                     |\n| :input _filename_                 | loads an input from the specified file                              |\n| :model _gpt-4_                    | Sets the AI model                                                   |\n| :max_tokens _800_                 | The maximum number of tokens to generate in the completion          |\n| :temperature _0.9_                | What sampling temperature to use, between 0 and 2                   |\n| :n _1_                            | Specifies the number answers given                                  |\n| :stop _[\"\\n\", \" Human:\", \" AI:\"]_ | Up to 4 sequences where the API will stop generating further tokens |\n| :bye                              | quits but saves the conversation first                              |\n| :exit or :quit                    | quits the program                                                   |\n\n",
    "bugtrack_url": null,
    "license": "This is free and unencumbered software released into the public domain.  Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.  In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  For more information, please refer to <https://unlicense.org> ",
    "summary": "Makes working with OpenAI's GPT API and other LLM's super easy",
    "version": "3.2.10",
    "project_urls": {
        "Homepage": "https://github.com/hpharmsen/justai"
    },
    "split_keywords": [
        "chatgpt",
        " gpt4",
        " gpt3.5",
        " api",
        " claude",
        " anthropic",
        " lllama"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d4408132172246fd0a58d036e1587713977b931f4cb4f271736b4b8fde9c8131",
                "md5": "44906555cd0a16aac17627cf46e29db6",
                "sha256": "b81c82a770c055892bba1caed0162edf09e1403edbcfa0f771f8d7924ecf65ee"
            },
            "downloads": -1,
            "filename": "justai-3.2.10-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "44906555cd0a16aac17627cf46e29db6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 28163,
            "upload_time": "2024-04-05T13:29:48",
            "upload_time_iso_8601": "2024-04-05T13:29:48.203842Z",
            "url": "https://files.pythonhosted.org/packages/d4/40/8132172246fd0a58d036e1587713977b931f4cb4f271736b4b8fde9c8131/justai-3.2.10-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "13ecc94e8854401d2920ee895751d5fca4d00929d3ddadfb39b02fa6dd6dee47",
                "md5": "caec628ac8d7013a4fa410f62c2b7293",
                "sha256": "1eb30040afecc84f8bb3a2ba649042f48184ad58a6ff5c5cad4c6d9c0182a872"
            },
            "downloads": -1,
            "filename": "justai-3.2.10.tar.gz",
            "has_sig": false,
            "md5_digest": "caec628ac8d7013a4fa410f62c2b7293",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 24036,
            "upload_time": "2024-04-05T13:29:50",
            "upload_time_iso_8601": "2024-04-05T13:29:50.195750Z",
            "url": "https://files.pythonhosted.org/packages/13/ec/c94e8854401d2920ee895751d5fca4d00929d3ddadfb39b02fa6dd6dee47/justai-3.2.10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-05 13:29:50",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hpharmsen",
    "github_project": "justai",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "python-dateutil",
            "specs": []
        },
        {
            "name": "openai",
            "specs": []
        },
        {
            "name": "python-dotenv",
            "specs": []
        },
        {
            "name": "rich",
            "specs": []
        },
        {
            "name": "tenacity",
            "specs": []
        },
        {
            "name": "requests",
            "specs": []
        },
        {
            "name": "setuptools",
            "specs": []
        },
        {
            "name": "packaging",
            "specs": []
        },
        {
            "name": "pip",
            "specs": []
        },
        {
            "name": "pytest",
            "specs": []
        },
        {
            "name": "tiktoken",
            "specs": []
        }
    ],
    "lcname": "justai"
}
        
Elapsed time: 0.22923s