Skip to content

Commit

Permalink
Merge pull request #106 from fractalego/new-version
Browse files Browse the repository at this point in the history
modified runners
  • Loading branch information
fractalego authored Jul 20, 2024
2 parents e9d5709 + 115a2e2 commit cbdd0d1
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 24 deletions.
7 changes: 3 additions & 4 deletions wafl/interface/command_line_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ async def output(self, text: str, silent: bool = False):
print(text)
return

utterance = from_bot_to_user(text)
print(COLOR_START + "bot> " + utterance + COLOR_END)
self._utterances.append((time.time(), f"bot: {text}"))
print(COLOR_START + "bot> " + text + COLOR_END)
self._insert_utterance(speaker="bot", text=text)
self.bot_has_spoken(True)

async def input(self) -> str:
Expand All @@ -29,7 +28,7 @@ async def input(self) -> str:
await self.output("I did not quite understand that")
text = input("user> ")

self._utterances.append((time.time(), f"user: {text}"))
self._insert_utterance(speaker="user", text=text)
return text

def bot_has_spoken(self, to_set: bool = None):
Expand Down
4 changes: 3 additions & 1 deletion wafl/runners/run_from_audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ def run_from_audio():
interface,
conversation_events,
_logger,
activation_word=config.get_value("waking_up_word"),
activation_word="",
max_misses=-1,
deactivate_on_closed_conversation=False,
)
scheduler = Scheduler([conversation_loop])
scheduler.run()
Expand Down
8 changes: 4 additions & 4 deletions wafl/runners/run_web_and_audio_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@


@app.route("/create_new_instance", methods=["POST"])
def create_new_instance():
def create_new_web_and_audio_instance():
conversation_id = random.randint(0, sys.maxsize)
result = create_scheduler_and_webserver_loop(conversation_id)
result = create_web_and_audio_scheduler_and_webserver_loop(conversation_id)
add_new_routes(conversation_id, result["web_server_handler"])
thread = threading.Thread(target=result["scheduler"].run)
thread.start()
return redirect(f"{conversation_id}/index")


@app.route("/")
async def index():
async def index_web_and_audio_():
return render_template("selector.html")


def create_scheduler_and_webserver_loop(conversation_id):
def create_web_and_audio_scheduler_and_webserver_loop(conversation_id):
config = Configuration.load_local_config()
interface = ListInterface([VoiceInterface(config), QueueInterface()])
interface.activate()
Expand Down
30 changes: 15 additions & 15 deletions wafl/runners/run_web_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,21 @@
_logger = LocalFileLogger()


@app.route("/create_new_instance", methods=["POST"])
def create_new_web_instance():
conversation_id = str(random.randint(0, sys.maxsize))
result = create_scheduler_and_webserver_loop(conversation_id)
add_new_routes(conversation_id, result["web_server_handler"])
thread = threading.Thread(target=result["scheduler"].run)
thread.start()
return redirect(f"{conversation_id}/index")


@app.route("/")
async def index_web():
return render_template("selector.html")


def create_scheduler_and_webserver_loop(conversation_id):
config = Configuration.load_local_config()
interface = QueueInterface()
Expand Down Expand Up @@ -46,21 +61,6 @@ def create_scheduler_and_webserver_loop(conversation_id):
}


@app.route("/create_new_instance", methods=["POST"])
def create_new_instance():
conversation_id = str(random.randint(0, sys.maxsize))
result = create_scheduler_and_webserver_loop(conversation_id)
add_new_routes(conversation_id, result["web_server_handler"])
thread = threading.Thread(target=result["scheduler"].run)
thread.start()
return redirect(f"{conversation_id}/index")


@app.route("/")
async def index():
return render_template("selector.html")


def run_server_only_app():
app.run(
host="0.0.0.0",
Expand Down

0 comments on commit cbdd0d1

Please sign in to comment.