Skip to main content

Gemma API python SDK

Project description

Llama API Client

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

pip install gemmaai

Usage

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

import json
from gemmaai import GemmaAI

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

gemmaai 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

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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: gemmaai-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 gemmaai-0.1.36.tar.gz
Algorithm Hash digest
SHA256 48b43a5eca26e410c1132b228f14e4b6d91131dbae0ecff857ab79b40c80669c
MD5 ab966ee3c9fb093fa69037434bd4e34f
BLAKE2b-256 3d1a17d174525f7094de8b0c466a50de3ecb877ba7510634be75fef139dcfa9c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gemmaai-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 gemmaai-0.1.36-py3-none-any.whl
Algorithm Hash digest
SHA256 055844edffd3ace60444b0daaa902baec9c87ac6ad1fcfc2147961a4bc205ddb
MD5 76480ecdabd5059b80f2515e1f5a7e56
BLAKE2b-256 9eef2f5fe9eb28a610e2a0036c5dc234af42ef6ed7429edad912b6d173e56db1

See more details on using hashes here.

Supported by

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