LiteRT-LM के कमांड लाइन इंटरफ़ेस (सीएलआई) की मदद से, मॉडल चलाए जा सकते हैं और टर्मिनल का इस्तेमाल करके उनके साथ इंटरैक्ट किया जा सकता है.
इंस्टॉल करना
uv का इस्तेमाल करके (सुझाया गया)
uv इंस्टॉल करने के लिए, uv इंस्टॉल करने के तरीके के बारे में जानकारी देने वाली गाइड पढ़ें.
uv tool install litert-lm-nightly
pip का इस्तेमाल करना
python3 -m venv .venv
source .venv/bin/activate
pip install litert-lm-nightly
Chat
CLI का इस्तेमाल करके मॉडल चलाएं:
litert-lm run google/gemma-3n-E2B-it-litert-lm/gemma-3n-E2B-it-int4 --prompt="What is the capital of France?"
फ़ंक्शन कॉल / टूल
प्रीसेट की मदद से टूल चलाए जा सकते हैं. preset.py बनाने के लिए:
import datetime
import base64
def get_current_time() -> str:
"""Returns the current date and time."""
return datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
system_instruction = "You are a helpful assistant with access to tools."
tools = [get_current_time]
प्रीसेट के साथ चलाएं:
litert-lm run google/gemma-3n-E2B-it-litert-lm/gemma-3n-E2B-it-int4 --preset=preset.py
प्रॉम्प्ट के सैंपल और इंटरैक्टिव आउटपुट:
> what will the time be in two hours?
[tool_call] {"arguments": {}, "name": "get_current_time"}
[tool_response] {"name": "get_current_time", "response": "2026-03-25 21:54:07"}
The current time is 2026-03-25 21:54:07.
In two hours, it will be **2026-03-25 23:54:07**.
यहां क्या हो रहा है?
जब कोई ऐसा सवाल पूछा जाता है जिसके लिए बाहरी जानकारी की ज़रूरत होती है (जैसे, मौजूदा समय), तो मॉडल को पता चल जाता है कि उसे किसी टूल को कॉल करना है.
- मॉडल
tool_callजनरेट करता है: मॉडल,get_current_timeफ़ंक्शन को कॉल करने के लिए JSON अनुरोध जनरेट करता है. - CLI Executes Tool: LiteRT-LM CLI इस कॉल को इंटरसेप्ट करता है और आपके
preset.pyमें तय किए गए Python फ़ंक्शन को लागू करता है. - सीएलआई
tool_responseभेजता है: सीएलआई, मॉडल को नतीजा वापस भेजता है. - मॉडल, आखिरी जवाब जनरेट करता है: मॉडल, टूल के जवाब का इस्तेमाल करके, उपयोगकर्ता के लिए आखिरी जवाब जनरेट करता है.
सीएलआई में "फ़ंक्शन कॉल करना" लूप अपने-आप होता है. इससे आपको Python की सुविधाओं के साथ लोकल एलएलएम को बेहतर बनाने में मदद मिलती है. इसके लिए, आपको कोई जटिल ऑर्केस्ट्रेशन कोड लिखने की ज़रूरत नहीं होती.
ये सुविधाएं, Python, C++, और Kotlin एपीआई से भी उपलब्ध हैं.