LlamaIndex
LlamaIndex
AgentOps가 LlamaIndex와 원활하게 동작하는 방법을 소개해요. LlamaIndex는 LLM으로 컨텍스트 강화 생성형 AI 애플리케이션을 구축하는 프레임워크이죠. 설치부터 사용법, 추적되는 작업까지 알아볼게요.
출처: 문서
본문
LlamaIndex는 LLM으로 컨텍스트 강화 생성형 AI 애플리케이션을 구축하기 위한 프레임워크예요. AgentOps는 자동 계측을 통해 LlamaIndex 애플리케이션에 대한 포괄적인 관측성을 제공하여, LLM 호출 모니터링, 성능 추적, 애플리케이션 동작 분석을 가능하게 해줍니다.
설치 (Installation)
AgentOps와 LlamaIndex AgentOps 계측 패키지를 설치하세요.
poetry add agentops llama-index-instrumentation-agentops
uv pip install agentops llama-index-instrumentation-agentops
API 키 설정 (Setting Up API Keys)
AgentOps Dashboard에서 AgentOps API 키가 필요해요.
AGENTOPS_API_KEY="your_agentops_api_key_here"
사용법 (Usage)
LlamaIndex 애플리케이션 시작 시 전역 핸들러를 "agentops"로 설정하기만 하면 됩니다. AgentOps는 LlamaIndex를 자동으로 계측해 LLM 상호작용과 애플리케이션 성능을 추적합니다.
from llama_index.core import set_global_handler
from llama_index.core import VectorStoreIndex, SimpleDirectoryReader
# Set the global handler to AgentOps
# NOTE: Feel free to set your AgentOps environment variables (e.g., 'AGENTOPS_API_KEY')
# as outlined in the AgentOps documentation, or pass the equivalent keyword arguments
# anticipated by AgentOps' AOClient as **eval_params in set_global_handler.
set_global_handler("agentops")
# Your LlamaIndex application code here
documents = SimpleDirectoryReader("data").load_data()
index = VectorStoreIndex.from_documents(documents)
# Create a query engine
query_engine = index.as_query_engine()
# Query your data - AgentOps will automatically track this
response = query_engine.query("What is the main topic of these documents?")
print(response)
무엇이 추적되나요? (What Gets Tracked)
LlamaIndex와 함께 AgentOps를 사용하면 다음 작업이 자동으로 추적됩니다.
- LLM Calls: 프롬프트, 완성(completion), 토큰 사용량을 포함한 언어 모델과의 모든 상호작용
- Embeddings: 벡터 임베딩 생성과 검색 작업
- Query Operations: 인덱스에서의 검색과 검색 작업
- Performance Metrics: 응답 시간, 토큰 비용, 성공/실패율
추가 리소스 (Additional Resources)
LlamaIndex의 관측성 기능과 AgentOps 통합에 대한 더 자세한 정보는 LlamaIndex 문서를 확인하세요.