Creation of Bot Interactio Table
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
d52dfe75a2
commit
b77133fe83
@ -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",)
|
||||
|
||||
|
27
pxy_meta_pages/migrations/0004_botinteraction.py
Normal file
27
pxy_meta_pages/migrations/0004_botinteraction.py
Normal 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 post’s 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')),
|
||||
],
|
||||
),
|
||||
]
|
@ -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 AI‐generated 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 post’s 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}"
|
Loading…
x
Reference in New Issue
Block a user