Skip to main content

A Python SDK for integrating to the Glik Service-API

Project description

Glik Python SDK

A Python client library for interacting with the Glik App Service API. This SDK provides a simple and intuitive interface for building applications that communicate with Glik's AI services.

Installation

Install the package using pip:

pip install glik-sdk

Quick Start

Basic Completion

from glik_sdk import CompletionClient

# Initialize the client with your API key
client = CompletionClient(api_key="your_api_key")

# Create a completion request
response = client.create_completion_message(
    inputs={"query": "What's the weather like today?"},
    response_mode="blocking",
    user="user_id"
)
response.raise_for_status()

# Get the response
result = response.json()
print(result.get('answer'))

Vision Model Usage

Using Remote Images

from glik_sdk import CompletionClient

client = CompletionClient(api_key="your_api_key")

# Define image files
files = [{
    "type": "image",
    "transfer_method": "remote_url",
    "url": "your_image_url"
}]

# Create completion with image
response = client.create_completion_message(
    inputs={"query": "Describe the picture."},
    response_mode="blocking",
    user="user_id",
    files=files
)
response.raise_for_status()

result = response.json()
print(result.get('answer'))

Using Local Images

from glik_sdk import GlikClient

# Initialize client
client = GlikClient(api_key="your_api_key")

# Upload local file
file_path = "path/to/image.jpg"
file_name = "image.jpg"
mime_type = "image/jpeg"

with open(file_path, "rb") as file:
    files = {
        "file": (file_name, file, mime_type)
    }
    upload_response = client.file_upload("user_id", files)
    upload_response.raise_for_status()
    
    file_id = upload_response.json().get("id")
    
    # Use the uploaded file
    files = [{
        "type": "image",
        "transfer_method": "local_file",
        "upload_file_id": file_id
    }]
    
    # Create completion with uploaded image
    response = client.create_completion_message(
        inputs={"query": "Describe the picture."},
        response_mode="blocking",
        user="user_id",
        files=files
    )
    response.raise_for_status()
    
    result = response.json()
    print(result.get('answer'))

Streaming Chat

import json
from glik_sdk import GlikChat

client = GlikChat(api_key="your_api_key")

# Create streaming chat message
response = client.create_chat_message(
    inputs={},
    query="Hello",
    user="user_id",
    response_mode="streaming"
)
response.raise_for_status()

# Process streaming response
for line in response.iter_lines(decode_unicode=True):
    line = line.split('data:', 1)[-1]
    if line.strip():
        line = json.loads(line.strip())
        print(line.get('answer'))

Advanced Usage

Chat Management

from glik_sdk import GlikChat

client = GlikChat(api_key="your_api_key")

# Get application parameters
parameters = client.get_application_parameters(user="user_id")
parameters.raise_for_status()
print(parameters.json())

# Get conversation list
conversations = client.get_conversations(user="user_id")
conversations.raise_for_status()
print(conversations.json())

# Get messages from a conversation
messages = client.get_conversation_messages(
    user="user_id",
    conversation_id="conversation_id"
)
messages.raise_for_status()
print(messages.json())

# Rename a conversation
rename_response = client.rename_conversation(
    conversation_id="conversation_id",
    name="new_name",
    user="user_id"
)
rename_response.raise_for_status()
print(rename_response.json())

Features

  • Support for both completion and chat modes
  • Vision model integration with local and remote image support
  • Streaming response handling
  • Conversation management
  • File upload capabilities
  • Simple and intuitive API

Requirements

  • Python 3.6+
  • requests library

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

glik-sdk-0.0.1.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

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

glik_sdk-0.0.1-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file glik-sdk-0.0.1.tar.gz.

File metadata

  • Download URL: glik-sdk-0.0.1.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.4

File hashes

Hashes for glik-sdk-0.0.1.tar.gz
Algorithm Hash digest
SHA256 87ae6310dfa815774963777e110c42faba429b1f0149211294c069d553e129f6
MD5 d52054230532b2dfd451e9270b17978e
BLAKE2b-256 a8dee9518cc049d755bb6e9b8fa8cdbc51374d7051241f216e7b49b1146d92ed

See more details on using hashes here.

File details

Details for the file glik_sdk-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: glik_sdk-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.4

File hashes

Hashes for glik_sdk-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2ab5b076f96a1e3c1dafb7ebee97dedd96284176e75e204f12cb04311867420f
MD5 dc9dc233fff9f6ec0a3173c4c507b487
BLAKE2b-256 58279107e63a109bf5bc21a2457f50494e132862973b69a4ee5a8987cc6b4c99

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