Creation of Bot Interactio Table
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Ekaropolus 2025-07-23 01:04:11 -06:00
parent d52dfe75a2
commit b77133fe83
3 changed files with 72 additions and 1 deletions

View File

@ -94,3 +94,12 @@ from .models import EventType
class EventTypeAdmin(admin.ModelAdmin):
list_display = ("code", "label")
search_fields = ("code", "label")
from .models import BotInteraction
@admin.register(BotInteraction)
class BotInteractionAdmin(admin.ModelAdmin):
list_display = ("page", "object_id", "parent_object_id", "platform", "created_at")
search_fields = ("object_id", "prompt", "bot_response")
list_filter = ("platform",)

View File

@ -0,0 +1,27 @@
# Generated by Django 5.0.3 on 2025-07-23 06:01
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('pxy_meta_pages', '0003_eventtype_facebookevent'),
]
operations = [
migrations.CreateModel(
name='BotInteraction',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('object_id', models.CharField(help_text='The Facebook post or comment ID that we commented on', max_length=100)),
('parent_object_id', models.CharField(blank=True, help_text='If this comment was on a share, the original posts ID', max_length=100, null=True)),
('prompt', models.TextField(help_text='Exact prompt sent to OpenAI for this comment')),
('bot_response', models.TextField(help_text='The text that the bot actually posted')),
('platform', models.CharField(help_text="E.g. 'Facebook' or 'Facebook (Original Post)'", max_length=50)),
('created_at', models.DateTimeField(auto_now_add=True)),
('page', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='bot_interactions', to='pxy_meta_pages.facebookpageassistant')),
],
),
]

View File

@ -65,3 +65,38 @@ class FacebookEvent(models.Model):
def __str__(self):
return f"{self.page.page_name}: {self.event_type.code} @ {self.timestamp:%Y-%m-%d %H:%M}"
class BotInteraction(models.Model):
"""
Stores each AIgenerated comment: which object we replied to, the prompt,
the response, and link back to the original (parent) post if any.
"""
page = models.ForeignKey(
FacebookPageAssistant,
on_delete=models.CASCADE,
related_name="bot_interactions"
)
object_id = models.CharField(
max_length=100,
help_text="The Facebook post or comment ID that we commented on"
)
parent_object_id = models.CharField(
max_length=100,
blank=True,
null=True,
help_text="If this comment was on a share, the original posts ID"
)
prompt = models.TextField(
help_text="Exact prompt sent to OpenAI for this comment"
)
bot_response = models.TextField(
help_text="The text that the bot actually posted"
)
platform = models.CharField(
max_length=50,
help_text="E.g. 'Facebook' or 'Facebook (Original Post)'"
)
created_at = models.DateTimeField(auto_now_add=True)
def __str__(self):
return f"{self.page.page_name}{self.object_id} @ {self.created_at:%Y-%m-%d %H:%M}"