forked from irmen/Tale
-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
114 additions
and
33 deletions.
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 |
---|---|---|
@@ -1,8 +1,7 @@ | ||
URL: "http://localhost:5001" | ||
ENDPOINT: "/api/v1/generate" | ||
STREAM: False | ||
STREAM: True | ||
STREAM_ENDPOINT: "/api/extra/generate/stream" | ||
DATA_ENDPOINT: "/api/extra/generate/check" | ||
DEFAULT_BODY: '{"stop_sequence": "\n\n\n\n", "max_length":750, "max_context_length":4096, "temperature":0.5, "top_k":120, "top_a":0.0, "top_p":0.85, "typical_p":1.0, "tfs":1.0, "rep_pen":1.2, "rep_pen_range":256, "sampler_order":[6,0,1,3,4,2,5], "seed":-1}' | ||
ANALYSIS_BODY: '{}' | ||
GENERATION_BODY: '{"stop_sequence": "\n\n\n\n", "max_length":750, "max_context_length":4096, "temperature":1.0, "top_k":120, "top_a":0.0, "top_p":0.85, "typical_p":1.0, "tfs":1.0, "rep_pen":1.2, "rep_pen_range":256, "sampler_order":[6,0,1,3,4,2,5], "seed":-1}' |
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
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
|
||
import json | ||
from tale.base import Location | ||
from tale.llm.contexts.BaseContext import BaseContext | ||
|
||
|
||
class ActionContext(BaseContext): | ||
|
||
def __init__(self, story_context: str, story_type: str, character_name: str, character_card: str, event_history: str, location: Location): | ||
super().__init__(story_context) | ||
self.story_type = story_type | ||
self.character_name = character_name | ||
self.character_card = character_card | ||
self.event_history = event_history | ||
self.location = location | ||
|
||
|
||
def to_prompt_string(self) -> str: | ||
actions = ', '.join(['move, say, attack, wear, remove, wield, take, eat, drink, emote']) | ||
characters = {} | ||
for living in self.location.livings: | ||
if living.visible and living.name != self.character_name.lower(): | ||
if living.alive: | ||
characters[living.name] = living.short_description | ||
else: | ||
characters[living.name] = f"{living.short_description} (dead)" | ||
exits = self.location.exits.keys() | ||
items = [item.name for item in self.location.items if item.visible] | ||
return f"Story context:{self.story_context}; Story type:{self.story_type}; Available actions: {actions}; Location:{self.location.name}, {self.location.description}; Available exits: {exits}; Self: {self.character_card}; Present items: {items}; Present characters: {json.dumps(characters)}; History:{self.event_history};" |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
|
||
class BaseContext(): | ||
|
||
def __init__(self, story_context: str) -> None: | ||
self.story_context = story_context | ||
|
||
def to_prompt_string(self) -> str: | ||
pass |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
|
||
|
||
from tale.llm.contexts.BaseContext import BaseContext | ||
|
||
|
||
class DialogueContext(BaseContext): | ||
|
||
def __init__(self, | ||
story_context: str, | ||
location_description: str, | ||
speaker_card: str, | ||
speaker_name: str, | ||
target_name: str, | ||
target_description: str): | ||
super().__init__(story_context) | ||
self.location_description = location_description | ||
self.speaker_card = speaker_card | ||
self.speaker_name = speaker_name | ||
self.target_name = target_name | ||
self.target_description = target_description | ||
|
||
|
||
def to_prompt_string(self) -> str: | ||
return f"Story context:{self.story_context}; Location:{self.location_description}; Self:{self.speaker_name}:{self.speaker_card}; Listener:{self.target_name}:{self.target_description};" |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from tale.llm.contexts.BaseContext import BaseContext | ||
|
||
class EvokeContext(BaseContext): | ||
|
||
def __init__(self, story_context: str, history: str) -> None: | ||
super().__init__(story_context) | ||
self.history = history | ||
|
||
def to_prompt_string(self) -> str: | ||
return f"Story context:{self.story_context}; History:{self.history};" |
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
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