Skip to main content

A lightweight wrapper for gigachat api model for seamless use with hf smolagents

Project description

GigaSmol Logo

lightweight gigachat api wrapper for smolagents

Overview

gigasmol serves two primary purposes:

  1. Provides direct, lightweight access to GigaChat models through GigaChat API without unnecessary abstractions
  2. Creates a smolagents-compatible wrapper that lets you use GigaChat within agent systems

No complex abstractions โ€” just clean, straightforward access to GigaChat's capabilities through smolagents.

GigaChat API + smolagents = gigasmol ๐Ÿ’€

Why gigasmol ๐Ÿ’€?

  • Tiny Footprint: Less than 1K lines of code total
  • Simple Structure: Just 4 core files
  • Zero Bloat: Only essential dependencies
  • Easy to Understand: Read and comprehend the entire codebase in minutes
  • Maintainable: Small, focused codebase means fewer bugs and easier updates

Installation

API-Only Installation (default)

python>=3.8

pip install gigasmol

Full Installation with Agent Support

python>=3.10

pip install "gigasmol[agent]"

Quick Start

Raw GigaChat API

gigasmol

import json
from gigasmol import GigaChat

# Direct access to GigaChat API
gigachat = GigaChat(
    auth_data="YOUR_AUTH_TOKEN",
    model_name="GigaChat-Max",
)

# Generate a response
response = gigachat.chat([
    {"role": "user", "content": "What is the capital of Russia?"}
])
print(response['answer']) # or print(response['response']['choices'][0]['message']['content'])

Usage with smolagents

gigasmol[agent]

from gigasmol import GigaChatSmolModel
from smolagents import CodeAgent, ToolCallingAgent, DuckDuckGoSearchTool

# Initialize the GigaChat model with your credentials
model = GigaChatSmolModel(
    auth_data="YOUR_AUTH_TOKEN",
    model_name="GigaChat-Max"
)

# Create a CodeAgent with the model
code_agent = CodeAgent(
    tools=[DuckDuckGoSearchTool()],
    model=model
)

# Run the code_agent
code_agent.run("What are the main tourist attractions in Moscow?")

# Create a ToolCallingAgent with the model
tool_calling_agent = ToolCallingAgent(
    tools=[DuckDuckGoSearchTool()],
    model=model
)

# Run the tool_calling_agent
tool_calling_agent.run("What are the main tourist attractions in Moscow?")

How It Works

GigaSmol provides two layers of functionality:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    gigasmol                       โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”          โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚ โ”‚    Direct     โ”‚          โ”‚   smolagents      โ”‚  โ”‚
โ”‚ โ”‚ GigaChat API  โ”‚          โ”‚  compatibility    โ”‚  โ”‚
โ”‚ โ”‚    access     โ”‚          โ”‚      layer        โ”‚  โ”‚
โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜          โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
    โ”‚                             โ”‚
    โ–ผ                             โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”           โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ GigaChat APIโ”‚           โ”‚ Agent systems  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜           โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
  1. Direct API Access: Use GigaChat for clean, direct access to the API
  2. smolagents Integration: Use GigaChatSmolModel to plug GigaChat into smolagents

Examples

Check the examples directory:

  • structured_output.ipynb: Using GigaChat API and function_calling for structured output
  • agents.ipynb: Building code and tool agents with GigaChat and smolagents

Acknowledgements

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

gigasmol-0.0.8.tar.gz (18.0 kB view details)

Uploaded Source

Built Distribution

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

gigasmol-0.0.8-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

File details

Details for the file gigasmol-0.0.8.tar.gz.

File metadata

  • Download URL: gigasmol-0.0.8.tar.gz
  • Upload date:
  • Size: 18.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for gigasmol-0.0.8.tar.gz
Algorithm Hash digest
SHA256 e6d121cf61a35811b9fe6254de6394e1fe5fd25bbe3cab4c013af89ba5444bf9
MD5 132e71921a43eed9a3722b6f9bdc873a
BLAKE2b-256 a5d9460cc00362c1e53931faa609e61d867f16713ab7715d04ffd72c95289831

See more details on using hashes here.

File details

Details for the file gigasmol-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: gigasmol-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 17.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for gigasmol-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 3e279f779af4c17dbca32d83c55af6c3b930e6aef4313f584778beb485290afd
MD5 5ed7ccaf42345a45abb1dd0597a420fb
BLAKE2b-256 0fe9528d8b14955dc11a55baf72e87134dca9162ff9dea6f6334b711d71cb438

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