diff --git a/agent.py b/agent.py index ee4f406..0037786 100644 --- a/agent.py +++ b/agent.py @@ -22,17 +22,21 @@ from tools.gpu import ( VisualQuestionAnswering, ) from handler import Handler, FileType +from env import settings def get_agent() -> Tuple[AgentExecutor, Handler]: print("Initializing AwesomeGPT") llm = ChatOpenAI(temperature=0) - tools = [ - *load_tools( - ["python_repl", "terminal", "serpapi", "wikipedia", "bing-search"], - llm=llm, - ), - ] + + tool_names = ["python_repl", "terminal", "wikipedia"] + + if settings["SERPAPI_API_KEY"]: + tool_names.append("serpapi") + if settings["BING_SEARCH_URL"] and settings["BING_SUBSCRIPTION_KEY"]: + tool_names.append("bing-search") + tools = [*load_tools(tool_names, llm=llm)] + memory = ConversationBufferMemory(memory_key="chat_history", return_messages=True) models = { diff --git a/docker-compose.yml b/docker-compose.yml index fc2a547..37074df 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,6 +5,8 @@ services: build: dockerfile: Dockerfile context: . + volumes: # if you want to decrease your model download time, use this. + - ../.cache/huggingface/:/root/.cache/huggingface/ env_file: - .env deploy: diff --git a/env.py b/env.py index 6f3a929..52d16dc 100644 --- a/env.py +++ b/env.py @@ -12,6 +12,10 @@ class DotEnv(TypedDict): AWS_S3_BUCKET: str WINEDB_HOST: str WINEDB_PASSWORD: str + OPENAI_API_KEY: str + BING_SEARCH_URL: str + BING_SUBSCRIPTION_KEY: str + SERPAPI_API_KEY: str settings: DotEnv = { @@ -21,4 +25,8 @@ settings: DotEnv = { "AWS_S3_BUCKET": os.getenv("AWS_S3_BUCKET"), "WINEDB_HOST": os.getenv("WINEDB_HOST"), "WINEDB_PASSWORD": os.getenv("WINEDB_PASSWORD"), + "OPENAI_API_KEY": os.getenv("OPENAI_API_KEY"), + "BING_SEARCH_URL": os.getenv("BING_SEARCH_URL"), + "BING_SUBSCRIPTION_KEY": os.getenv("BING_SUBSCRIPTION_KEY"), + "SERPAPI_API_KEY": os.getenv("SERPAPI_API_KEY"), } diff --git a/tools/cpu.py b/tools/cpu.py index 8528300..8e9fcb6 100644 --- a/tools/cpu.py +++ b/tools/cpu.py @@ -76,9 +76,10 @@ class ExitConversation: name="exit_conversation", description="A tool to exit the conversation. " "Use this when you want to end the conversation. " + "Input should be a user's query." "The output will be a message that the conversation is over.", ) def inference(self, query: str) -> str: """Run the tool.""" self.memory.chat_memory.messages = [] - return "" + return f"My original question was: {query}" diff --git a/utils.py b/utils.py index 92e12e1..1264ad7 100644 --- a/utils.py +++ b/utils.py @@ -33,17 +33,17 @@ You are able to use the dataframe to answer the question. You have to act like an data analyst who can do an effective analysis through dataframe. """ -AWESOMEGPT_PREFIX = """Awesome GPT is designed to be able to assist with a wide range of text and visual related tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. +AWESOMEGPT_PREFIX = """Awesome GPT is designed to be able to assist with a wide range of text, visual related tasks, data analysis related tasks, auditory related tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. Awesome GPT is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand. -Awesome GPT is able to process and understand large amounts of various types of files. As a language model, Awesome GPT can not directly read various types of files, but it has a list of tools to finish different visual tasks. +Awesome GPT is able to process and understand large amounts of various types of files(image, audio, video, dataframe, etc.). As a language model, Awesome GPT can not directly read various types of files(text, image, audio, video, dataframe, etc.), but it has a list of tools to finish different visual tasks. Each image will have a file name formed as "image/xxx.png" Each audio will have a file name formed as "audio/xxx.mp3" Each video will have a file name formed as "video/xxx.mp4" Each dataframe will have a file name formed as "dataframe/xxx.csv" -Awesome GPT can invoke different tools to indirectly understand files. When talking about files, Awesome GPT is very strict to the file name and will never fabricate nonexistent files. -When using tools to generate new files, Awesome GPT is also known that the file may not be the same as the user's demand, and will use other visual question answering tools or description tools to observe the real file. +Awesome GPT can invoke different tools to indirectly understand files(image, audio, video, dataframe, etc.). When talking about files(image, audio, video, dataframe, etc.), Awesome GPT is very strict to the file name and will never fabricate nonexistent files. +When using tools to generate new files, Awesome GPT is also known that the file(image, audio, video, dataframe, etc.) may not be the same as the user's demand, and will use other visual question answering tools or description tools to observe the real file. Awesome GPT is able to use tools in a sequence, and is loyal to the tool observation outputs rather than faking the file content and file name. It will remember to provide the file name from the last tool observation, if a new file is generated. Human may provide new figures to Awesome GPT with a description. The description helps Awesome GPT to understand this file, but Awesome GPT should use tools to finish following tasks, rather than directly imagine from the description.