Skip to content

Commit

Permalink
Merge pull request TransformerOptimus#122 from TransformerOptimus/gpt3.5
Browse files Browse the repository at this point in the history
Added LLM thinking tool
  • Loading branch information
TransformerOptimus authored May 27, 2023
2 parents bf2a0e6 + e180811 commit f307aba
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 2 deletions.
2 changes: 1 addition & 1 deletion superagi/agent/output_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def parse(self, text: str) -> AgentGPTAction:
format_prefix_green = "\033[92m\033[1m"
format_suffix_green = "\033[0m\033[0m"
print(format_prefix_green + "Intelligence : " + format_suffix_green)
print(format_prefix_yellow + "Thoughts: " + format_suffix_yellow + parsed["thoughts"]["reasoning"] + "\n")
print(format_prefix_yellow + "Thoughts: " + format_suffix_yellow + parsed["thoughts"]["text"] + "\n")
print(format_prefix_yellow + "Reasoning: " + format_suffix_yellow + parsed["thoughts"]["reasoning"] + "\n")
print(format_prefix_yellow + "Plan: " + format_suffix_yellow + parsed["thoughts"]["plan"] + "\n")
print(format_prefix_yellow + "Criticism: " + format_suffix_yellow + parsed["thoughts"]["criticism"] + "\n")
Expand Down
Empty file.
38 changes: 38 additions & 0 deletions superagi/tools/thinking/tools.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import os
import openai
from typing import Type, Optional

from pydantic import BaseModel, Field
from superagi.tools.base_tool import BaseTool
from superagi.config.config import get_config
from superagi.llms.base_llm import BaseLlm
from pydantic import BaseModel, Field, PrivateAttr


class LlmTaskSchema(BaseModel):
task_description: str = Field(
...,
description="Text describing the task for which the LLM should generate a response.",
)

class LlmThinkingTool(BaseTool):
llm: Optional[BaseLlm] = None
name = "LlmThinkingTool"
description = (
"A tool that interacts with any given LLM "
"to generate text given a certain task description."
)
args_schema: Type[LlmTaskSchema] = LlmTaskSchema

class Config:
arbitrary_types_allowed = True


def _execute(self, task_description: str):
try:
messages = [{"role": "system", "content": task_description}]
result = self.llm.chat_completion(messages)
return result["content"]
except Exception as e:
print(e)
return f"Error generating text: {e}"
4 changes: 3 additions & 1 deletion test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from superagi.tools.google_search.tools import GoogleSearchSchema, GoogleSearchTool
from superagi.tools.google_serp_search.tools import GoogleSerpTool
from superagi.tools.twitter.send_tweet import SendTweetTool
from superagi.tools.thinking.tools import LlmThinkingTool
from superagi.tools.email.read_email import ReadEmailTool
from superagi.tools.email.send_email import SendEmailTool
from superagi.tools.email.send_email_attachment import SendEmailAttachmentTool
Expand All @@ -26,6 +27,7 @@ def create_campaign(campaign_name: str):


tools = [
LlmThinkingTool(llm=OpenAi(model="gpt-3.5-turbo")),
GoogleSearchTool(),
WriteFileTool(),
ReadFileTool(),
Expand All @@ -43,7 +45,7 @@ def create_campaign(campaign_name: str):



superagi = SuperAgi.from_llm_and_tools("Super AGI", "To solve any complex problems for you", 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-3.5-turbo"))
user_goal=[]
user_goal=str(input("Enter your Goals seperated by ',':\n")).split(",")
superagi.execute(user_goal)

0 comments on commit f307aba

Please sign in to comment.