Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
138 commits
Select commit Hold shift + click to select a range
77e4d07
feat: update README.md file
sangar-1028 Sep 18, 2024
1dae750
feat: update setup.py appropriate
sangar-1028 Sep 18, 2024
9b8837a
feat: update CONTRIBUTING.md file
sangar-1028 Sep 18, 2024
3a34d7b
feat: replaced template with btcopilot
sangar-1028 Sep 18, 2024
38ff642
feat: update btcopilot/__init__.py file
sangar-1028 Sep 18, 2024
b63bf4d
feat: update setup.py
sangar-1028 Sep 18, 2024
c97712e
feat: update gitignore file
sangar-1028 Sep 18, 2024
89a13c3
feat: specified author's name
sangar-1028 Sep 27, 2024
dd6a125
feat: complete miner and validator part for initial workflow
sangar-1028 Oct 31, 2024
419e332
feat: add organatic forward
sangar-1028 Oct 31, 2024
49ee7c0
feat: text2html
sangar-1028 Oct 31, 2024
15f1dc5
feat: update readme
sangar-1028 Nov 4, 2024
4b38c2b
feat: add scoring mechanism for the imagetohtml feature
Cardoso-topdev Nov 15, 2024
b761424
chore: readme update
Cardoso-topdev Nov 15, 2024
9967324
chore: readme update
Cardoso-topdev Nov 15, 2024
355f557
chore: readme update
Cardoso-topdev Nov 15, 2024
e28172e
chore: update documents
sangar-1028 Dec 11, 2024
287a02a
chore: replaced incentive formula code with an image
sangar-1028 Dec 11, 2024
b834403
Merge branch 'main' into feat/dev
sangar-1028 Dec 11, 2024
e3c3fa2
Merge pull request #2 from web-genie-ai/feat/dev
sangar-1028 Dec 11, 2024
3008c6c
chore: rename folder name
pycorn0729 Dec 11, 2024
d541dc9
chore: refactor packagename
pycorn0729 Dec 11, 2024
abd64fb
chore: refactor folder structure
pycorn0729 Dec 11, 2024
1702715
feat: restructure architecture
pycorn0729 Dec 12, 2024
8945131
chore: refactor rewarding structure
pycorn0729 Dec 12, 2024
e799192
fix: fixed bugs for launch
pycorn0729 Dec 12, 2024
5cf0c92
fix: fixed bugs in miner
pycorn0729 Dec 12, 2024
afcaf02
feat: added wandb logging
pycorn0729 Dec 12, 2024
cfd0080
chore : added wandb to gitignore
pycorn0729 Dec 12, 2024
1cc9a26
chre: added pseudo rewards
pycorn0729 Dec 12, 2024
562b8c1
chore: added sanity check
pycorn0729 Dec 12, 2024
4739278
feat: added openai text miner
pycorn0729 Dec 12, 2024
9559108
feat: added image task process
pycorn0729 Dec 12, 2024
f0305fe
feat: remove wandb
pycorn0729 Dec 12, 2024
7036a55
feat: add wandb to the gitignore list
pycorn0729 Dec 12, 2024
ad8f1a5
feat: implemented organic task
pycorn0729 Dec 12, 2024
5d061cc
chore: removed version in wandb run name
pycorn0729 Dec 12, 2024
b8c8807
feat: implemented visual reward
pycorn0729 Dec 13, 2024
ee552e4
chore: moved backend api hotkey to constants
pycorn0729 Dec 13, 2024
7c90dd4
docs: added comments in constants
pycorn0729 Dec 13, 2024
cb7fe17
feat: added bert reward
pycorn0729 Dec 13, 2024
6b30f5e
fix: fixed bugs in bert
pycorn0729 Dec 13, 2024
25e5b18
chore: implemented preprocess html pseudo code
pycorn0729 Dec 13, 2024
488b6f0
chore: implemented preprocess func
pycorn0729 Dec 13, 2024
03b268d
feat: implemented rtc reward
pycorn0729 Dec 13, 2024
b2b5d13
feat: added auto update script
pycorn0729 Dec 13, 2024
46eb1e2
chore: removed hardcoded python cmd
pycorn0729 Dec 13, 2024
6c37c1b
chore: removed dummy miner
pycorn0729 Dec 13, 2024
e93db24
docs: added developer info
pycorn0729 Dec 13, 2024
3580ebf
docs: changed developer info
pycorn0729 Dec 13, 2024
b3714a7
chore: added code removing work file int htmls helper
pycorn0729 Dec 13, 2024
60d4078
chore:wrote code to make work dir
pycorn0729 Dec 13, 2024
513fdf1
chore: added .env.example file
pycorn0729 Dec 13, 2024
ca9a45a
chore: reconfigured .env files
pycorn0729 Dec 13, 2024
e7060d5
docs: updated requirements.txt
pycorn0729 Dec 13, 2024
d014476
chore: updated beautify_html func
pycorn0729 Dec 13, 2024
7a07cce
chore: updated imagetaskgenerator
pycorn0729 Dec 13, 2024
6e1818b
chore: added exception handling
pycorn0729 Dec 13, 2024
b2b18b3
chore: removed logging
pycorn0729 Dec 13, 2024
6313c10
chore: added seperate_html_css
pycorn0729 Dec 13, 2024
0a465bb
chore: added html validity check
pycorn0729 Dec 13, 2024
514a1e8
chore: removed unneccessary file
pycorn0729 Dec 13, 2024
ce4ffaf
updated gitignore
pycorn0729 Dec 13, 2024
45b3dd0
removed run scripts
pycorn0729 Dec 13, 2024
1b64725
Merge pull request #3 from web-genie-ai/dev
pycorn0729 Dec 13, 2024
6f85003
feat: update readme for text prompted html generation model
Cardoso-topdev Dec 13, 2024
7e169fa
Merge branch 'main' of https://github.com/web-genie-ai/web-genie-ai
Cardoso-topdev Dec 13, 2024
5a2d2cf
feat: added synthetic dataset
pycorn0729 Dec 14, 2024
6fbeeb5
refactor: moved mockup dataset to seperate file
pycorn0729 Dec 14, 2024
4b0b59a
style: removed unneccessary imports
pycorn0729 Dec 14, 2024
9b1a006
feat: added synthetic dataset to image task generator
pycorn0729 Dec 14, 2024
548dde3
feat: updated synthetic dataset
pycorn0729 Dec 14, 2024
7fd1609
fix: fixed bugs in import
pycorn0729 Dec 14, 2024
78cb9ad
docs: added paper link
pycorn0729 Dec 14, 2024
ad4cef9
docs: updated comment
pycorn0729 Dec 14, 2024
a56f827
fix: fixed synthetic data gen
pycorn0729 Dec 14, 2024
1ec8a85
fix: fixed bugs
pycorn0729 Dec 14, 2024
2f5dd01
fix: fixed bugs in synthetic dataset
pycorn0729 Dec 14, 2024
b7edac0
style: removed some empty lines
pycorn0729 Dec 14, 2024
14accdb
style: styled
pycorn0729 Dec 14, 2024
1a632de
Merge pull request #4 from web-genie-ai/dev
sangar-1028 Dec 14, 2024
b79d74a
feat: add workflow diagram
Cardoso-topdev Dec 16, 2024
7190164
Merge branch 'main' of https://github.com/web-genie-ai/web-genie-ai i…
Cardoso-topdev Dec 16, 2024
76b650c
fix: incentive block match scoring formula
Cardoso-topdev Dec 16, 2024
15dc6e4
Merge pull request #5 from web-genie-ai/feat/add-workflow-diagram
Cardoso-topdev Dec 16, 2024
ee527a2
hotfix: hyperlink anchor issue
Cardoso-topdev Dec 16, 2024
3453113
chore: seperated making tasks loop
pycorn0729 Dec 17, 2024
bcd0585
chore: reduced sleep time
pycorn0729 Dec 17, 2024
af12c6f
chore: updated logging info
pycorn0729 Dec 17, 2024
d220243
chore: updated logging infos
pycorn0729 Dec 17, 2024
aaf5393
chore: updated logging info
pycorn0729 Dec 17, 2024
ac0d779
feat: added git design2code dataset
pycorn0729 Dec 17, 2024
8b139f1
chore: added env variables for llm
pycorn0729 Dec 17, 2024
91869a4
chore: implemented async langchain
pycorn0729 Dec 17, 2024
757bc7e
chore: set weights for tasks
pycorn0729 Dec 17, 2024
b44c4ba
chore: updated hf-dataset
pycorn0729 Dec 17, 2024
c432cae
Merge pull request #6 from web-genie-ai/dev
donbusha Dec 18, 2024
55b3c7d
feat: updated incentive reward
donbusha Dec 18, 2024
ec04cb9
style: styled code
donbusha Dec 18, 2024
198d90b
fix: fixed circular import
donbusha Dec 18, 2024
36e05a3
fix: fixed circular import
donbusha Dec 18, 2024
966ef04
chore: updated dependencies
donbusha Dec 18, 2024
3f1114b
feat: added base image2html model
donbusha Dec 18, 2024
2704e49
fix: fixed bugs for backend hotkey
donbusha Dec 18, 2024
7388fdd
fix: fixed bugs for empty html
donbusha Dec 18, 2024
52a6125
feat: merged with dev and resolved conflict
donbusha Dec 18, 2024
1d5298d
chore: added miner logs
donbusha Dec 18, 2024
57a6dca
fix: fixed bugs
donbusha Dec 18, 2024
2b9a832
fix: fixed bugs
donbusha Dec 18, 2024
03f28d7
feat: added text2html basemodel
donbusha Dec 19, 2024
a5dc545
wip: ext2html
donbusha Dec 19, 2024
0f76a09
feat: added text2html model
donbusha Dec 19, 2024
7ee25c2
chore: added time measure
donbusha Dec 19, 2024
84182ab
feat: checked gpu
donbusha Dec 19, 2024
612d783
chore: added logs
donbusha Dec 19, 2024
7b1573e
chore: added logs
donbusha Dec 19, 2024
1552a23
chore: added logs
donbusha Dec 19, 2024
5dca432
chore: added logs
donbusha Dec 19, 2024
fd0108f
build(bittensor): upgraded version
donbusha Dec 19, 2024
2dffbd4
chore: added default llm config
donbusha Dec 19, 2024
1366917
fix: fixed clearing state
donbusha Dec 20, 2024
1569d5c
feat: updated s_bert
donbusha Dec 20, 2024
7df5a62
feat: implemented batch scoring
donbusha Jan 2, 2025
73165c1
feat: updated incentive reward
donbusha Jan 2, 2025
a8aa6aa
feat: added code quality reward
pycorn0729 Jan 3, 2025
b862df3
chore: added code quality criteria
pycorn0729 Jan 3, 2025
975ff6e
chore: implemented stressing miners
pycorn0729 Jan 5, 2025
6fd2e2f
feat: implemented stressing miners
pycorn0729 Jan 5, 2025
fa03ba0
chore: removed logs
pycorn0729 Jan 5, 2025
b05a0aa
chore: edited .env files
pycorn0729 Jan 5, 2025
eea7232
hotfix: fixed division by zero
pycorn0729 Jan 5, 2025
7942716
chore: created new dendrite when query to miners
pycorn0729 Jan 5, 2025
00a432a
hotfix: fixed bugs when new miners register
pycorn0729 Jan 5, 2025
531387e
chore: removed temp files
pycorn0729 Jan 5, 2025
b26bac5
chore: updated reward system
pycorn0729 Jan 5, 2025
53a8830
feat: updated code quality prompt
pycorn0729 Jan 6, 2025
7175af8
feat: updated incentive mechanize to avoid uid pressure
pycorn0729 Jan 6, 2025
b0b4093
chore: renamed the var name
pycorn0729 Jan 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .env.miner.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
WANDB_API_KEY = your_wandb_api_key
WANDB_ENTITY_NAME = your_wandb_entity_name

HF_TOKEN = your_huggingface_token

LLM_API_KEY = your_openai_api_key
LLM_MODEL_ID = your_openai_model_id
LLM_MODEL_URL = your_openai_model_url
6 changes: 6 additions & 0 deletions .env.validator.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
WANDB_API_KEY = your_wandb_api_key
WANDB_ENTITY_NAME = your_wandb_entity_name

LLM_API_KEY = your_openai_api_key
LLM_MODEL_ID = your_openai_model_id
LLM_MODEL_URL = your_openai_model_url
26 changes: 26 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,29 @@ testing/

# Editors
.vscode/settings.json

.DS_Store
temp.txt

# env
.env.miner
.env.validator

# test
test.py

# Wandb
wandb/

# work dir
work/
work_save/
*.png

# scripts
run_miner.sh
run_miner_2.sh
run_validator.sh

# developer doc
developer_doc.md
311 changes: 122 additions & 189 deletions README.md

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions auto_update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash


while true; do
# Log the start of the script execution
echo "$(date): Script started"

# Save the current HEAD hash
current_head=$(git rev-parse HEAD)

# Pull the latest changes from the repository
git stash
git pull -f
git reset --hard origin/main

# Get the new HEAD hash
new_head=$(git rev-parse HEAD)

# Check if the new HEAD is different from the current HEAD
if [ "$current_head" != "$new_head" ]; then
# The HEAD has changed, meaning there's a new version
echo "$(date): New version detected, installing requirements and restarting the validator."
pip install -e .
pm2 restart webgenie_validator
else
# No new version, no action needed
echo "$(date): No new version detected, no restart needed."
fi

# Sleep until the beginning of the next hour
sleep 3600
done
10 changes: 5 additions & 5 deletions contrib/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Contributing to Bittensor Subnet Development
# Contributing to webgenie

The following is a set of guidelines for contributing to the Bittensor ecosystem. These are **HIGHLY RECOMMENDED** guidelines, but not hard-and-fast rules. Use your best judgment, and feel free to propose changes to this document in a pull request.
The following is a set of guidelines for contributing to the webgenie Subnet. These are **HIGHLY RECOMMENDED** guidelines, but not hard-and-fast rules. Use your best judgment, and feel free to propose changes to this document in a pull request.

## Table Of Contents
1. [How Can I Contribute?](#how-can-i-contribute)
Expand All @@ -16,10 +16,10 @@ The following is a set of guidelines for contributing to the Bittensor ecosystem


## How Can I Contribute?
TODO(developer): Define your desired contribution procedure.
You can fork this repository and create a PR with your codes and request review from our development team. You can reference [Pull Request Philosophy](#pull-request-philosophy).

## Communication Channels
TODO(developer): Place your communication channels here
Contact us on [Our discord server](https://discord.gg/P2XRwVEJ)

> Please follow the Bittensor Subnet [style guide](./STYLE.md) regardless of your contribution type.

Expand Down Expand Up @@ -99,7 +99,7 @@ After you submit a pull request, it will be reviewed by the maintainers. They ma
> Note: Be sure to merge the latest from "upstream" before making a pull request:

```bash
git remote add upstream https://github.com/opentensor/bittensor.git # TODO(developer): replace with your repo URL
git remote add upstream https://github.com/webgenie/webgenie.git
git fetch upstream
git merge upstream/<your-branch-name>
git push origin <your-branch-name>
Expand Down
Binary file added docs/incentive-fomula.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 9 additions & 9 deletions docs/running_on_mainnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ After installing `bittensor`, proceed as below:

## Steps

## 1. Install your subnet template
## 1. Install web-genie-ai

**NOTE: Skip this step if** you already did this during local testing and development.

In your project directory:

```bash
git clone https://github.com/opentensor/bittensor-subnet-template.git
git clone https://github.com/web-genie-ai/web-genie-ai.git
```

Next, `cd` into `bittensor-subnet-template` repo directory:
Next, `cd` into `web-genie-ai` repo directory:

```bash
cd bittensor-subnet-template
cd web-genie-ai
```

Install the Bittensor subnet template package:
Expand Down Expand Up @@ -132,7 +132,7 @@ This step registers your subnet validator and subnet miner keys to the subnet gi
Register your miner key to the subnet:

```bash
btcli subnet recycle_register --netuid 1 --subtensor.network finney --wallet.name miner --wallet.hotkey default
btcli subnet recycle_register --netuid [mainnet_netuid] --subtensor.network finney --wallet.name miner --wallet.hotkey default
```

Follow the below prompts:
Expand All @@ -149,13 +149,13 @@ Follow the below prompts:
Next, register your validator key to the subnet:

```bash
btcli subnet recycle_register --netuid 1 --subtensor.network finney --wallet.name validator --wallet.hotkey default
btcli subnet recycle_register --netuid [mainnet_netuid] --subtensor.network finney --wallet.name validator --wallet.hotkey default
```

Follow the below prompts:

```bash
>> Enter netuid [1] (1): # Enter netuid 1 to specify the subnet you just created.
>> Enter netuid [1] (1): # Enter netuid [mainnet_netuid] to specify the subnet you just created.
>> Continue Registration?
hotkey: ...
coldkey: ...
Expand Down Expand Up @@ -202,7 +202,7 @@ miner default 1 True 0.00000 0.00000 0.00000 0.00000 0.00000
Run the subnet miner:

```bash
python neurons/miner.py --netuid 1 --wallet.name miner --wallet.hotkey default --logging.debug
python neurons/miner.py --netuid [mainnet_netuid] --wallet.name miner --wallet.hotkey default --logging.debug
```

You will see the below terminal output:
Expand All @@ -214,7 +214,7 @@ You will see the below terminal output:
Run the subnet validator:

```bash
python neurons/validator.py --netuid 1 --wallet.name validator --wallet.hotkey default --logging.debug
python neurons/validator.py --netuid [mainnet_netuid] --wallet.name validator --wallet.hotkey default --logging.debug
```

You will see the below terminal output:
Expand Down
12 changes: 6 additions & 6 deletions docs/running_on_staging.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Running Subnet Locally

This tutorial will guide you through:
This document will guide you through:

- Setting up a local blockchain that is not connected to either Bittensor testchain or mainchain
- Creating a subnet
Expand Down Expand Up @@ -92,21 +92,21 @@ BUILD_BINARY=0 ./scripts/localnet.sh

**NOTE**: Watch for any build or initialization outputs in this step. If you are building the project for the first time, this step will take a while to finish building, depending on your hardware.

## 6. Install subnet template
## 6. Install web-genie-ai subnet

`cd` to your project directory and clone the bittensor subnet template repository:
`cd` to your project directory and clone the web-genie-ai repository:

```bash
git clone https://github.com/opentensor/bittensor-subnet-template.git
git clone https://github.com/web-genie-ai/web-genie-ai.git
```

Navigate to the cloned repository:

```bash
cd bittensor-subnet-template
cd web-genie-ai
```

Install the bittensor-subnet-template Python package:
Install the web-genie-ai Python package:

```bash
python -m pip install -e .
Expand Down
24 changes: 12 additions & 12 deletions docs/running_on_testnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,23 @@ Before proceeding further, make sure that you have installed Bittensor. See the

After installing `bittensor`, proceed as below:

## 1. Install Bittensor subnet template
## 1. Install web-genie-ai

**NOTE: Skip this step if** you already did this during local testing and development.

`cd` into your project directory and clone the bittensor-subnet-template repo:
`cd` into your project directory and clone the web-genie-ai repo:

```bash
git clone https://github.com/opentensor/bittensor-subnet-template.git
git clone https://github.com/web-genie-ai/web-genie-ai.git
```

Next, `cd` into bittensor-subnet-template repo directory:
Next, `cd` into web-genie-ai repo directory:

```bash
cd bittensor-subnet-template # Enter the
cd web-genie-ai # Enter the
```

Install the bittensor-subnet-template package:
Install the web-genie-ai package:

```bash
python -m pip install -e .
Expand Down Expand Up @@ -129,13 +129,13 @@ This step registers your subnet validator and subnet miner keys to the subnet, g
Register your miner key to the subnet:

```bash
btcli subnet register --netuid 13 --subtensor.network test --wallet.name miner --wallet.hotkey default
btcli subnet register --netuid 214 --subtensor.network test --wallet.name miner --wallet.hotkey default
```

Follow the below prompts:

```bash
>> Enter netuid [1] (1): # Enter netuid 1 to specify the subnet you just created.
>> Enter netuid [1] (1): # Enter netuid 214 to specify web-genie-ai test subnet.
>> Continue Registration?
hotkey: ...
coldkey: ...
Expand All @@ -146,13 +146,13 @@ Follow the below prompts:
Next, register your validator key to the subnet:

```bash
btcli subnet register --netuid 13 --subtensor.network test --wallet.name validator --wallet.hotkey default
btcli subnet register --netuid 214 --subtensor.network test --wallet.name validator --wallet.hotkey default
```

Follow the prompts:

```bash
>> Enter netuid [1] (1): # Enter netuid 1 to specify the subnet you just created.
>> Enter netuid [1] (1): # Enter netuid 214 to specify web-genie-ai test subnet.
>> Continue Registration?
hotkey: ...
coldkey: ...
Expand Down Expand Up @@ -201,7 +201,7 @@ miner default 1 True 0.00000 0.00000 0.00000 0.00000 0.00000
Run the subnet miner:

```bash
python neurons/miner.py --netuid 1 --subtensor.network test --wallet.name miner --wallet.hotkey default --logging.debug
python neurons/miner.py --netuid 214 --subtensor.network test --wallet.name miner --wallet.hotkey default --logging.debug
```

You will see the below terminal output:
Expand All @@ -213,7 +213,7 @@ You will see the below terminal output:
Next, run the subnet validator:

```bash
python neurons/validator.py --netuid 1 --subtensor.network test --wallet.name validator --wallet.hotkey default --logging.debug
python neurons/validator.py --netuid 214 --subtensor.network test --wallet.name validator --wallet.hotkey default --logging.debug
```

You will see the below terminal output:
Expand Down
2 changes: 1 addition & 1 deletion docs/stream_tutorial/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"""
This has assumed you have:
1. Registered your miner on the chain (finney/test)
2. Are serving your miner on an open port (e.g. 12345)
2. Are serving your miner on an open(e.g. 12345)

Steps:
- Instantiate your synapse subclass with the relevant information. E.g. messages, roles, etc.
Expand Down
Binary file added docs/webgenie-workflow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions min_compute.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ compute_spec:

gpu:
required: True # Does the application require a GPU?
min_vram: 8 # Minimum GPU VRAM (GB)
recommended_vram: 24 # Recommended GPU VRAM (GB)
min_vram: 80 # Minimum GPU VRAM (GB)
recommended_vram: 100 # Recommended GPU VRAM (GB)
cuda_cores: 1024 # Minimum number of CUDA cores (if applicable)
min_compute_capability: 6.0 # Minimum CUDA compute capability
recommended_compute_capability: 7.0 # Recommended CUDA compute capability
Expand All @@ -71,8 +71,8 @@ compute_spec:
ram_type: "DDR4" # RAM type (e.g., DDR4, DDR3, etc.)

storage:
min_space: 10 # Minimum free storage space (GB)
recommended_space: 100 # Recommended free storage space (GB)
min_space: 500 # Minimum free storage space (GB)
recommended_space: 1000 # Recommended free storage space (GB)
type: "SSD" # Preferred storage type (e.g., SSD, HDD)
min_iops: 1000 # Minimum I/O operations per second (if applicable)
recommended_iops: 5000 # Recommended I/O operations per second
Expand Down
49 changes: 49 additions & 0 deletions neurons/miners/hf_miner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import bittensor as bt
import os

from webgenie.base.neuron import BaseNeuron
from webgenie.protocol import WebgenieTextSynapse, WebgenieImageSynapse
from webgenie.helpers.images import base64_to_image

from webgenie.utils.gpus import get_gpu_info
total_memory_mb, _, _ = get_gpu_info()

if total_memory_mb is None:
raise ValueError("No GPU detected. HfMiner requires a GPU.")

bt.logging.info(f"Total memory: {total_memory_mb}")

if total_memory_mb < 1024 * 23:
raise ValueError("Insufficient GPU memory. HfMiner requires at least 25GB of GPU memory.")

from neurons.miners.hf_models.websight_finetuned import generate_html_from_image

if total_memory_mb > 1024 * 50:
from neurons.miners.hf_models.falcon7b import generate_html_from_text

class HfMiner:
def __init__(self, neuron: BaseNeuron):
self.neuron = neuron

async def forward_text(self, synapse: WebgenieTextSynapse) -> WebgenieTextSynapse:
try:
if total_memory_mb > 1024 * 50:
synapse.html = generate_html_from_text(synapse.prompt)
else:
synapse.html = "you don't have enough memory to generate html from text"
return synapse
except Exception as e:
bt.logging.error(f"Error in HfMiner forward_text: {e}")
synapse.html = f"Error in HfMiner forward_text: {e}"
return synapse

async def forward_image(self, synapse: WebgenieImageSynapse) -> WebgenieImageSynapse:
try:
bt.logging.debug(f"Generating HTML from image")
synapse.html = generate_html_from_image(base64_to_image(synapse.base64_image))
bt.logging.debug(f"Generated HTML: {synapse.html}")
return synapse
except Exception as e:
bt.logging.error(f"Error in OpenaiMiner forward_image: {e}")
synapse.html = f"Error in OpenaiMiner forward_image: {e}"
return synapse
Loading