Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

:bug: Minor type fixes

Taylor Beestonea67b6772c46
diff --git a/autogpt/llm_utils.py b/autogpt/llm_utils.py
index 4fb0e1f537..bc68ba9372 100644
--- a/autogpt/llm_utils.py
+++ b/autogpt/llm_utils.py
@@ -1,12 +1,14 @@
from __future__ import annotations
import time
+from typing import List, Optional
import openai
from colorama import Fore
from openai.error import APIError, RateLimitError
from autogpt.config import Config
+from plugin_template import Message
CFG = Config()
@@ -35,8 +37,8 @@ def call_ai_function(
# For each arg, if any are None, convert to "None":
args = [str(arg) if arg is not None else "None" for arg in args]
# parse args to comma separated string
- args = ", ".join(args)
- messages = [
+ args: str = ", ".join(args)
+ messages: List[Message] = [
{
"role": "system",
"content": f"You are now the following python function: ```# {description}"
@@ -51,15 +53,15 @@ def call_ai_function(
# Overly simple abstraction until we create something better
# simple retry mechanism when getting a rate error or a bad gateway
def create_chat_completion(
- messages: list, # type: ignore
- model: str | None = None,
+ messages: List[Message], # type: ignore
+ model: Optional[str] = None,
temperature: float = CFG.temperature,
- max_tokens: int | None = None,
+ max_tokens: Optional[int] = None,
) -> str:
"""Create a chat completion using the OpenAI API
Args:
- messages (list[dict[str, str]]): The messages to send to the chat completion
+ messages (List[Message]): The messages to send to the chat completion
model (str, optional): The model to use. Defaults to None.
temperature (float, optional): The temperature to use. Defaults to 0.9.
max_tokens (int, optional): The max tokens to use. Defaults to None.
diff --git a/autogpt/plugins.py b/autogpt/plugins.py
index a00b989eae..b4b2ac7882 100644
--- a/autogpt/plugins.py
+++ b/autogpt/plugins.py
@@ -6,6 +6,8 @@ from pathlib import Path
from typing import List, Optional, Tuple
from zipimport import zipimporter
+from plugin_template import AutoGPTPluginTemplate
+
def inspect_zip_for_module(zip_path: str, debug: bool = False) -> Optional[str]:
"""
@@ -45,7 +47,9 @@ def scan_plugins(plugins_path: Path, debug: bool = False) -> List[Tuple[str, Pat
return plugins
-def load_plugins(plugins_path: Path, debug: bool = False) -> List[Module]:
+def load_plugins(
+ plugins_path: Path, debug: bool = False
+) -> List[AutoGPTPluginTemplate]:
"""Load plugins from the plugins directory.
Args:
diff --git a/autogpt/token_counter.py b/autogpt/token_counter.py
index 338fe6be4d..8cf4c369e4 100644
--- a/autogpt/token_counter.py
+++ b/autogpt/token_counter.py
@@ -1,13 +1,16 @@
"""Functions for counting the number of tokens in a message or string."""
from __future__ import annotations
+from typing import List
import tiktoken
from autogpt.logs import logger
+from plugin_template import Message
+
def count_message_tokens(
- messages: list[dict[str, str]], model: str = "gpt-3.5-turbo-0301"
+ messages: List[Message], model: str = "gpt-3.5-turbo-0301"
) -> int:
"""
Returns the number of tokens used by a list of messages.