Appearance
Amazon SageMaker
Invoke your own deployed SageMaker endpoint with SageMakerAIModel. Use this when you host a custom or fine-tuned model on AWS SageMaker.
For standalone invoke / stream usage, see LLM Models — Amazon SageMaker.
Install
bash
pip install --extra-index-url https://core-packages.elsai.ai/root/ "elsai-model[sagemaker]==2.1.0"
pip install --extra-index-url https://elsai-agents.elsai.ai/root/ elsai-agents==0.3.1Setup
- Deploy a SageMaker endpoint in your AWS account.
- Configure AWS credentials and export the endpoint name:
bash
export AWS_ACCESS_KEY_ID=...
export AWS_SECRET_ACCESS_KEY=...
export AWS_REGION=us-west-2
export SAGEMAKER_ENDPOINT_NAME=your-endpoint-nameAgent — basic
python
import os
from elsai import Agent
from elsai_model import LLM, Provider
model = LLM(
provider=Provider.SAGEMAKER,
endpoint_config={
"endpoint_name": os.environ["SAGEMAKER_ENDPOINT_NAME"],
"region_name": os.getenv("AWS_REGION", "us-west-2"),
},
payload_config={"max_tokens": 256, "temperature": 0.2},
)
agent = Agent(
model=model,
system_prompt="You are a concise assistant.",
)
result = agent("Summarize what an AI agent is in two sentences.")
print(result)