Skip to main content

Llama API Python Client

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

Llama API Client

LlamaAPI is a Python SDK for interacting with the Llama API. It abstracts away the handling of aiohttp sessions and headers, allowing for a simplified interaction with the API.

Installation

You can install the LlamaAPI SDK using pip:

pip install llamaapi

Usage

After installing the SDK, you can use it in your Python projects like so:

import json
from llamaapi import LlamaAPI

# Initialize the llamaapi with your api_token
llama = LlamaAPI("<your_api_token>")

# Define your API request
api_request_json = {
  "messages": [
    {"role": "user", "content": "Extract the desired information from the following passage.:\n\nHi!"},
  ],
  "functions": [
        {'name': 'information_extraction',
         'description': 'Extracts the relevant information from the passage.',
         'parameters': {
             'type': 'object',
             'properties': {
                 'sentiment': {
                    'title': 'sentiment',
                    'type': 'string',
                    'description': 'the sentiment encountered in the passage'
                    },
                 'aggressiveness': {
                    'title': 'aggressiveness',
                    'type': 'integer',
                    'description': 'a 0-10 score of how aggressive the passage is'
                    },
                 'language': {
                    'title': 'language',
                    'type': 'string',
                    'description': 'the language of the passage'
                    }
             },
             'required': ['sentiment', 'aggressiveness', 'language']
         }
      }
    ],
  "stream": False,
  "function_call": {"name": "information_extraction"},
}

# Make your request and handle the response
response = llama.run(api_request_json)
print(json.dumps(response.json(), indent=2))

Other parameters that you can pass in the request json is:

{
  ...
  "max_length" = 500,
  "temperature"= 0.1,
  "top_p"= 1.0,
  "frequency_penalty"=1.0
  ...
}

Note: Stream is still not working, so it is recommended to submit with stream: False.

Change Log

Version 0.1: Initial release

Contributing

We welcome contributions to this project. Please see the Contributing Guidelines for more details.

License

llamaapi SDK is licensed under the MIT License. Please see the License File for more details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llamaai-0.1.27.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llamaai-0.1.27-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file llamaai-0.1.27.tar.gz.

File metadata

  • Download URL: llamaai-0.1.27.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.4 Darwin/22.4.0

File hashes

Hashes for llamaai-0.1.27.tar.gz
Algorithm Hash digest
SHA256 f1a6168b9dce378a1c8ca9c145a237b523ea17ea1519bcf5507fe1451d005d6f
MD5 931b9bbff81eff4958e4e4a04ca79a79
BLAKE2b-256 bb6fef98c3430959276049ff21a396c6ed7c554764845854c763ab4cb426fe0f

See more details on using hashes here.

File details

Details for the file llamaai-0.1.27-py3-none-any.whl.

File metadata

  • Download URL: llamaai-0.1.27-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.4 Darwin/22.4.0

File hashes

Hashes for llamaai-0.1.27-py3-none-any.whl
Algorithm Hash digest
SHA256 9988ba71cb4ddf34bd2a0e4f697eaf362da639138c03030c01e68cc1b1c7894d
MD5 ff0b4105c1a9a02a8f63fbe7cf0b7baa
BLAKE2b-256 10a1a61c5c3f66f411193a33d351e6576d786fd12a4f62fa43a9c119e34d1d27

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page