mirror of
https://github.com/tcsenpai/agenticSeek.git
synced 2025-06-06 11:05:26 +00:00
Feat : interaction class
This commit is contained in:
parent
62cc76764e
commit
55ccb408fc
44
main.py
44
main.py
@ -1,54 +1,40 @@
|
|||||||
#!/usr/bin python3
|
#!/usr/bin python3
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
from colorama import Fore
|
|
||||||
import signal
|
import signal
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
from sources.text_to_speech import Speech
|
|
||||||
from sources.code_agent import CoderAgent
|
|
||||||
from sources.utility import pretty_print
|
|
||||||
from sources.llm_provider import Provider
|
from sources.llm_provider import Provider
|
||||||
|
from sources.interaction import Interaction
|
||||||
|
from sources.code_agent import CoderAgent
|
||||||
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description='Deepseek AI assistant')
|
parser = argparse.ArgumentParser(description='Deepseek AI assistant')
|
||||||
parser.add_argument('--speak', action='store_true',
|
parser.add_argument('--speak', action='store_true',
|
||||||
help='Make AI use text-to-speech')
|
help='Make AI use text-to-speech')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
def get_user_query() -> str:
|
def handleInterrupt(signum, frame):
|
||||||
buffer = ""
|
sys.exit(0)
|
||||||
|
|
||||||
while buffer == "" or buffer.isascii() == False:
|
def main():
|
||||||
buffer = input(f">>> ")
|
signal.signal(signal.SIGINT, handler=handleInterrupt)
|
||||||
if buffer == "exit":
|
|
||||||
return None
|
|
||||||
return buffer
|
|
||||||
|
|
||||||
def conversation_loop():
|
|
||||||
speech_module = Speech()
|
|
||||||
#local_provider = Provider("ollama", "deepseek-r1:14b", None)
|
#local_provider = Provider("ollama", "deepseek-r1:14b", None)
|
||||||
server_provider = Provider("server", "deepseek-r1:14b", "192.168.1.100:5000")
|
server_provider = Provider(provider_name="server",
|
||||||
|
model="deepseek-r1:14b",
|
||||||
|
server_address="192.168.1.100:5000")
|
||||||
|
|
||||||
agent = CoderAgent(model="deepseek-r1:14b",
|
agent = CoderAgent(model="deepseek-r1:14b",
|
||||||
name="Marcus the code agent",
|
name="Marcus the code agent",
|
||||||
prompt_path="prompts/coder_agent.txt",
|
prompt_path="prompts/coder_agent.txt",
|
||||||
provider=server_provider)
|
provider=server_provider)
|
||||||
|
|
||||||
while True:
|
interaction = Interaction([agent], tts_enabled=args.speak)
|
||||||
query = get_user_query()
|
while interaction.is_active:
|
||||||
if query is None:
|
interaction.get_user()
|
||||||
break
|
interaction.think()
|
||||||
answer, reasoning = agent.answer(query, speech_module)
|
interaction.show_answer()
|
||||||
pretty_print(answer, color="output")
|
|
||||||
if args.speak:
|
|
||||||
speech_module.speak(answer)
|
|
||||||
|
|
||||||
def handleInterrupt(signum, frame):
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
def main():
|
|
||||||
signal.signal(signal.SIGINT, handler=handleInterrupt)
|
|
||||||
conversation_loop()
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
44
sources/interaction.py
Normal file
44
sources/interaction.py
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
|
||||||
|
from sources.text_to_speech import Speech
|
||||||
|
from sources.utility import pretty_print
|
||||||
|
|
||||||
|
class Interaction:
|
||||||
|
def __init__(self, agents, tts_enabled: bool = False):
|
||||||
|
self.tts_enabled = tts_enabled
|
||||||
|
self.agents = agents
|
||||||
|
self.speech = Speech()
|
||||||
|
self.is_active = True
|
||||||
|
self.last_query = None
|
||||||
|
self.last_answer = None
|
||||||
|
|
||||||
|
def is_active(self):
|
||||||
|
return self.is_active
|
||||||
|
|
||||||
|
def read_stdin(self) -> str:
|
||||||
|
buffer = ""
|
||||||
|
|
||||||
|
while buffer == "" or buffer.isascii() == False:
|
||||||
|
try:
|
||||||
|
buffer = input(f">>> ")
|
||||||
|
except EOFError:
|
||||||
|
return None
|
||||||
|
if buffer == "exit":
|
||||||
|
return None
|
||||||
|
return buffer
|
||||||
|
|
||||||
|
def get_user(self):
|
||||||
|
query = self.read_stdin()
|
||||||
|
if query is None:
|
||||||
|
self.is_active = False
|
||||||
|
return
|
||||||
|
self.last_query = query
|
||||||
|
return query
|
||||||
|
|
||||||
|
def think(self):
|
||||||
|
self.last_answer, _ = self.agents[0].answer(self.last_query, self.speech)
|
||||||
|
|
||||||
|
def show_answer(self):
|
||||||
|
pretty_print(self.last_answer, color="output")
|
||||||
|
if self.tts_enabled:
|
||||||
|
self.speech.speak(self.last_answer)
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user