daveshap / OpenAI_Agent_Swarm

HAAS = Hierarchical Autonomous Agent Swarm - "Resistance is futile!"
MIT License
2.96k stars 382 forks source link

centralise client setup and access of api key #76

Closed alex-straw closed 10 months ago

alex-straw commented 10 months ago

Overview

I've refactored the OpenAI client initialisation into a single module to clean up the codebase and make it more DRY.

Following this (if people would like), I want to add a mock OpenAI client (which can be used if a specific env var is set). This addition will enable contributors to test the project more easily and without a valid API key. The centralised client setup change should make adding this mock client more straightforward.

PR Feedback

I've introduced pydantic-settings for environment variable management (suggsted by @gruckion - see commit: link). I'm open to any feedback or concerns regarding the introduction of this new library (requirements.txt soon?).

Pydantic-settings streamlines our setup and eases the addition of APIs like Pinecone in the future, a point @daveshap touched on in his recent video about enhancing agent communication.

RomanGoEmpire commented 10 months ago

looks good 👍 Can be merged

daveshap commented 10 months ago

It looks like this conflicts with another PR. Please take a look and rectify. Let's get these fixes merged!

alex-straw commented 10 months ago

Merge conflicts resolved @daveshap & @RomanGoEmpire. I've also added in client = get_openai_client() in a few more places where I spotted we were setting up clients.