# Generated by Django 5.2.12 on 2026-03-30 06:47

from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('links', '0044_add_source_url_to_fileupload'),
    ]

    operations = [
        migrations.CreateModel(
            name='KnowledgeGraphSnapshot',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('status', models.CharField(choices=[('building', 'Building'), ('ready', 'Ready'), ('failed', 'Failed')], db_index=True, default='building', max_length=20, verbose_name='Status')),
                ('graph_data', models.JSONField(default=dict, help_text='Graphology-compatible serialization: {nodes: [...], edges: [...]}', verbose_name='Graph Data')),
                ('node_count', models.IntegerField(default=0, verbose_name='Node Count')),
                ('edge_count', models.IntegerField(default=0, verbose_name='Edge Count')),
                ('used_llm', models.BooleanField(default=False, verbose_name='Used LLM')),
                ('error_message', models.TextField(blank=True, verbose_name='Error Message')),
                ('build_duration_ms', models.IntegerField(default=0, verbose_name='Build Duration (ms)')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Created At')),
                ('completed_at', models.DateTimeField(blank=True, null=True, verbose_name='Completed At')),
            ],
            options={
                'verbose_name': 'Knowledge Graph Snapshot',
                'verbose_name_plural': 'Knowledge Graph Snapshots',
                'ordering': ['-created_at'],
            },
        ),
        migrations.AddField(
            model_name='sitesettings',
            name='kg_auto_schedule_enabled',
            field=models.BooleanField(default=False, help_text='When enabled, the knowledge graph is rebuilt on the configured interval.', verbose_name='Auto-rebuild Knowledge Graph'),
        ),
        migrations.AddField(
            model_name='sitesettings',
            name='kg_auto_schedule_interval',
            field=models.IntegerField(default=3600, help_text='How often (in seconds) to auto-rebuild the knowledge graph. Minimum 60.', verbose_name='Knowledge Graph Rebuild Interval (seconds)'),
        ),
        migrations.AddField(
            model_name='sitesettings',
            name='kg_include_links',
            field=models.BooleanField(default=True, verbose_name='Include Links in Graph'),
        ),
        migrations.AddField(
            model_name='sitesettings',
            name='kg_include_pages',
            field=models.BooleanField(default=True, verbose_name='Include Pages in Graph'),
        ),
        migrations.AddField(
            model_name='sitesettings',
            name='kg_include_posts',
            field=models.BooleanField(default=True, verbose_name='Include Posts in Graph'),
        ),
        migrations.AddField(
            model_name='sitesettings',
            name='kg_include_tags',
            field=models.BooleanField(default=True, verbose_name='Include Tags in Graph'),
        ),
        migrations.AddField(
            model_name='sitesettings',
            name='kg_semantic_threshold',
            field=models.FloatField(default=0.7, help_text='Minimum cosine similarity (0.0–1.0) required to draw a semantic edge between two items.', verbose_name='Semantic Similarity Threshold'),
        ),
        migrations.AddField(
            model_name='sitesettings',
            name='llm_api_key',
            field=models.CharField(blank=True, default='', help_text='API key for OpenRouter (not needed for Ollama).', max_length=255, verbose_name='LLM API Key'),
        ),
        migrations.AddField(
            model_name='sitesettings',
            name='llm_base_url',
            field=models.CharField(blank=True, default='http://localhost:11434', help_text='Base URL for the Ollama server (e.g. http://192.168.1.2:11434).', max_length=255, verbose_name='LLM Base URL'),
        ),
        migrations.AddField(
            model_name='sitesettings',
            name='llm_model',
            field=models.CharField(blank=True, default='nomic-embed-text', help_text='Model name used for embeddings (e.g. nomic-embed-text for Ollama).', max_length=100, verbose_name='LLM Embedding Model'),
        ),
        migrations.AddField(
            model_name='sitesettings',
            name='llm_provider',
            field=models.CharField(choices=[('none', 'None (no LLM)'), ('ollama', 'Ollama (local)'), ('openrouter', 'OpenRouter')], default='none', help_text='LLM/embedding provider used to generate semantic edges in the knowledge graph.', max_length=20, verbose_name='LLM Provider'),
        ),
    ]
