Example Projects

Example Projects

Real-world example projects and use cases for Yachtsy AI models.

Example Projects

Explore real-world examples of how to use Yachtsy Agent for different sailing and yachting applications.

Common Use Cases

Yacht Brokerage Assistant

Help customers find the perfect yacht with AI-powered recommendations:

from openai import OpenAI

client = OpenAI(
    base_url="http://localhost:8000/v1",
    api_key="your-api-key"
)

def find_yacht_recommendations(budget, length, sailing_style, experience):
    prompt = f"""
    I'm looking for yacht recommendations with these criteria:
    - Budget: ${budget:,}
    - Length: {length} feet
    - Sailing style: {sailing_style}
    - Experience level: {experience}
    
    Please suggest 3-5 specific yacht models with brief explanations of why each would be suitable.
    """
    
    response = client.chat.completions.create(
        model="yachtsy-agent",
        messages=[
            {"role": "system", "content": "You are an experienced yacht broker with deep knowledge of the used yacht market."},
            {"role": "user", "content": prompt}
        ],
        temperature=0.7
    )
    
    return response.choices[0].message.content

# Example usage
recommendations = find_yacht_recommendations(
    budget=150000,
    length="35-40",
    sailing_style="coastal cruising with occasional offshore passages",
    experience="intermediate"
)
print(recommendations)

Weather Routing Assistant

Get passage planning and weather advice:

async function getPassagePlanning(departure, destination, timeframe, boatType) {
    const response = await fetch('/api/chat', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({
            messages: [
                {
                    role: "system",
                    content: "You are a professional yacht delivery captain with extensive offshore experience. Provide detailed passage planning advice considering weather patterns, currents, and seasonal conditions."
                },
                {
                    role: "user",
                    content: `Plan a passage from ${departure} to ${destination} in ${timeframe} for a ${boatType}. Include timing recommendations, weather considerations, and key waypoints.`
                }
            ]
        })
    });
    
    const data = await response.json();
    return data.choices[0].message.content;
}

// Example usage
const passagePlan = await getPassagePlanning(
    "Fort Lauderdale, FL",
    "Georgetown, Bahamas",
    "December 2024",
    "42ft catamaran"
);

Maintenance Scheduler

Create intelligent maintenance reminders:

def create_maintenance_schedule(boat_info, usage_hours, last_service_date):
    prompt = f"""
    Create a maintenance schedule for:
    - Boat: {boat_info['make']} {boat_info['model']} ({boat_info['year']})
    - Engine: {boat_info['engine']}
    - Annual usage: {usage_hours} hours
    - Last major service: {last_service_date}
    
    Provide a prioritized maintenance checklist with recommended intervals and brief explanations of why each item is important.
    """
    
    response = client.chat.completions.create(
        model="yachtsy-agent",
        messages=[
            {"role": "system", "content": "You are a certified marine mechanic and yacht maintenance expert."},
            {"role": "user", "content": prompt}
        ]
    )
    
    return response.choices[0].message.content

# Example usage
boat_info = {
    "make": "Catalina",
    "model": "34",
    "year": "2005",
    "engine": "Universal M-25XP diesel"
}

schedule = create_maintenance_schedule(
    boat_info=boat_info,
    usage_hours=80,
    last_service_date="March 2024"
)

Sailing Education Examples

Interactive Sailing Lessons

class SailingTutor {
    constructor() {
        this.client = new OpenAI({
            baseURL: 'http://localhost:8000/v1',
            apiKey: process.env.YACHTSY_API_KEY
        });
    }

    async teachConcept(concept, studentLevel, previousQuestions = []) {
        const context = previousQuestions.length > 0 
            ? `Previous questions in this session: ${previousQuestions.join(', ')}`
            : '';

        const response = await this.client.chat.completions.create({
            model: 'yachtsy-agent',
            messages: [
                {
                    role: 'system',
                    content: `You are a patient sailing instructor teaching ${studentLevel} sailors. Use clear explanations with practical examples. ${context}`
                },
                {
                    role: 'user',
                    content: `Explain ${concept} in a way that's appropriate for a ${studentLevel} sailor. Include practical tips and safety considerations.`
                }
            ],
            temperature: 0.6
        });

        return response.choices[0].message.content;
    }

    async askQuizQuestion(topic, difficulty) {
        const response = await this.client.chat.completions.create({
            model: 'yachtsy-agent',
            messages: [
                {
                    role: 'system',
                    content: 'You are creating sailing quiz questions. Provide one multiple-choice question with 4 options and explain the correct answer.'
                },
                {
                    role: 'user',
                    content: `Create a ${difficulty} level quiz question about ${topic}`
                }
            ],
            temperature: 0.8
        });

        return response.choices[0].message.content;
    }
}

// Usage
const tutor = new SailingTutor();

// Teach a concept
const lesson = await tutor.teachConcept(
    'points of sail',
    'beginner',
    ['What is the wind window?', 'How do sails work?']
);

// Generate quiz question
const quiz = await tutor.askQuizQuestion('right of way rules', 'intermediate');

Safety Scenario Training

def generate_safety_scenario(scenario_type, boat_size, crew_experience):
    prompt = f"""
    Generate a realistic sailing safety scenario for training purposes:
    - Scenario type: {scenario_type}
    - Boat size: {boat_size}
    - Crew experience: {crew_experience}
    
    Include:
    1. The situation description
    2. What signs/symptoms to watch for
    3. Step-by-step response procedure
    4. Prevention tips for the future
    
    Make it realistic but educational.
    """
    
    response = client.chat.completions.create(
        model="yachtsy-agent",
        messages=[
            {"role": "system", "content": "You are a sailing safety instructor creating realistic training scenarios."},
            {"role": "user", "content": prompt}
        ]
    )
    
    return response.choices[0].message.content

# Generate different scenarios
scenarios = [
    generate_safety_scenario("man overboard", "35ft sloop", "novice crew"),
    generate_safety_scenario("engine failure", "40ft catamaran", "experienced crew"),
    generate_safety_scenario("medical emergency", "28ft coastal cruiser", "mixed experience")
]

Equipment Recommendation Engine

async function recommendEquipment(boatSpecs, sailingType, budget) {
    const systemPrompt = `You are a marine equipment expert helping sailors choose the right gear. Consider compatibility, quality, budget, and specific use cases. Always mention specific brands and models when appropriate.`;
    
    const userPrompt = `
    Recommend equipment for:
    - Boat: ${boatSpecs.length}ft ${boatSpecs.type}
    - Primary use: ${sailingType}
    - Budget: $${budget}
    - Current equipment gaps: ${boatSpecs.needsUpgrade.join(', ')}
    
    Prioritize recommendations by safety importance and provide specific product suggestions with approximate prices.
    `;

    const response = await fetch('/api/chat', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({
            messages: [
                { role: 'system', content: systemPrompt },
                { role: 'user', content: userPrompt }
            ]
        })
    });

    return await response.json();
}

// Example usage
const recommendations = await recommendEquipment(
    {
        length: 38,
        type: 'sloop',
        needsUpgrade: ['autopilot', 'chart plotter', 'life raft']
    },
    'offshore cruising',
    15000
);

Destination Guide Generator

def generate_cruising_guide(destination, boat_draft, crew_size, interests):
    prompt = f"""
    Create a comprehensive cruising guide for {destination} including:
    
    Boat specifications to consider:
    - Draft: {boat_draft} feet
    - Crew size: {crew_size}
    - Interests: {', '.join(interests)}
    
    Please include:
    1. Best anchorages and marinas (considering draft limitations)
    2. Local regulations and customs procedures
    3. Provisioning opportunities
    4. Weather patterns and best sailing seasons
    5. Local attractions matching crew interests
    6. Safety considerations and emergency contacts
    7. Approximate costs for marina fees, fuel, provisions
    """
    
    response = client.chat.completions.create(
        model="yachtsy-agent",
        messages=[
            {"role": "system", "content": "You are an experienced cruising sailor who has visited destinations worldwide. Provide practical, up-to-date advice."},
            {"role": "user", "content": prompt}
        ],
        temperature=0.7
    )
    
    return response.choices[0].message.content

# Generate guides for different destinations
destinations = [
    {
        "location": "British Virgin Islands",
        "draft": 4.5,
        "crew": 4,
        "interests": ["snorkeling", "beach bars", "sailing"]
    },
    {
        "location": "Greek Islands (Cyclades)",
        "draft": 6.2,
        "crew": 6,
        "interests": ["history", "local cuisine", "hiking"]
    }
]

for dest in destinations:
    guide = generate_cruising_guide(
        dest["location"],
        dest["draft"],
        dest["crew"],
        dest["interests"]
    )
    print(f"\n=== {dest['location']} Guide ===")
    print(guide)

Real-time Chat Integration

Complete example of a sailing chat application with context memory:

class YachtsyChatBot {
    constructor(apiKey) {
        this.client = new OpenAI({
            baseURL: 'http://localhost:8000/v1',
            apiKey: apiKey
        });
        this.conversationHistory = [];
        this.userContext = {};
    }

    setUserContext(context) {
        this.userContext = { ...this.userContext, ...context };
    }

    async chat(message, streaming = false) {
        // Add context to system message if available
        const systemMessage = {
            role: 'system',
            content: this.buildSystemPrompt()
        };

        const messages = [
            systemMessage,
            ...this.conversationHistory,
            { role: 'user', content: message }
        ];

        if (streaming) {
            return this.streamResponse(messages);
        } else {
            return this.getResponse(messages);
        }
    }

    buildSystemPrompt() {
        let prompt = "You are Yachtsy, an expert sailing assistant. Provide helpful, accurate, and safety-conscious advice.";
        
        if (this.userContext.boatType) {
            prompt += ` The user sails a ${this.userContext.boatType}.`;
        }
        if (this.userContext.experience) {
            prompt += ` Their experience level is ${this.userContext.experience}.`;
        }
        if (this.userContext.sailingRegion) {
            prompt += ` They primarily sail in ${this.userContext.sailingRegion}.`;
        }
        
        return prompt;
    }

    async getResponse(messages) {
        try {
            const response = await this.client.chat.completions.create({
                model: 'yachtsy-agent',
                messages: messages,
                temperature: 0.7,
                max_tokens: 1000
            });

            const assistantMessage = response.choices[0].message;
            
            // Store conversation history
            this.conversationHistory.push(
                messages[messages.length - 1], // user message
                assistantMessage // assistant response
            );

            // Keep conversation history manageable
            if (this.conversationHistory.length > 20) {
                this.conversationHistory = this.conversationHistory.slice(-20);
            }

            return assistantMessage.content;
        } catch (error) {
            console.error('Error:', error);
            return "I'm sorry, I encountered an error. Please try again.";
        }
    }

    async *streamResponse(messages) {
        try {
            const stream = await this.client.chat.completions.create({
                model: 'yachtsy-agent',
                messages: messages,
                stream: true,
                temperature: 0.7
            });

            let fullResponse = '';
            
            for await (const chunk of stream) {
                const content = chunk.choices[0]?.delta?.content || '';
                if (content) {
                    fullResponse += content;
                    yield content;
                }
            }

            // Store complete conversation
            this.conversationHistory.push(
                messages[messages.length - 1],
                { role: 'assistant', content: fullResponse }
            );

            if (this.conversationHistory.length > 20) {
                this.conversationHistory = this.conversationHistory.slice(-20);
            }

        } catch (error) {
            console.error('Error:', error);
            yield "I'm sorry, I encountered an error. Please try again.";
        }
    }

    clearHistory() {
        this.conversationHistory = [];
    }
}

// Usage example
const chatBot = new YachtsyChatBot('your-api-key');

// Set user context for personalized responses
chatBot.setUserContext({
    boatType: '35ft Catalina sloop',
    experience: 'intermediate',
    sailingRegion: 'Chesapeake Bay'
});

// Regular chat
const response = await chatBot.chat("What's the best anchor for my boat?");
console.log(response);

// Streaming chat
console.log("Streaming response:");
for await (const chunk of chatBot.chat("Plan a weekend cruise route", true)) {
    process.stdout.write(chunk);
}
Tip: These examples show the versatility of Yachtsy Agent. Adapt them to your specific use case and always implement proper error handling and security measures in production.