Śledzenie i monitorowanie wywołań LLM
Rejestruj tokeny, opóźnienie i koszt każdego żądania
Śledzenie i monitorowanie wywołań LLM to bezpłatna lekcja MLOps Academy na CoddyKit. To lekcja 3 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej MLOps Academy, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs MLOps Academy zawiera 4 lekcji w sumie.
Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.
You Cannot Fix What You Cannot See
An LLM app feels like a black box until you log what it does. Tracing records each call so you can debug, cost, and improve it later. 🔍
Capture the Request
For every call, log the final prompt, the model name, and key parameters. This request record lets you reproduce any answer exactly.
log.info({"model": "gpt-4o", "prompt": prompt, "temperature": 0.2})Capture the Response
Save the generated text alongside the request. Together the input and output form one trace you can replay, score, or share with a teammate.
Record Token Usage
Each response reports tokens in and out. Logging tokens per call is how you attribute cost and spot prompts that quietly grew too large.
usage = response.usage
log.info({"in": usage.input_tokens, "out": usage.output_tokens})Turn Tokens Into Cost
Multiply token counts by the price per token to get spend. Tracking cost per request keeps a runaway feature from surprising you on the bill.
cost = inp / 1e6 * 2.50 + out / 1e6 * 10.00Measure Latency
Time each call from send to final token. Watching latency per request reveals slow prompts and tells you when streaming would help users.
start = time.perf_counter()
response = client.responses.create(...)
latency = time.perf_counter() - startSpans Build a Trace
A real request may chain retrieval, the LLM, and a tool. Each step is a span, and nesting them into one trace shows where time and tokens go.
Tools Built for LLMs
Platforms like LangSmith, Langfuse, and Phoenix capture traces with one wrapper. A purpose-built observability tool beats parsing raw logs by hand.
from langfuse.openai import openai
response = openai.responses.create(model="gpt-4o", input=prompt)Tag Traces With Metadata
Attach a user id, prompt version, and feature name to each trace. This metadata lets you slice metrics and find which segment is misbehaving.
Sample What You Cannot Store
At high volume, logging every full payload is costly. Sampling a fraction of traces keeps insight while controlling storage and privacy.
Dashboards and Alerts
Roll traces into dashboards for cost, latency, and error rate, then alert on spikes. Now production problems reach you before users complain.
Quick Check
Your monthly LLM bill jumped with no traffic change. Which logged value explains it fastest?
Recap
You can now trace LLM calls end to end: request, response, tokens, cost, latency, and spans, then watch them on dashboards. Eyes wide open! 🎉
Często zadawane pytania
Czy lekcja „Śledzenie i monitorowanie wywołań LLM” jest bezpłatna?
Tak — pełny tekst „Śledzenie i monitorowanie wywołań LLM” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu MLOps Academy, przejdź na CoddyKit PRO. Kurs MLOps Academy zawiera 4 lekcji w sumie.
Co nauczysz się w „Śledzenie i monitorowanie wywołań LLM”?
Rejestruj tokeny, opóźnienie i koszt każdego żądania Ćwiczysz MLOps Academy z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.
Czy potrzebuję doświadczenia, aby zacząć MLOps Academy?
Nie wymagamy żadnego doświadczenia. MLOps Academy w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 3 z 4.
Ile czasu zajmuje lekcja „Śledzenie i monitorowanie wywołań LLM”?
Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.
Czy mogę pisać i uruchamiać kod w tej lekcji MLOps Academy?
Tak. Każda lekcja MLOps Academy zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.
Wszystkie lekcje w tym kursie
- Czym LLMOps różni się od klasycznego MLOps
- Wersjonowanie promptów i ocena wyników
- Śledzenie i monitorowanie wywołań LLM
- Guardrails i ocena RAG