Skip to content

Commit

Permalink
Formatted Response
Browse files Browse the repository at this point in the history
  • Loading branch information
luciferlinx committed May 22, 2023
1 parent 2a12536 commit d004f71
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
6 changes: 3 additions & 3 deletions superagi/agent/agent_prompt_to_print_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ def add_list_items_to_string(self, title: str, items: List[str]) -> str:
return title + ":\n" + list_string + "\n"

def generate_prompt_string(self):
final_string = "\n\n"
final_string = "\n"
final_string += f"I am {self.agent_prompt.ai_name}. My role is {self.agent_prompt.ai_role}\n"
final_string += self.agent_prompt.base_prompt
final_string += "\n"
final_string += self.add_list_items_to_string("\033[94m\033[1m\nGOALS\033[0m\033[0m", self.agent_prompt.goals)
final_string += self.add_list_items_to_string("\033[94m\033[1m\nGoals\033[0m\033[0m", self.agent_prompt.goals)
# final_string += self.add_list_items_to_string("\033[96m\033[1m\nCONSTRAINTS\033[0m\033[0m", self.agent_prompt.constraints)
# commands string
final_string = self.add_tools_to_prompt(final_string)
Expand All @@ -61,7 +61,7 @@ def generate_prompt_string(self):
return final_string

def add_tools_to_prompt(self, final_string):
final_string += "\033[91m\033[1m\nTOOLS\033[0m\033[0m:\n"
final_string += "\033[91m\033[1m\nTools\033[0m\033[0m:\n"
for i, item in enumerate(self.agent_prompt.tools):
final_string += f"{i + 1}. {self._generate_command_string(item)}\n"
# finish_description = (
Expand Down
16 changes: 13 additions & 3 deletions superagi/agent/super_agi.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
from superagi.vector_store.base import VectorStore
from superagi.vector_store.document import Document
import json
# from spinners.spinners import Spinner



FINISH = "finish"
print("\033[92m\033[1m" + "\nWelcome to SuperAGI - The future of AGI" + "\033[0m\033[0m")
Expand Down Expand Up @@ -70,8 +73,8 @@ def execute(self, goals: List[str]):
format_suffix_yellow = "\033[0m\033[0m"
format_prefix_green = "\033[92m\033[1m"
format_suffix_green = "\033[0m\033[0m"

i += 1
print("\n"+format_prefix_green + "____________________Iteration : "+str(i)+"________________________" + format_suffix_green+"\n")
if i > iteration:
return
# print(self.tools)
Expand All @@ -91,9 +94,16 @@ def execute(self, goals: List[str]):
current_tokens = TokenCounter.count_message_tokens(messages, self.llm.get_model())
token_limit = TokenCounter.token_limit(self.llm.get_model())

# spinner = Spinners.dots12
# spinner.start()
# spinner = Spinner('dots12')
# spinner.start()


# print("Token remaining:", token_limit - current_tokens)
response = self.llm.chat_completion(messages, token_limit - current_tokens)

# spinner.stop()
# parsed_response = json.loads(response['choices'][0]['message']['content'])
# parsed_response = json.loads(response)

Expand All @@ -118,7 +128,7 @@ def execute(self, goals: List[str]):
tools = {t.name: t for t in self.tools}

if action.name == FINISH:
print(format_prefix_green + "Sub-task completed moving to next task!" + format_suffix_green)
print(format_prefix_green + "\nTask Finished :) \n" + format_suffix_green)
return action.args["response"]
if action.name in tools:
tool = tools[action.name]
Expand Down Expand Up @@ -147,7 +157,7 @@ def execute(self, goals: List[str]):
self.full_message_history.append(SystemMessage(content=result))
# print(self.full_message_history)

print(format_prefix_green + "Sub-task completed moving to next task!" + format_suffix_green)
print(format_prefix_green + "Interation completed moving to next iteration!" + format_suffix_green)
pass

def call_llm(self):
Expand Down
2 changes: 1 addition & 1 deletion superagi/tools/file/write_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class WriteFileInput(BaseModel):


class WriteFileTool(BaseTool):
name: str = "Write File"
name: str = "write_file"
args_schema: Type[BaseModel] = WriteFileInput
description: str = "Writes text to a file"

Expand Down
2 changes: 1 addition & 1 deletion test.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def create_campaign(campaign_name: str):



superagi = SuperAgi.from_llm_and_tools("Super AGI", "Super AGI", memory, tools, OpenAi(model="gpt-4"))
superagi = SuperAgi.from_llm_and_tools("Super AGI", "To solve any complex problems for you", memory, tools, OpenAi(model="gpt-4"))
user_goal=[]
user_goal=str(input("Enter your Goal:\n"))
superagi.execute([user_goal])

0 comments on commit d004f71

Please sign in to comment.