-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug fixes #21
Merged
Merged
bug fixes #21
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -213,9 +213,13 @@ async def update( | |||||||||||||||||||||||||||
Interaction strength: {interaction_strength} | ||||||||||||||||||||||||||||
Distance between states: {distance} | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
Based on this interaction, describe the new positive, neutral, or negative emotional state in 1 sentence: | ||||||||||||||||||||||||||||
Based on this interaction, your response should be a single word that captures the emotional response to the interaction.: | ||||||||||||||||||||||||||||
""" | ||||||||||||||||||||||||||||
new_description = await llm.generate(prompt) | ||||||||||||||||||||||||||||
new_description = new_description.strip() | ||||||||||||||||||||||||||||
# strip parentheses | ||||||||||||||||||||||||||||
new_description = re.sub(r"\([^)]*\)", "", new_description) | ||||||||||||||||||||||||||||
new_description = new_description.lower() | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
# Generate a new embedding for the updated emotional state | ||||||||||||||||||||||||||||
new_embedding = await llm.generate_embedding(new_description) | ||||||||||||||||||||||||||||
|
@@ -261,6 +265,7 @@ def __init__( | |||||||||||||||||||||||||||
self._field = None | ||||||||||||||||||||||||||||
if field: | ||||||||||||||||||||||||||||
self.set_field(field) | ||||||||||||||||||||||||||||
self.theme_influences = {} # Add this line to track theme influences | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
def set_field(self, field: "NarrativeField"): | ||||||||||||||||||||||||||||
self._field = field | ||||||||||||||||||||||||||||
|
@@ -366,6 +371,9 @@ def add_memory(self, memory: Memory): | |||||||||||||||||||||||||||
self.memory_layer.append(memory) | ||||||||||||||||||||||||||||
self.memory_state.update(memory) | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
def update_theme_influence(self, theme: str, influence: float): | ||||||||||||||||||||||||||||
self.theme_influences[theme] = self.theme_influences.get(theme, 0) + influence | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
class NarrativeFieldViz(BaseClass): | ||||||||||||||||||||||||||||
"""Handles visualization of field state""" | ||||||||||||||||||||||||||||
|
@@ -796,6 +804,12 @@ async def process_interaction(self, story1: Story, story2: Story): | |||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||
story1.add_memory(memory) | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
# Update theme influences | ||||||||||||||||||||||||||||
shared_themes = set(story1.themes) & set(story2.themes) | ||||||||||||||||||||||||||||
for theme in shared_themes: | ||||||||||||||||||||||||||||
story1.update_theme_influence(theme, resonance * 0.1) | ||||||||||||||||||||||||||||
story2.update_theme_influence(theme, resonance * 0.1) | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
return resonance, interaction_type | ||||||||||||||||||||||||||||
return 0, None | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
|
@@ -915,9 +929,10 @@ def summarize_journey(self, story: Story): | |||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
# Safely get unique interactions | ||||||||||||||||||||||||||||
unique_interactions = { | ||||||||||||||||||||||||||||
m["partner_id"] for m in story.memory_layer if "partner_id" in m | ||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||
unique_interactions = set() | ||||||||||||||||||||||||||||
for memory in story.memory_layer: | ||||||||||||||||||||||||||||
if hasattr(memory, 'partner_id') and memory.partner_id is not None: | ||||||||||||||||||||||||||||
unique_interactions.add(memory.partner_id) | ||||||||||||||||||||||||||||
Comment on lines
931
to
+935
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (code-quality): Convert for loop into set comprehension (
Suggested change
|
||||||||||||||||||||||||||||
num_unique_interactions = len(unique_interactions) | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
# Emotional journey analysis | ||||||||||||||||||||||||||||
|
@@ -959,17 +974,13 @@ def get_journey_analytics(self, story: Story): | |||||||||||||||||||||||||||
theme_counts[theme] = theme_counts.get(theme, 0) + 1 | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
most_influential_themes = sorted( | ||||||||||||||||||||||||||||
story.perspective.theme_influences.items(), key=lambda x: x[1], reverse=True | ||||||||||||||||||||||||||||
story.theme_influences.items(), key=lambda x: x[1], reverse=True | ||||||||||||||||||||||||||||
)[:3] | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
return { | ||||||||||||||||||||||||||||
"total_memories": len(story.memory_layer), | ||||||||||||||||||||||||||||
"unique_interactions": len( | ||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||
m.partner_id | ||||||||||||||||||||||||||||
for m in story.memory_layer | ||||||||||||||||||||||||||||
if m.partner_id is not None | ||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||
{m.partner_id for m in story.memory_layer if m.partner_id is not None} | ||||||||||||||||||||||||||||
), | ||||||||||||||||||||||||||||
"theme_exposure": theme_counts, | ||||||||||||||||||||||||||||
"total_perspective_shift": story.total_perspective_shift, | ||||||||||||||||||||||||||||
|
@@ -1141,15 +1152,15 @@ async def simulate_field(): | |||||||||||||||||||||||||||
interaction_engine = EnhancedInteractionEngine(field, llm) | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
# Generate initial stories | ||||||||||||||||||||||||||||
for _ in range(9): | ||||||||||||||||||||||||||||
for _ in range(15): | ||||||||||||||||||||||||||||
story = await story_generator.generate_story(field) | ||||||||||||||||||||||||||||
field.add_story(story) | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
# Add journey logger | ||||||||||||||||||||||||||||
journey_logger = EnhancedJourneyLogger() | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
# Simulation loop | ||||||||||||||||||||||||||||
for t in range(100): | ||||||||||||||||||||||||||||
for t in range(10): | ||||||||||||||||||||||||||||
field.time = t | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
# Update physics | ||||||||||||||||||||||||||||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (complexity): Consider consolidating theme influence tracking into a single location within the Story class
The theme influence tracking is unnecessarily split between Story.theme_influences and the perspective object, creating confusing duplication. Consolidate this into the Story class since it's the natural owner of theme-related state.
This removes the duplicate state while preserving all functionality.