mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2026-01-07 00:04:26 +01:00
* Implemented running cost counter for chat completions This data is known to the AI as additional system context, and is printed out to the user * Added comments to api_manager.py * Added user-defined API budget. The user is now prompted if they want to give the AI a budget for API calls. If they enter nothing, there is no monetary limit, but if they define a budget then the AI will be told to shut down gracefully once it has come within 1 cent of its limit, and to shut down immediately once it has exceeded its limit. If a budget is defined, Auto-GPT is always aware of how much it was given and how much remains to be spent. * Chat completion calls are now done through api_manager. Total running cost is printed. * Implemented api budget setting and tracking User can now configure a maximum api budget, and the AI is aware of that and its remaining budget. The AI is instructed to shut down when exceeding the budget. * Update autogpt/api_manager.py Change "per token" to "per 1000 tokens" in a comment on the api cost Co-authored-by: Rob Luke <code@robertluke.net> * Fixed lint errors * Include embedding costs * Add embedding completion cost * lint * Added 'requires_api_key' decorator to test_commands.py, switched to a valid chat completions model * Refactor API manager, add debug mode, and add tests - Extract model costs to to avoid duplication - Add debug mode parameter to ApiManager class - Move debug mode configuration to - Log AI response and budget messages in debug mode - Implement 'test_api_manager.py' * Fixed test_setup failing. An extra user input is needed for api budget * Linting --------- Co-authored-by: Rob Luke <code@robertluke.net> Co-authored-by: Nicholas Tindle <nick@ntindle.com>
39 lines
736 B
Python
39 lines
736 B
Python
"""Base class for memory providers."""
|
|
import abc
|
|
|
|
import openai
|
|
|
|
from autogpt.api_manager import api_manager
|
|
from autogpt.config import AbstractSingleton, Config
|
|
|
|
cfg = Config()
|
|
|
|
|
|
def get_ada_embedding(text):
|
|
text = text.replace("\n", " ")
|
|
return api_manager.embedding_create(
|
|
text_list=[text], model="text-embedding-ada-002"
|
|
)
|
|
|
|
|
|
class MemoryProviderSingleton(AbstractSingleton):
|
|
@abc.abstractmethod
|
|
def add(self, data):
|
|
pass
|
|
|
|
@abc.abstractmethod
|
|
def get(self, data):
|
|
pass
|
|
|
|
@abc.abstractmethod
|
|
def clear(self):
|
|
pass
|
|
|
|
@abc.abstractmethod
|
|
def get_relevant(self, data, num_relevant=5):
|
|
pass
|
|
|
|
@abc.abstractmethod
|
|
def get_stats(self):
|
|
pass
|