Repository navigation
v0.2.0
This release marks the first version built on our major core refactoring towards Rust.
For the full feature set and updated guides, see our documentation.
Major API changes
Initializing Language Models and Agents
import ailoy as ai
# Local models
model = await ai.LangModel.new_local("Qwen/Qwen3-0.6B")
# API-based models
model = ai.LangModel.new_stream_api("OpenAI", "gpt-5-mini", "<OPENAI_API_KEY>")
# Creating an agent
agent = ai.Agent(model)Running Agents
# Stream responses per message
async for resp in agent.run("What is your name?"):
print(resp.message)
# Stream token-level message deltas
async for resp in agent.runDelta("What is your name?"):
print(resp.delta)Using Tools
tool_desc = ai.ToolDesc(...)
def tool_behavior(...):
...
# Create a Python function tool
tool = ai.Tool.new_py_function(tool_behavior, tool_desc)
# Add a tool to an agent
agent.add_tool(tool)
# Using MCP tools
client = await ai.MCPClient.from_stdio("npx", ["-y", "@modelcontextprotocol/server-github"])
tools = [
client.get_tool("search_repositories"),
client.get_tool("get_file_contents"),
]
agent.add_tools(tools)Knowledge Integration (EmbeddingModel + VectorStore)
# Create an embedding model
embed = await ai.EmbeddingModel.new_local("BAAI/bge-m3")
# Create a vector store
vs = ai.VectorStore.new_faiss(1024)
# Create a Knowledge
knowledge = ai.Knowledge.new_vector_store(vs, embed)
# Insert documents
doc = "Ailoy is an awesome AI agent framework"
embedding = await embed.infer(doc)
await vs.add_vector(ai.VectorStoreAddInput(
embedding=embedding,
document=doc,
metadata={"topic": "ailoy"}
)
# Create an agent with knowledge
agent = ai.Agent(..., knowledge=knowledge)
# Apply document polyfill to make the agent document-aware
config = ai.AgentConfig(
inference=ai.InferenceConfig(document_polyfill=ai.get_qwen3_polyfill())
)
async for resp in agent.run("What is Ailoy?"):
print(resp.message)