Documentation Index
Fetch the complete documentation index at: https://docs.getmuster.io/llms.txt
Use this file to discover all available pages before exploring further.
Installation
Basic integration
from langchain.chains import LLMChain
import uuid
# muster_emit( # add after job completes
# agent_id="contract-reviewer", version="1.3.0")
def run_contract_review(contract_text: str) -> dict:
job_id = str(uuid.uuid4())
chain = LLMChain(llm=llm, prompt=prompt)
result = chain.invoke({"contract": contract_text})
muster_emit(
job_id=job_id,
overall_passed=bool(result.get("output")),
token_input=result.get("token_usage", {}).get("prompt_tokens", 0),
token_output=result.get("token_usage", {}).get("completion_tokens", 0),
model="gpt-4o",
checks=[
quality.Check("output_not_empty", "HIGH", bool(result.get("output"))),
quality.Check("risk_flag_present", "HIGH", "risk_flags" in result),
quality.Check("source_cited", "HIGH", "source" in result),
]
)
return result
Using LangChain callbacks
For automatic token tracking, use LangChain’s callback system:
from langchain.callbacks import get_openai_callback
with get_openai_callback() as cb:
result = chain.invoke({"contract": contract_text})
muster_emit(
job_id=job_id,
overall_passed=bool(result),
token_input=cb.prompt_tokens,
token_output=cb.completion_tokens,
model="gpt-4o",
checks=[
quality.Check("output_not_empty", "HIGH", bool(result)),
]
)