LiteRT-LM 명령줄 인터페이스 (CLI)를 사용하면 터미널을 사용하여 모델을 실행하고 모델과 상호작용할 수 있습니다.
설치
uv 사용 (권장)
uv 설치 가이드에 따라 uv를 설치합니다.
uv tool install litert-lm-nightly
pip 사용
python3 -m venv .venv
source .venv/bin/activate
pip install litert-lm-nightly
채팅
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가 도구를 실행함: LiteRT-LM CLI가 이 호출을 가로채고
preset.py에 정의된 해당 Python 함수를 실행합니다. - CLI가
tool_response전송: CLI가 결과를 모델에 다시 전송합니다. - 모델이 최종 답변 생성: 모델이 도구 응답을 사용하여 사용자를 위한 최종 답변을 계산하고 생성합니다.
이 '함수 호출' 루프는 CLI 내에서 자동으로 실행되므로 복잡한 오케스트레이션 코드를 작성하지 않고도 Python 기능을 사용하여 로컬 LLM을 보강할 수 있습니다.
Python, C++, Kotlin API에서도 동일한 기능을 사용할 수 있습니다.