From 50464c50a8e8c37d7f5307d19d653ba5483d65f5 Mon Sep 17 00:00:00 2001 From: frdel <38891707+frdel@users.noreply.github.com> Date: Fri, 19 Jul 2024 22:47:16 +0200 Subject: [PATCH] gpt-4o-mini --- README.md | 13 ++++++------- main.py | 7 ++++--- models.py | 5 +++++ 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 72fe6d3b8..8d1393e85 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ ## Keep in mind 1. **Agent Zero can be dangerous!** -With proper instruction, Agent Zero is capable of many things, even potentially dangerous to your computer, data, or accounts. Always run Agent Zero in an isolated environment, preferably in a Linux virtual machine with backup. +With proper instruction, Agent Zero is capable of many things, even potentially dangerous to your computer, data, or accounts. Always run Agent Zero in an isolated environment, preferably in the built-in automated Docker solution. 2. **Agent Zero is not pre-programmed; it is prompt-based.** The whole framework contains only a minimal amount of code and does not guide the agent in any way. @@ -54,23 +54,22 @@ Everything lies in the system prompt in the **prompts/** folder. Here you can re If your agent fails to communicate properly, use tools, reason, use memory, find answers - just instruct it better. 3. **If you cannot provide the ideal environment, let your agent know.** -Agent Zero is made to be used in an isolated virtual machine (for safety) with some tools preinstalled and configured. +Agent Zero is made to be used in an isolated virtual environment (for safety) with some tools preinstalled and configured. If you cannot provide all the necessary conditions or API keys, just change the system prompt and tell your agent what operating system and tools are at its disposal. Nothing is hard-coded; if you do not tell your agent about a certain tool, it will not know about it and will not try to use it. ## Known problems 1. The system prompt sucks. You can do better. If you do, help me please :) -2. Input freeze on some Linux terminals - for some reason, sometimes the input field freezes on some terminal apps on linux when the window loses focus. Right now I have no clue why... -3. Claude models like to hallucinate when using tools. This can probebly be fixed in prompt, but for some reason, Claude models like to use multiple tools in a single message and not wait for output, they just make up their outputs right away. For now I have limited the tool usage to 1 tool per message, this helps a little. +2. Claude models like to hallucinate when using tools. This can probebly be fixed in prompt, but for some reason, Claude models like to use multiple tools in a single message and not wait for output, they just make up their outputs right away. For now I have limited the tool usage to 1 tool per message, this helps a little. ## Ideal environment -- **Linux VM / docker container**: The perfect environment to run Agent Zero is a Debian-based Linux virtual machine or docker container with enhanced privileges or root access (to install packages and run terminal commands). +- **Linux VM / docker container**: The perfect environment to run Agent Zero is a Debian-based Linux virtual machine or (event better) the built-in docker container with enhanced privileges or root access (to install packages and run terminal commands). - **Python**: Python has to be installed on the system to run the framework and let the agent execute created Python scripts. - **NodeJS**: NodeJS is required to allow the agent to run JS scripts as well. - **Internet access**: The agent will need internet access to use its online knowledge tool and execute commands and scripts requiring a connection. If you do not need your agent to be online, you can alter its prompts in the **prompts/** folder and make it fully local. ## Setup 1. **Required API keys:** -- At the moment, the only required API key is for https://www.perplexity.ai/ API. Perplexity is used as a convenient web search tool and has not yet been replaced by an open-source alternative. +- At the moment, the only recommended API key is for https://www.perplexity.ai/ API. Perplexity is used as a convenient web search tool and has not yet been replaced by an open-source alternative. - Chat models and embedding models can be executed locally via Ollama and HuggingFace or via API as well. 2. **Enter your API keys:** @@ -86,7 +85,7 @@ export API_KEY_OPENAI="your-api-key-here" pip install -r requirements.txt ~~~ -3. **Choose your chat and embeddings model:** +3. **Choose your chat, utility and embeddings model:** - In the **main.py** file, right at the start of the **chat()** function, you can see how the chat model and embedding model are set. - You can choose between online models (OpenAI, Anthropic, Groq) or offline (Ollama, HuggingFace) for both. diff --git a/main.py b/main.py index 9e4f3adaa..5c8c00975 100644 --- a/main.py +++ b/main.py @@ -20,6 +20,7 @@ def initialize(): # chat_llm = models.get_groq_llama8b(temperature=0.2) # chat_llm = models.get_openai_gpt35(temperature=0) # chat_llm = models.get_openai_gpt4o(temperature=0) + chat_llm = models.get_openai_chat(temperature=0) # chat_llm = models.get_anthropic_opus(temperature=0) # chat_llm = models.get_anthropic_sonnet(temperature=0) # chat_llm = models.get_anthropic_sonnet_35(temperature=0) @@ -29,12 +30,12 @@ def initialize(): # chat_llm = models.get_ollama(model_name="llama3:8b-text-fp16") # chat_llm = models.get_ollama(model_name="gemma2:latest") # chat_llm = models.get_ollama(model_name="qwen:14b") - chat_llm = models.get_google_chat() + # chat_llm = models.get_google_chat() # utility model used for helper functions (cheaper, faster) - utility_llm = models.get_anthropic_haiku(temperature=0) - + utility_llm = models.get_openai_chat(temperature=0) + # embedding model used for memory embedding_llm = models.get_embedding_openai() # embedding_llm = models.get_embedding_hf() diff --git a/models.py b/models.py index 22fbe4b09..58c182f0e 100644 --- a/models.py +++ b/models.py @@ -40,6 +40,11 @@ def get_openai_gpt35(api_key=None, temperature=DEFAULT_TEMPERATURE): api_key = api_key or get_api_key("openai") return ChatOpenAI(model_name="gpt-3.5-turbo", temperature=temperature, api_key=api_key) # type: ignore +def get_openai_chat(api_key=None, model="gpt-4o-mini", temperature=DEFAULT_TEMPERATURE): + api_key = api_key or get_api_key("openai") + return ChatOpenAI(model_name=model, temperature=temperature, api_key=api_key) # type: ignore + + def get_openai_gpt35_instruct(api_key=None, temperature=DEFAULT_TEMPERATURE): api_key = api_key or get_api_key("openai") return OpenAI(model_name="gpt-3.5-turbo-instruct", temperature=temperature, api_key=api_key) # type: ignore