lightweight gigachat api wrapper for smolagents
Overview
gigasmol serves two primary purposes:
- Provides direct, lightweight access to GigaChat models through GigaChat API without unnecessary abstractions
- 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 │
└─────────────┘ └────────────────┘
- Direct API Access: Use
GigaChatfor clean, direct access to the API - smolagents Integration: Use
GigaChatSmolModelto plug GigaChat into smolagents
Examples
Check the examples directory:
structured_output.ipynb: Using GigaChat API and function_calling for structured outputagents.ipynb: Building code and tool agents with GigaChat and smolagents
Acknowledgements
- SberDevices for creating the GigaChat API
- Hugging Face for the smolagents framework
Metadata
Release files for gigasmol 0.0.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| gigasmol-0.0.8.tar.gz | 18.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gigasmol-0.0.8-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 35.9 kB
Release files / gigasmol-0.0.8.tar.gz
| Download URL | gigasmol-0.0.8.tar.gz |
|---|---|
| Size | 18.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e6d121cf61a35811b9fe6254de6394e1fe5fd25bbe3cab4c013af89ba5444bf9
|
|
BLAKE2b-256 checksum How to use checksums |
a5d9460cc00362c1e53931faa609e61d867f16713ab7715d04ffd72c95289831
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|
Release files / gigasmol-0.0.8-py3-none-any.whl
| Download URL | gigasmol-0.0.8-py3-none-any.whl |
|---|---|
| Size | 17.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3e279f779af4c17dbca32d83c55af6c3b930e6aef4313f584778beb485290afd
|
|
BLAKE2b-256 checksum How to use checksums |
0fe9528d8b14955dc11a55baf72e87134dca9162ff9dea6f6334b711d71cb438
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|