Skip to main content

Gemma API python SDK

Project description

Llama API Client

GemmaAPI 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 GemmaAPI SDK using pip:

pip install gemmaapi

Usage

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

import json
from gemmaapi import GemmaAPI

# Initialize the gemmaapi with your api_token
llama = GemmaAPI("<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

gemmaapi 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

gemmaapi-0.1.36.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

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

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: gemmaapi-0.1.36.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.9.13 Linux/5.15.0-92-generic

File hashes

Hashes for gemmaapi-0.1.36.tar.gz
Algorithm Hash digest
SHA256 0e9838b1d33d64e94fa6ede000c825f739699aecdb051adb1280c6d2f28b1be6
MD5 50879b98fc8d519db9412eb10e8bae71
BLAKE2b-256 c035b2886ebd9fb133c187cb99e3ef077966a3ced5c22ffffecc83688c6782e1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gemmaapi-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.4.2 CPython/3.9.13 Linux/5.15.0-92-generic

File hashes

Hashes for gemmaapi-0.1.36-py3-none-any.whl
Algorithm Hash digest
SHA256 06ba2388eab8c1aecfba3709808f7ae308ed8023ebee796438bb53f19d338bd9
MD5 d6ed0ece58759548c3ae282fff3a6801
BLAKE2b-256 a60a5685562c6714e73bca3937555ce79fa157452d656fdd26ed8a7065a0d19d

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