This repository provides a comprehensive collection of AI agent examples and implementation guides using the Venice AI PHP SDK. Whether you're new to AI agents or looking to build sophisticated applications, these examples demonstrate how to leverage AI for decision-making, autonomous actions, and natural language understanding.
AI agents are software programs that use artificial intelligence to:
- Process and understand user inputs
- Make autonomous decisions
- Perform actions based on those decisions
- Maintain state and context across interactions
- Provide natural language responses
Unlike traditional scripts with predefined logic paths, AI agents use large language models to understand context, determine intent, and generate dynamic responses.
This repository includes ready-to-use examples at various complexity levels:
A beginner-friendly chat agent that maintains conversations and remembers basic user information.
Key features:
- Basic conversation management
- Simple memory system
- Pattern-based command recognition
- Natural language responses
A task-oriented agent that helps manage a to-do list with persistent storage.
Key features:
- Task creation, completion, and deletion
- Data persistence using JSON storage
- Intent classification with AI
- Natural language task understanding
A domain-specific agent that provides weather information and remembers user preferences.
Key features:
- Location-based weather forecasts
- User preference storage
- Weather-based recommendations
- Multi-day forecasts
A versatile agent that combines multiple capabilities into one intelligent assistant.
Key features:
- Calendar management
- Note taking and retrieval
- Weather forecasts
- Web search functionality
- User preference management
- Advanced intent classification
A highly specialized agent focused on recipes, cooking, and dietary preferences.
Key features:
- Recipe suggestions based on ingredients
- Dietary restriction handling
- Step-by-step cooking instructions
- Ingredient substitutions
- Recipe scaling
- User food preference tracking
In addition to the examples, this repository includes detailed guides to help you understand and build your own AI agents:
- Simple Agent Concept - Clear explanation of what makes software "agentic"
- Agent Demo Plan - Comprehensive plan for building a full-featured agent
- Venice Agent Implementation Guide - Step-by-step implementation instructions
- Simple Venice Agent - A complete, single-file agent implementation
- Agent Implementation Roadmap - A guided path to building agents of increasing complexity
All examples showcase key capabilities that define true AI agents:
Using AI to understand what users want to accomplish, beyond simple command matching.
// Example of AI-based intent recognition
private function determineIntent($message) {
// Create system prompt for intent classification
$systemPrompt = "Analyze the user message and determine their intent...";
// Get response from Venice AI
$response = $this->venice->createChatCompletion([
['role' => 'system', 'content' => $systemPrompt],
['role' => 'user', 'content' => $message]
]);
// Extract and parse intent
$intentData = json_decode($response['choices'][0]['message']['content'], true);
return $intentData;
}Agents make decisions about how to handle inputs rather than following predefined logic paths.
// Example of autonomous decision making
private function handleIntent($intent, $message) {
switch ($intent['intent']) {
case 'add_task':
return $this->addTask($intent['parameters']);
case 'list_tasks':
return $this->listTasks();
case 'find_task':
return $this->findTask($intent['parameters']);
default:
// Generate a conversational response when no specific intent is matched
return $this->generateConversationalResponse($message);
}
}Agents maintain state across interactions to provide contextual responses.
// Example of memory management
private function addToHistory($role, $content) {
$this->conversationHistory[] = [
'role' => $role,
'content' => $content
];
// Limit history size
if (count($this->conversationHistory) > 20) {
array_shift($this->conversationHistory);
}
}Agents process natural language input without requiring specific command formats.
// Example of extracting information from natural language
private function extractUserInfo($message) {
if (preg_match('/my name is ([a-z\s]+)/i', $message, $matches)) {
$this->userInfo['name'] = trim($matches[1]);
}
if (preg_match('/i (?:live|am) (?:in|from) ([a-z\s]+)/i', $message, $matches)) {
$this->userInfo['location'] = trim($matches[1]);
}
}Agents perform actions based on their understanding of user intent.
// Example of function execution based on intent
private function addTask($parameters) {
$title = $parameters['title'] ?? null;
$dueDate = $parameters['due_date'] ?? null;
if (!$title) {
return "I need a title for your task. What would you like to add?";
}
$task = [
'id' => uniqid(),
'title' => $title,
'completed' => false,
'created_at' => date('Y-m-d H:i:s'),
'due_date' => $dueDate
];
$this->tasks[] = $task;
$this->saveTasks();
return "I've added \"$title\" to your task list" .
($dueDate ? " with due date $dueDate" : "") . ".";
}- PHP 7.4 or higher
- Venice AI API key
- Basic understanding of PHP programming
- Clone this repository:
git clone https://github.com/yourusername/venice-ai-php-agents.git
- Copy configuration file:
cp config.example.php config.php
- Edit config.php to add your Venice AI API key:
return [
'api_key' => 'your-venice-api-key-here',
];- Choose an example that matches your needs and run it:
php path/to/example/file.php
Follow these steps to build your own custom agent:
- Define your agent's purpose: What specific tasks will it help with?
- Choose a complexity level: Start simple and add capabilities as needed
- Select relevant examples: Use the provided examples as starting points
- Implement core functions: Intent recognition, memory management, etc.
- Test and refine: Iterate based on user interactions
Refer to the Agent Implementation Roadmap for detailed guidance.
These agent examples can be adapted for various real-world applications:
- Customer Service: Automated support agents that understand and resolve issues
- Personal Productivity: Task management, scheduling, and information retrieval
- Content Creation: Assistants that help generate or organize content
- E-commerce: Shopping assistants that help users find products
- Education: Tutors that provide personalized learning assistance
- Healthcare: Assistants that help with medical information or appointment scheduling
For more sophisticated agents, consider these advanced techniques:
- Tool Integration: Allow your agent to use external tools and APIs
- Multi-step Reasoning: Break complex tasks into smaller reasoning steps
- Feedback Learning: Improve agent responses based on user feedback
- Context Windowing: Manage larger conversation contexts efficiently
- Function Calling: Implement structured function calling with parameter validation
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.