I'm using Turn-Topic maps to analyze social dynamics in group discussions. Turn-Topic…
- User
I'm using Turn-Topic maps to analyze social dynamics in group discussions. Turn-Topic maps are grids that map each turn to the topics it addresses. The columns represent turns, and the rows correspond to topics. A cell has a value X if the corresponding topic is describing the relevant turn. I want to implement an LLM agent in Python that generates Turn Topic maps for a given discussion. The agent works in steps. In each step, a different turn is processed. The LLM handling the given turn gets the previous turns and outputs, as history. There is an option to correct a previous turn, but the logic is that the agent produces a single column each turn. The list of topics is created on-the-fly, and is sorted by the order the topics first appear in the discussion. Is the role clear?
Assistant
Yes, the role is perfectly clear.You're describing an agent that builds a Turn-Topic map (a matrix) by processing a discussion sequentially, one turn at a time.Here's my understanding of the process:Iterative Process: The agent loops through the discussion, processing Turn 1, then Turn 2, and so on.Dynamic Rows (Topics): The list of topics (the map's rows) is not fixed. When the LLM processes a turn and identifies a topic that hasn't been seen before, it appends that new topic to the bottom of the topic list.Column Generation: In each step, the agent's main job is to produce a single new column corresponding to the current turn. This column will have an 'X' (or similar marker) for every topic (both old and newly added) that is present in this specific turn.History Context: To make its decision for the current turn, the LLM is given the content of all previous turns and the map (or outputs) it has generated so far.Correction (Advanced Feature): You've also included a mechanism for the agent to go back and correct previous columns, which is a key feature for improving accuracy as more context becomes available.Essentially, the agent is dynamically building both the rows (topics) and columns (turns) of the map as it moves through the discussion.Would you like to move on to outlining the Python class structure for this agent, or perhaps discuss the specific prompts you'd use for the LLM?
- User
We need to discuss the final data structure. The final output will be a list of dictionaries representing topic arrays. Each topic dictionary will have a single key with the topic name, and the value will be a list of the size of the number of turns. The indices that correspond to turns that address the specific topic will have the value 1, and the rest of the entries will be 0.
Assistant
Got it. So, the final output isn't the map itself, but a list of topic rows.Just to confirm, for a simple discussion like this:Turn 1: "Let's talk about the budget."Turn 2: "I'm worried about the timeline."Turn 3: "The budget really impacts the timeline."The final data structure would be:JSON[ { "budget": [1, 0, 1] }, { "timeline": [0, 1, 1] } ] This makes sense. Even though the agent processes the data column by column (one turn at a time), the final output is transposed into this "row-first" (topic-first) format.This structure is clear. Are you ready to outline the agent's main Python class and the helper functions it might need?
- User
Yes. I want a basic Python skeleton implementation
Assistant
- User
Is this a clear system prompt? SYS_PROMPT = """You are an expert in analyzing Hebrew group discussions. You will review a turn in a discussion along with the history of previous turns. A turn topic map tracks which topics are discussed in each turn. The columns represent turns, and the rows correspond to topics. Your task is to generate a column in a Turn-Topic map for the given turn. """
Assistant
- User
Make the examples match the output format rule. SYS_PROMPT = """You are an expert in analyzing group discussions in Hebrew. Your task is to identify all topics present in a single "turn" of a discussion. You will review: 1. The turn to analyze. 2. The discussion history for context. 3. A list of existing topics identified so far. # Instructions: 1. Re-use Existing Topics: If the "current turn" discusses a topic from the existing-topics list, you MUST include its exact name in your output. 2. Identify New Topics: If the turn introduces a new topic that is NOT in the existing-topics list, you MUST create a concise, new topic name for it and include it in your output. 3. Output Format: You MUST respond with ONLY a JSON list of topic strings. 4. Empty Turns: If no topics are identified in the current turn, you MUST respond with an empty list: []. # Examples Turn: "לדעתי נכון שמגילת העצמאות תהיה בסיסי לחוקים בישראל אני מסכימה עם החזון והערכים הכתובים שם , אך לדעתי יש בצורה שבה נכתבה בעיתיות ויש צורך לשינוי . ראשית , האנשים אשר כתבו את מגילת העצמאות לעולם לא נבחרו " " לא יעלה על הדעת , ש – 37 אנשיםשלא נבחרו מעולם . . . מבלי שהתכוונו יצרו לנו מסמך שנקרא חוקה ויכבול את כל הדורות " ( מעיתון הארץ ) . שנית בהיסטוריה של מדינת ישראל הובהר כבר ב1948 שהיא אינה מחייבת " ב ־ 1948 בג"ץ הבהיר שאין לה תוקף של חוק , והיא איננה חוקה המגבילה את הפרלמנט " . ובנוסף " הגוף שחתם על מגילת העצמאות היה מועצת המדינה הזמנית – שראתה את עצמה כזמנית , וקבעה שמיד עם קיום הבחירות הראשונות תוקם האסיפה המכוננת , שהיא זו שתכונן חוקה ומכוחה יוקמו מוסדות שלטון " . לסיכום אני חושבת שיש להבהיר את מעמדה במשפט בישראל ואולי אפילו לכתוב אחת מחדש ." Topics Identified: ["בסיס לחוקים", "צורך בשינוי", "מעמד משפטי", "האנשים החתומים"] Turn: "תתעלמו מזה בבקשה." Topics Identified: [] Turn: "לפי דעתי , מגילת העצמאות היא בסיס לחוקים מסויימים אבל אנחנו גם צריכים חוקי יסוד . ההתבוססות על מגית העצמאות היא רופפת למדי וצריכה להשתנות לפי דעתי , היא צריכה לתפוס מקום יותר היסטורי ופחות משפטי ." Topics Identified: ["בסיס לחוקים", "מעמד משפטי", "חוקי יסוד", "מקום היסטורי"] """
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.