-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
latentvector
committed
May 17, 2024
1 parent
161ceb1
commit 09af24d
Showing
13 changed files
with
101 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,28 @@ | ||
import commune as c | ||
|
||
class Watchdog(c.Module): | ||
def __init__(self): | ||
def __init__(self, modules=['module', 'subspace']): | ||
self.modules = {m: c.module(m) for m in modules} | ||
self.module = c.module('watchdog') | ||
c.thread(self.run_loop) | ||
|
||
def sync(self): | ||
self.modules = {m: c.module(m) for m in self.modules} | ||
c.print('syncing...') | ||
c.ip(update=1) | ||
c.tree(update=1) | ||
c.namespace(update=1) | ||
c.print('synced') | ||
self.subspace = c.module('subspace') | ||
self.subspace = c.get_module('subspace') | ||
self.subspace.stake_from(netuid='all') | ||
|
||
|
||
|
||
def run_loop(self, sleep_time=30): | ||
def run_loop(self, sleep_time=30): | ||
while True: | ||
try: | ||
self.sync() | ||
except Exception as e: | ||
print(e) | ||
pass | ||
c.sleep(sleep_time) | ||
print(f'sleeping for {sleep_time} seconds') | ||
e = c.detailed_error(e) | ||
c.print(f'Error syncing, restarting {e}') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import commune as c | ||
|
||
|
||
class Comchat(c.Module): | ||
def __init__(self, model='model.openrouter' , **kwargs): | ||
self.model = c.module(model)(**kwargs) | ||
def generate(self, text, **kwargs): | ||
return self.model.generate(text, **kwargs) | ||
def test(self): | ||
return self.generate('hello world') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,26 @@ | ||
print('fam') | ||
import commune as c | ||
|
||
|
||
def register_servers(netuid=6, buffer = 100, timeout = 60): | ||
subspace = c.module('subspace')() | ||
stake = subspace.min_register_stake(netuid=netuid) + buffer | ||
key2balance = {k:v for k,v in c.key2balance().items() if v > stake} | ||
keys = list(key2balance.keys()) | ||
c.print(f'Keys for registration: {keys}') | ||
servers = c.servers() | ||
c.print(f'Servers: {servers}') | ||
futures = [] | ||
for i, s in enumerate(c.servers()): | ||
c.print(f'Registering {s}') | ||
key = keys[i % len(keys)] | ||
future = c.submit(c.register, kwargs=dict(name=s, netuid=netuid, stake=stake, key=key ), timeout=timeout) | ||
futures.append(future) | ||
|
||
for f in c.as_completed(futures, timeout=timeout): | ||
c.print(f.result()) | ||
|
||
|
||
while True: | ||
register_servers() | ||
# for s in c.servers(): | ||
# c.register(s, netuid=) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import commune as c | ||
|
||
|
||
class Comchat(c.Module): | ||
def __init__(self, model='model.openrouter' , **kwargs): | ||
self.model = c.module(model)(**kwargs) | ||
def generate(self, text, **kwargs): | ||
return self.model.generate(text, **kwargs) | ||
def test(self): | ||
return self.generate('hello world') |