Skip to main content

Llama API python SDK

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

llamaapi-0.1.36.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

llamaapi-0.1.36-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file llamaapi-0.1.36.tar.gz.

File metadata

  • Download URL: llamaapi-0.1.36.tar.gz
  • Upload date:
  • Size: 3.4 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 llamaapi-0.1.36.tar.gz
Algorithm Hash digest
SHA256 e001f43d84a1906cb8136a787d31798b5201b37ab73cef464bcb53e61e688749
MD5 ee155571928db0dcc255015c297c2501
BLAKE2b-256 244de27d20984e87ebcf7c8dbab41a6d24fdf488fdd54a1ceed92463c9bc1b12

See more details on using hashes here.

File details

Details for the file llamaapi-0.1.36-py3-none-any.whl.

File metadata

  • Download URL: llamaapi-0.1.36-py3-none-any.whl
  • Upload date:
  • Size: 4.0 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 llamaapi-0.1.36-py3-none-any.whl
Algorithm Hash digest
SHA256 ec22534acf5f2d6adf7cff953e7c8d0621d0dfded94ea9377913648c41d3b7e9
MD5 3227859cf8b5651aacc0b0a7771473a2
BLAKE2b-256 fbafc49dee77acd982bb801efc2d2acd16f53fcbc56fc69beb5a0fc6b4d03aa0

See more details on using hashes here.

Supported by

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