A lightweight wrapper for gigachat api model for seamless use with hf smolagents
Project description
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
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e6d121cf61a35811b9fe6254de6394e1fe5fd25bbe3cab4c013af89ba5444bf9
|
|
| MD5 |
132e71921a43eed9a3722b6f9bdc873a
|
|
| BLAKE2b-256 |
a5d9460cc00362c1e53931faa609e61d867f16713ab7715d04ffd72c95289831
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e279f779af4c17dbca32d83c55af6c3b930e6aef4313f584778beb485290afd
|
|
| MD5 |
5ed7ccaf42345a45abb1dd0597a420fb
|
|
| BLAKE2b-256 |
0fe9528d8b14955dc11a55baf72e87134dca9162ff9dea6f6334b711d71cb438
|