More troubleshooting and setup tips, and some improvements to flagship Week 8 project
This commit is contained in:
@@ -41,14 +41,18 @@ class DealAgentFramework:
|
||||
|
||||
def __init__(self):
|
||||
init_logging()
|
||||
self.log("Initializing Agent Framework")
|
||||
load_dotenv()
|
||||
client = chromadb.PersistentClient(path=self.DB)
|
||||
self.memory = self.read_memory()
|
||||
self.collection = client.get_or_create_collection('products')
|
||||
self.planner = PlanningAgent(self.collection)
|
||||
self.log("Agent Framework is ready")
|
||||
self.planner = None
|
||||
|
||||
def init_agents_as_needed(self):
|
||||
if not self.planner:
|
||||
self.log("Initializing Agent Framework")
|
||||
self.planner = PlanningAgent(self.collection)
|
||||
self.log("Agent Framework is ready")
|
||||
|
||||
def read_memory(self) -> List[Opportunity]:
|
||||
if os.path.exists(self.MEMORY_FILENAME):
|
||||
with open(self.MEMORY_FILENAME, "r") as file:
|
||||
@@ -66,14 +70,15 @@ class DealAgentFramework:
|
||||
text = BG_BLUE + WHITE + "[Agent Framework] " + message + RESET
|
||||
logging.info(text)
|
||||
|
||||
def run(self) -> Optional[Opportunity]:
|
||||
def run(self) -> List[Opportunity]:
|
||||
self.init_agents_as_needed()
|
||||
logging.info("Kicking off Planning Agent")
|
||||
result = self.planner.plan(memory=self.memory)
|
||||
logging.info(f"Planning Agent has completed and returned: {result}")
|
||||
if result:
|
||||
self.memory.append(result)
|
||||
self.write_memory()
|
||||
return result
|
||||
return self.memory
|
||||
|
||||
@classmethod
|
||||
def get_plot_data(cls, max_datapoints=10000):
|
||||
|
||||
Reference in New Issue
Block a user