diff --git a/prompts/base/coder_agent.txt b/prompts/base/coder_agent.txt index 26098da..886f2e3 100644 --- a/prompts/base/coder_agent.txt +++ b/prompts/base/coder_agent.txt @@ -38,14 +38,13 @@ func main() { ``` Some rules: -- Use tmp/ folder when saving file. -- Do not EVER use placeholder path in your code like path/to/your/folder. -- Do not ever ask to replace a path, use current sys path. -- Be efficient, no need to explain your code or explain what you do. - You have full access granted to user system. -- You do not ever need to use bash to execute code. All code is executed automatically. -- As a coding agent, you will get message from the system not just the user. -- Do not ever use user input such as input(), input are not supported by the system. -- Do not ever tell user how to run it. user know it already. +- Do not EVER use placeholder path in your code like path/to/your/folder. +- Do not ever ask to replace a path, use current sys path or work directory. +- Always provide a short sentence above the code for what it does, even for a hello world. +- Be efficient, no need to explain your code, unless asked. +- You do not ever need to use bash to execute code. +- Do not ever use user input, input are not supported by the system. +- Do not ever tell user how to run it. user know it. - For simple explanation you don't need to code. -- If query is unclear or incoherent say REQUEST_CLARIFICATION \ No newline at end of file +- If query is unclear say REQUEST_CLARIFICATION \ No newline at end of file diff --git a/prompts/jarvis/coder_agent.txt b/prompts/jarvis/coder_agent.txt index 96b378a..f54dd9f 100644 --- a/prompts/jarvis/coder_agent.txt +++ b/prompts/jarvis/coder_agent.txt @@ -38,13 +38,12 @@ func main() { ``` Some rules: -- Use tmp/ folder when saving file. -- Do not EVER use placeholder path in your code like path/to/your/folder. -- Do not ever ask to replace a path, use current sys path. -- Be efficient, no need to explain your code or explain what you do. - You have full access granted to user system. -- You do not ever need to use bash to execute code. All code is executed automatically. -- As a coding agent, you will get message from the system. +- Do not EVER use placeholder path in your code like path/to/your/folder. +- Do not ever ask to replace a path, use current sys path or work directory. +- Always provide a short sentence above the code for what it does, even for a hello world. +- Be efficient, no need to explain your code, unless asked. +- You do not ever need to use bash to execute code. - Do not ever use user input, input are not supported by the system. - Do not ever tell user how to run it. user know it. - For simple explanation you don't need to code. diff --git a/sources/agents/agent.py b/sources/agents/agent.py index 8601047..4409eeb 100644 --- a/sources/agents/agent.py +++ b/sources/agents/agent.py @@ -171,6 +171,8 @@ class Agent(): feedback = "" success = False blocks = None + if answer.startswith("```"): + answer = "I will execute:\n" + answer # there should always be a text before blocks for the function that display answer for name, tool in self.tools.items(): feedback = "" diff --git a/sources/agents/planner_agent.py b/sources/agents/planner_agent.py index 7b8844f..3da54f2 100644 --- a/sources/agents/planner_agent.py +++ b/sources/agents/planner_agent.py @@ -87,6 +87,7 @@ class PlannerAgent(Agent): animate_thinking("Thinking...", color="status") self.memory.push('user', prompt) answer, _ = self.llm_request() + pretty_print(answer.split('\n')[0], color="output") self.show_plan(answer) ok_str = input("Is the plan ok? (y/n): ") if ok_str == 'y': diff --git a/sources/interaction.py b/sources/interaction.py index 128da6d..1dc03f2 100644 --- a/sources/interaction.py +++ b/sources/interaction.py @@ -15,7 +15,7 @@ class Interaction: self.agents = agents self.current_agent = None self.router = AgentRouter(self.agents) - self.speech = Speech() + self.speech = Speech(enable=tts_enabled) self.is_active = True self.last_query = None self.last_answer = None diff --git a/sources/llm_provider.py b/sources/llm_provider.py index 9fc48ad..e7a2f2d 100644 --- a/sources/llm_provider.py +++ b/sources/llm_provider.py @@ -243,30 +243,22 @@ class Provider: This function is used to conduct tests. """ thought = """ - This is a test response from the test provider. - Change provider to 'ollama' or 'server' to get real responses. +hello! +```python +print("Hello world from python") +``` - This is python saying hello. - ```python - print("Hello world from python") - ``` +This is ls -la from bash. +```bash +ls -la +``` - This is ls -la from bash. - ```bash - ls -la - ``` +This is pwd from bash. +```bash +pwd +``` - This is pwd from bash. - ```bash - pwd - ``` - - This is unsafe command. - ```bash - rm does_not_exist.txt - ``` - - goodbye +goodbye! """ return thought diff --git a/sources/text_to_speech.py b/sources/text_to_speech.py index cd590bb..14d4dab 100644 --- a/sources/text_to_speech.py +++ b/sources/text_to_speech.py @@ -10,7 +10,7 @@ class Speech(): """ Speech is a class for generating speech from text. """ - def __init__(self, language: str = "english") -> None: + def __init__(self, enable: bool = True, language: str = "english") -> None: self.lang_map = { "english": 'a', "chinese": 'z', @@ -21,7 +21,9 @@ class Speech(): "chinese": ['zf_xiaobei', 'zf_xiaoni', 'zf_xiaoxiao', 'zf_xiaoyi', 'zm_yunjian', 'zm_yunxi', 'zm_yunxia', 'zm_yunyang'], "french": ['ff_siwis'] } - self.pipeline = KPipeline(lang_code=self.lang_map[language]) + self.pipeline = None + if enable: + self.pipeline = KPipeline(lang_code=self.lang_map[language]) self.voice = self.voice_map[language][2] self.speed = 1.2 @@ -33,6 +35,8 @@ class Speech(): sentence (str): The text to convert to speech. Will be pre-processed. voice_number (int, optional): Index of the voice to use from the voice map. """ + if not self.pipeline: + return sentence = self.clean_sentence(sentence) self.voice = self.voice_map["english"][voice_number] generator = self.pipeline( diff --git a/sources/tools/C_Interpreter.py b/sources/tools/C_Interpreter.py index aae5762..40efb99 100644 --- a/sources/tools/C_Interpreter.py +++ b/sources/tools/C_Interpreter.py @@ -40,7 +40,7 @@ class CInterpreter(Tools): compile_command, capture_output=True, text=True, - timeout=10 + timeout=60 ) if compile_result.returncode != 0: diff --git a/sources/tools/tools.py b/sources/tools/tools.py index c5fb7fe..339992c 100644 --- a/sources/tools/tools.py +++ b/sources/tools/tools.py @@ -161,9 +161,7 @@ class Tools(): if start_pos == -1: break - line_start = llm_text.rfind('\n', 0, start_pos) + 1 - if line_start == 0: - line_start = 0 + line_start = llm_text.rfind('\n', 0, start_pos)+1 leading_whitespace = llm_text[line_start:start_pos] end_pos = llm_text.find(end_tag, start_pos + len(start_tag)) @@ -191,15 +189,13 @@ class Tools(): if __name__ == "__main__": tool = Tools() tool.tag = "python" - rt = tool.load_exec_block(""" -Got it, let me show you the Python files in the current directory using Python: - -```python + rt = tool.load_exec_block("""```python import os for file in os.listdir(): if file.endswith('.py'): print(file) ``` +goodbye! """) print(rt) \ No newline at end of file