Skip to content
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

0.29.0 #167

Draft
wants to merge 54 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
85030d0
set 0.29.0
vegu-ai-tools Nov 24, 2024
785ec8c
tweaks for dig layered history (wip)
vegu-ai-tools Nov 25, 2024
08b7979
move director agent to directory
vegu-ai-tools Nov 25, 2024
7d8d12d
relock
vegu-ai-tools Nov 25, 2024
2a38782
remove "none" from dig_layered_history response
vegu-ai-tools Nov 25, 2024
0fa34a5
determine character development
vegu-ai-tools Nov 25, 2024
2ecb257
update character sheet from character development (wip)
vegu-ai-tools Nov 27, 2024
bfe011b
org imports
vegu-ai-tools Nov 27, 2024
ea2e360
alert outdated template overrides during startup
vegu-ai-tools Nov 27, 2024
60e240d
editor controls normalization of exposition
vegu-ai-tools Nov 27, 2024
d8689f2
dialogue formatting refactor
vegu-ai-tools Nov 27, 2024
e9fe685
fix narrator.clean_result forcing * regardless of editor fix expositi…
vegu-ai-tools Nov 27, 2024
c579f1a
move more of the dialogue cleanup logic into the editor fix expositio…
vegu-ai-tools Dec 1, 2024
facb58b
remove cruft
vegu-ai-tools Dec 1, 2024
810a11c
change ot normal selects and add some margin
vegu-ai-tools Dec 1, 2024
fa07c47
move formatting option up
vegu-ai-tools Dec 1, 2024
71a06c6
always strip partial sentences
vegu-ai-tools Dec 2, 2024
b499d81
separates exposition fixes from other dialogue cleanup operations, si…
vegu-ai-tools Dec 2, 2024
9109967
add novel formatting style
vegu-ai-tools Dec 3, 2024
80ae0a4
honor formatting config when no markers are supplied
vegu-ai-tools Dec 3, 2024
4aa3a65
fix issue where sometimes character message formatting would miss cha…
vegu-ai-tools Dec 13, 2024
1b63a2b
director can now guide actors through scene analysis
vegu-ai-tools Dec 15, 2024
4824202
style fixes
vegu-ai-tools Dec 15, 2024
82da143
typo
vegu-ai-tools Dec 15, 2024
b4bedd4
select correct system message on direction type
vegu-ai-tools Dec 15, 2024
5d7e479
prompt tweaks
vegu-ai-tools Dec 15, 2024
d69c6e9
disable by default
vegu-ai-tools Dec 15, 2024
f7c326f
add support for dynamic instruction injection and include missing gui…
vegu-ai-tools Dec 15, 2024
7e923d3
change favicon and also indicate business through favicon
vegu-ai-tools Dec 19, 2024
4118097
img
vegu-ai-tools Dec 19, 2024
2600432
support xtc, dry and smoothing in text gen webui
vegu-ai-tools Dec 19, 2024
3a410e0
prompt tweaks
vegu-ai-tools Dec 19, 2024
b2400bb
support xtc, dry, smoothing in koboldcpp client
vegu-ai-tools Dec 19, 2024
e42ec81
reorder
vegu-ai-tools Dec 19, 2024
049d33e
dry, xtc and smoothing factor exposed to tabby api client
vegu-ai-tools Dec 22, 2024
8d86178
urls to third party API documentation
vegu-ai-tools Dec 22, 2024
b331adc
remove bos token
vegu-ai-tools Dec 22, 2024
a47c4e0
add missing preset
vegu-ai-tools Dec 22, 2024
f1250fc
focal
vegu-ai-tools Dec 23, 2024
31c2134
focal progress
vegu-ai-tools Dec 26, 2024
51b103f
focal progress and generated suggestions progress
vegu-ai-tools Dec 27, 2024
e4348c4
fix issue with discard all suggestions
vegu-ai-tools Dec 27, 2024
5cf3712
apply suggestions
vegu-ai-tools Dec 28, 2024
5e9ea8d
move suggestion ux into the world state manager
vegu-ai-tools Dec 28, 2024
eeb3bf9
support generation options for suggestion generation
vegu-ai-tools Dec 28, 2024
9c206ae
unused import
vegu-ai-tools Dec 28, 2024
bf1f470
refactor focal to json based approach
vegu-ai-tools Dec 30, 2024
24c7783
focal and character suggestion tweaks
vegu-ai-tools Dec 30, 2024
b839aa1
rmeove cruft
vegu-ai-tools Dec 30, 2024
5b82de4
remove cruft
vegu-ai-tools Dec 30, 2024
2843f85
relock
vegu-ai-tools Dec 31, 2024
4c12f46
prompt tweaks
vegu-ai-tools Dec 31, 2024
d5406f1
layout spacing updates
vegu-ai-tools Dec 31, 2024
af1cef3
ux elements for removal of scenes from quick load menu
vegu-ai-tools Dec 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions docs/dev/third-party-reference.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## Third Party API docs

### Chat completions

- Anthropic: https://docs.anthropic.com/en/api/messages
- Cohere: https://docs.cohere.com/reference/chat
- Google: https://ai.google.dev/api/generate-content#v1beta.GenerationConfig
- Groq: https://console.groq.com/docs/api-reference#chat-create
- KoboldCpp: https://lite.koboldai.net/koboldcpp_api#/api/v1
- LMStudio: https://lmstudio.ai/docs/api/rest-api
- MistralAI: https://docs.mistral.ai/api/
- OpenAI: https://platform.openai.com/docs/api-reference/completions
- TabbyAPI: https://theroyallab.github.io/tabbyAPI/#operation/chat_completion_request_v1_chat_completions_post
- Text-Generation-WebUI: https://github.com/oobabooga/text-generation-webui/blob/main/extensions/openai/typing.py
2,574 changes: 1,265 additions & 1,309 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.masonry.api"

[tool.poetry]
name = "talemate"
version = "0.27.0"
version = "0.29.0"
description = "AI-backed roleplay and narrative tools"
authors = ["FinalWombat"]
license = "GNU Affero General Public License v3.0"
Expand Down
6 changes: 3 additions & 3 deletions scenes/infinity-quest/infinity-quest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"description": "Captain Elmer Farstield and his trusty first officer, Kaira, embark upon a daring mission into uncharted space. Their small but mighty exploration vessel, the Starlight Nomad, is equipped with state-of-the-art technology and crewed by an elite team of scientists, engineers, and pilots. Together they brave the vast cosmos seeking answers to humanity's most pressing questions about life beyond our solar system.",
"intro": "*You awaken aboard your ship, the Starlight Nomad, surrounded by darkness. A soft hum resonates throughout the vessel indicating its systems are online. Your mind struggles to recall what brought you here - where 'here' actually is. You remember nothing more than flashes of images; swirling nebulae, foreign constellations, alien life forms... Then there was a bright light followed by this endless void.*\n\n*Gingerly, you make your way through the dimly lit corridors of the ship. It seems smaller than you expected given the magnitude of the mission ahead. However, each room reveals intricate technology designed specifically for long-term space travel and exploration. There appears to be no other living soul besides yourself. An eerie silence fills every corner.*",
"intro": "You awaken aboard your ship, the Starlight Nomad, surrounded by darkness. A soft hum resonates throughout the vessel indicating its systems are online. Your mind struggles to recall what brought you here - where 'here' actually is. You remember nothing more than flashes of images; swirling nebulae, foreign constellations, alien life forms... Then there was a bright light followed by this endless void.\n\nGingerly, you make your way through the dimly lit corridors of the ship. It seems smaller than you expected given the magnitude of the mission ahead. However, each room reveals intricate technology designed specifically for long-term space travel and exploration. There appears to be no other living soul besides yourself. An eerie silence fills every corner.",
"name": "Infinity Quest",
"history": [],
"environment": "scene",
Expand Down Expand Up @@ -90,9 +90,9 @@
"gender": "female",
"color": "red",
"example_dialogue": [
"Kaira: Yes Captain, I believe that is the best course of action *She nods slightly, as if to punctuate her approval of the decision*",
"Kaira: \"Yes Captain, I believe that is the best course of action\" She nods slightly, as if to punctuate her approval of the decision*",
"Kaira: \"This device appears to have multiple functions, Captain. Allow me to analyze its capabilities and determine if it could be useful in our exploration efforts.\"",
"Kaira: \"Captain, it appears that this newly discovered planet harbors an ancient civilization whose technological advancements rival those found back home on Altrusia!\" *Excitement bubbles beneath her calm exterior as she shares the news*",
"Kaira: \"Captain, it appears that this newly discovered planet harbors an ancient civilization whose technological advancements rival those found back home on Altrusia!\" Excitement bubbles beneath her calm exterior as she shares the news",
"Kaira: \"Captain, I understand why you would want us to pursue this course of action based on our current data, but I cannot shake the feeling that there might be unforeseen consequences if we proceed without further investigation into potential hazards.\"",
"Kaira: \"I often find myself wondering what it would have been like if I had never left my home world... But then again, perhaps it was fate that led me here, onto this ship bound for destinations unknown...\""
],
Expand Down
2 changes: 1 addition & 1 deletion scenes/simulation-suite/simulation-suite.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"experimental": true,
"help": "Address the computer by starting your statements with 'Computer, ' followed by an instruction.\n\nExamples:\n'Computer, i would like to experience an adventure on a derelict space station'\n'Computer, add a horrific alien creature that is chasing me.'",
"description": "",
"intro": "*You have entered the simulation suite. No simulation is currently active and you are in a non-descript space with paneled walls surrounding you. The control panel next to you is pulsating with a green light, indicating readiness to receive a prompt to start the simulation.*",
"intro": "You have entered the simulation suite. No simulation is currently active and you are in a non-descript space with paneled walls surrounding you. The control panel next to you is pulsating with a green light, indicating readiness to receive a prompt to start the simulation.",
"archived_history": [],
"history": [],
"ts": "PT1S",
Expand Down
27 changes: 22 additions & 5 deletions src/talemate/agents/conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,13 @@ class ConversationAgentEmission(AgentEmission):
actor: Actor
character: Character
generation: list[str]
dynamic_instructions: list[str] = None


talemate.emit.async_signals.register(
"agent.conversation.before_generate", "agent.conversation.generated"
"agent.conversation.before_generate",
"agent.conversation.inject_instructions",
"agent.conversation.generated"
)


Expand Down Expand Up @@ -535,6 +538,21 @@ async def build_prompt_default(

if self.investigate_context:
await self.run_context_investigation(character)

dynamic_instructions = []

await talemate.emit.async_signals.get(
"agent.conversation.inject_instructions"
).send(ConversationAgentEmission(
agent=self,
generation="",
actor=None,
character=character,
dynamic_instructions=dynamic_instructions
))

log.debug("Dynamic instructions", dynamic_instructions=dynamic_instructions)


conversation_format = self.conversation_format
prompt = Prompt.get(
Expand All @@ -557,6 +575,7 @@ async def build_prompt_default(
"actor_instructions_offset": self.generation_settings_actor_instructions_offset,
"direct_instruction": instruction,
"decensor": self.client.decensor_enabled,
"dynamic_instructions": dynamic_instructions,
},
)

Expand Down Expand Up @@ -671,11 +690,9 @@ def clean_result(self, result, character):
result = result.split("(Internal")[0]

result = result.replace(" :", ":")
result = result.replace("[", "*").replace("]", "*")
result = result.replace("(", "*").replace(")", "*")
result = result.replace("**", "*")

result = util.handle_endofline_special_delimiter(result)
result = util.remove_trailing_markers(result)

return result

Expand Down Expand Up @@ -782,7 +799,7 @@ async def converse(self, actor, only_generate:bool = False, instruction:str = No
total_result = util.clean_dialogue(total_result, main_name=character.name)

# Check if total_result starts with character name, if not, prepend it
if not total_result.startswith(character.name):
if not total_result.startswith(character.name+":"):
total_result = f"{character.name}: {total_result}"

total_result = total_result.strip()
Expand Down
59 changes: 56 additions & 3 deletions src/talemate/agents/creator/assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ class ContentGenerationContext(pydantic.BaseModel):
A context for generating content.
"""

# character attribute:Attribute name
# character detail:Detail name
# character dialogue:
# scene intro:
context: str
instructions: str = ""
length: int = 100
Expand Down Expand Up @@ -175,6 +179,7 @@ async def contextual_generate(
"""

context_typ, context_name = generation_context.computed_context
editor = get_agent("editor")

if generation_context.length < 100:
kind = "create_short"
Expand Down Expand Up @@ -224,13 +229,61 @@ async def contextual_generate(
if not content.startswith(generation_context.character + ":"):
content = generation_context.character + ": " + content
content = util.strip_partial_sentences(content)
content = util.ensure_dialog_format(
content, talking_character=generation_context.character
)
content = await editor.cleanup_character_message(content, generation_context.character.name)
return content

return content.strip().strip("*").strip()

@set_processing
async def generate_character_attribute(
self,
character: "Character",
attribute_name: str,
instructions: str = "",
original: str | None = None,
generation_options: GenerationOptions = None,
) -> str:
"""
Wrapper for contextual_generate that generates a character attribute.
"""

if not generation_options:
generation_options = GenerationOptions()

return await self.contextual_generate_from_args(
context=f"character attribute:{attribute_name}",
character=character.name,
instructions=instructions,
original=original,
**generation_options.model_dump(),
)

@set_processing
async def generate_character_detail(
self,
character: "Character",
detail_name: str,
instructions: str = "",
original: str | None = None,
length: int = 512,
generation_options: GenerationOptions = None,
) -> str:
"""
Wrapper for contextual_generate that generates a character detail.
"""

if not generation_options:
generation_options = GenerationOptions()

return await self.contextual_generate_from_args(
context=f"character detail:{detail_name}",
character=character.name,
instructions=instructions,
original=original,
length=length,
**generation_options.model_dump(),
)

@set_processing
async def autocomplete_dialogue(
self,
Expand Down
4 changes: 3 additions & 1 deletion src/talemate/agents/creator/character.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from talemate.agents.base import set_processing
from talemate.prompts import Prompt

import talemate.game.focal as focal

if TYPE_CHECKING:
from talemate.tale_mate import Character

Expand Down Expand Up @@ -127,4 +129,4 @@ async def determine_character_goals(
log.debug("determine_character_goals", goals=goals, character=character)
await character.set_detail("goals", goals.strip())

return goals.strip()
return goals.strip()
Original file line number Diff line number Diff line change
@@ -1,35 +1,33 @@
from __future__ import annotations

import asyncio
import random
import re
from typing import TYPE_CHECKING, Callable, List, Optional, Union
from typing import TYPE_CHECKING, List

import structlog

import talemate.automated_action as automated_action
import talemate.emit.async_signals
import talemate.instance as instance
import talemate.util as util
from talemate.agents.conversation import ConversationAgentEmission
from talemate.automated_action import AutomatedAction
from talemate.emit import emit, wait_for_input
from talemate.emit import emit
from talemate.events import GameLoopActorIterEvent, GameLoopStartEvent, SceneStateEvent
from talemate.game.engine import GameInstructionsMixin
from talemate.prompts import Prompt
from talemate.scene_message import DirectorMessage, NarratorMessage, CharacterMessage

from .base import Agent, AgentAction, AgentActionConfig, set_processing
from .registry import register
from talemate.agents.base import Agent, AgentAction, AgentActionConfig, set_processing
from talemate.agents.registry import register

from talemate.agents.director.analyze import SceneAnalyzationMixin

if TYPE_CHECKING:
from talemate import Actor, Character, Player, Scene
from talemate import Character

log = structlog.get_logger("talemate.agent.director")


@register()
class DirectorAgent(GameInstructionsMixin, Agent):
class DirectorAgent(SceneAnalyzationMixin, GameInstructionsMixin, Agent):
agent_type = "director"
verbose_name = "Director"

Expand Down Expand Up @@ -129,6 +127,8 @@ def __init__(self, client, **kwargs):
),

}

SceneAnalyzationMixin.add_actions(self)

@property
def enabled(self):
Expand Down
Loading