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.
Merge pull request #80 from neph1/update-v0.29.0
Update v0.29.0
- Loading branch information
Showing
12 changed files
with
196 additions
and
2 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
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
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
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,17 @@ | ||
|
||
|
||
from tale.base import Location | ||
from tale.llm.contexts.ActionContext import ActionContext | ||
from tale.llm.contexts.BaseContext import BaseContext | ||
|
||
|
||
class FollowContext(ActionContext): | ||
|
||
def __init__(self, story_context: str, story_type: str, character_name: str, character_card: str, event_history: str, location: Location, asker_name: str, asker_card: str, asker_reason: str): | ||
super().__init__(story_context, story_type, character_name, character_card, event_history, location, []) | ||
self.asker_name = asker_name | ||
self.asker_card = asker_card | ||
self.asker_reason = asker_reason # Added last in actual prompt | ||
|
||
def to_prompt_string(self) -> str: | ||
return f"Story context:{self.story_context}; Story type:{self.story_type}; Location:{self.location.name}, {self.location.description}; Self({self.character_name}): {self.character_card}; Asker({self.asker_name}): {self.asker_card} ; 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
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,8 @@ | ||
|
||
|
||
class FollowResponse: | ||
|
||
def __init__(self, response: dict): | ||
yes_responses = ['yes', 'y', 'true', 'True'] | ||
self.follow = any(r in response.get('response', 'no').lower() for r in yes_responses) # type: bool | ||
self.reason = response.get('reason', '') # type: str |
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
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,20 @@ | ||
|
||
|
||
import json | ||
from tale.llm.responses.FollowResponse import FollowResponse | ||
|
||
|
||
class TestFollowResponse: | ||
|
||
def test_follow_response(self): | ||
response = '{"response":"yes", "reason":"because"}' | ||
follow_response = FollowResponse(json.loads(response)) | ||
assert follow_response.follow == True | ||
|
||
response = '{"response":"no", "reason":"because"}' | ||
follow_response = FollowResponse(json.loads(response)) | ||
assert follow_response.follow == False | ||
|
||
response = '{"response":"Yes, I will follow you.", "reason":"because"}' | ||
follow_response = FollowResponse(json.loads(response)) | ||
assert follow_response.follow == True |