File size: 1,193 Bytes
b3509ba
 
 
 
 
 
 
 
 
 
bd51fa1
 
 
 
 
 
 
 
 
 
b3509ba
bd51fa1
 
 
 
b3509ba
bd51fa1
b3509ba
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import sys
import os
import json
from pathlib import Path
sys.path.append('..')

from swarmai.Swarm import Swarm

def load_keys():
    try:
        keys_file = Path(__file__).parent.parent / "keys.json"
        with open(keys_file) as f:
            keys = json.load(f)
        os.environ["OPENAI_API_KEY"] = keys["OPENAI_API_KEY"]
        try:
            os.environ["GOOGLE_API_KEY"] = keys["GOOGLE_API_KEY"]
            os.environ["CUSTOM_SEARCH_ENGINE_ID"] = keys["CUSTOM_SEARCH_ENGINE_ID"]
            os.environ["GOOGLE_CSE_ID"] = keys["CUSTOM_SEARCH_ENGINE_ID"]
        except:
            print("WARNING: GOOGLE_API_KEY and GOOGLE_CSE_ID not found in keys.json. Googler agent will be treated as a general purpose agent.")

        try:
            os.environ["APIFY_API_TOKEN"] = keys["APIFY_API_TOKEN"]
        except:
            print("WARNING: APIFY_API_TOKEN not found in keys.json. WebScraper agent will not work.")
    except:
        pass

def run_swarm():
    # establishing the swarm
    swarm_config_loc = Path(__file__).parent.parent / "swarm_config.yaml"
    load_keys()
    swarm1 = Swarm(swarm_config_loc)
    swarm1.run_swarm()

if __name__=="__main__":
    run_swarm()