Implement AI workspace and mitigation workflow
This commit is contained in:
@@ -1,13 +1,16 @@
|
||||
from core.lib.prompts import bases
|
||||
from openai import AsyncOpenAI
|
||||
from asgiref.sync import sync_to_async
|
||||
from core.models import Message, ChatSession, AI, Person, Manipulation
|
||||
from core.util import logs
|
||||
import json
|
||||
import asyncio
|
||||
from django.utils import timezone
|
||||
import json
|
||||
import random
|
||||
|
||||
from asgiref.sync import sync_to_async
|
||||
from django.utils import timezone
|
||||
from openai import AsyncOpenAI
|
||||
|
||||
from core.lib.prompts import bases
|
||||
from core.models import AI, ChatSession, Manipulation, Message, Person
|
||||
from core.util import logs
|
||||
|
||||
|
||||
def generate_prompt(msg: dict, person: Person, manip: Manipulation, chat_history: str):
|
||||
"""
|
||||
Generate a structured prompt using the attributes of the provided Person and Manipulation models.
|
||||
@@ -18,7 +21,6 @@ def generate_prompt(msg: dict, person: Person, manip: Manipulation, chat_history
|
||||
|
||||
system_message = (
|
||||
"You are my digital persona, responding on my behalf while embodying my personality, preferences, and unique style.\n\n"
|
||||
|
||||
"### Persona Profile ###\n"
|
||||
f"- **MBTI:** {persona.mbti} ({persona.mbti_identity} balance)\n"
|
||||
f"- **Tone:** {persona.tone} | **Humor:** {persona.humor_style}\n"
|
||||
@@ -29,7 +31,6 @@ def generate_prompt(msg: dict, person: Person, manip: Manipulation, chat_history
|
||||
f"- **Response Tactics:** {persona.response_tactics}\n"
|
||||
f"- **Persuasion Techniques:** {persona.persuasion_tactics}\n"
|
||||
f"- **Boundaries:** {persona.boundaries} | **Adaptability:** {persona.adaptability}%\n\n"
|
||||
|
||||
"### Contact Information ###\n"
|
||||
f"- **Summary:** {person.summary or 'N/A'}\n"
|
||||
f"- **Profile:** {person.profile or 'N/A'}\n"
|
||||
@@ -38,10 +39,8 @@ def generate_prompt(msg: dict, person: Person, manip: Manipulation, chat_history
|
||||
f"- **Timezone:** {person.timezone or 'N/A'}\n"
|
||||
f"- **Last Interaction:** {person.last_interaction or 'Never'}\n"
|
||||
f"- **Current Date/Time:** {now}\n\n"
|
||||
|
||||
"### Conversation Context ###\n"
|
||||
f"{chat_history if chat_history else 'No prior chat history.'}\n\n"
|
||||
|
||||
"### Response Guidelines ###\n"
|
||||
"- **Engagement**: Keep responses engaging, with a balance of wit, depth, and confidence.\n"
|
||||
"- **Flirting**: Be direct, playful, and, when appropriate, subtly provocative—without hesitation.\n"
|
||||
@@ -56,10 +55,11 @@ def generate_prompt(msg: dict, person: Person, manip: Manipulation, chat_history
|
||||
{"role": "user", "content": user_message},
|
||||
]
|
||||
|
||||
|
||||
async def run_context_prompt(
|
||||
prompt: list[str],
|
||||
ai: AI,
|
||||
):
|
||||
prompt: list[str],
|
||||
ai: AI,
|
||||
):
|
||||
cast = {"api_key": ai.api_key}
|
||||
if ai.base_url is not None:
|
||||
cast["api_key"] = ai.base_url
|
||||
@@ -70,4 +70,4 @@ async def run_context_prompt(
|
||||
)
|
||||
content = response.choices[0].message.content
|
||||
|
||||
return content
|
||||
return content
|
||||
|
||||
Reference in New Issue
Block a user