Skip to content

Commit

Permalink
Allow Gradio cookbook to open with VS Code extension
Browse files Browse the repository at this point in the history
I changed the model parser path, this now works for the `huggingface.aiconfig.json` with VSCode extension

## Test Plan

To edit from local editor, do this:

Go to `aiconfig/python/src/aiconfig/editor/client` and run this command:
```
rm -rf node_modules && yarn && yarn build
```

Then go to `aiconfig` dir and run this command:
```
aiconfig_path=./cookbooks/Gradio/huggingface.aiconfig.json
parsers_path=./cookbooks/Gradio/aiconfig_model_registry.py
aiconfig edit --aiconfig-path=$aiconfig_path --server-port=8080 --server-mode=debug_servers --parsers-module-path=$parsers_path
```

<img width="1512" alt="Screenshot 2024-01-31 at 13 57 13" src="https://github.com/lastmile-ai/aiconfig/assets/151060367/5ec2a92f-4750-4f2d-b2a1-fc407849a252">
  • Loading branch information
Rossdan Craig [email protected] committed Jan 31, 2024
1 parent e34a1bd commit 1d7e82d
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 21 deletions.
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,4 @@
"black-formatter.args": ["--line-length=79"],
// example: "--disable=C0114,C0115,C0116"
"pylint.args": [],
"vscode-aiconfig.modelRegistryPath": "/Users/rossdancraig/Projects/aiconfig/cookbooks/Claude-And-Azure/aiconfig_model_registry.py"
}
12 changes: 7 additions & 5 deletions cookbooks/Gradio/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,16 @@ We are working on using `sveltris` to package our React frontend to work with Gr

- `pip3 install -r requirements.txt`

- Install `python-aiconfig-test` package from `test-pypi`:
Go to `aiconfig/python/src/aiconfig/editor/client` and run this command:

```
pip3 install --index-url https://test.pypi.org/simple --extra-index-url https://pypi.org/simple python-aiconfig-test==1.1.38 --force
```bash
rm -rf node_modules && yarn && yarn build

This comment has been minimized.

Copy link
@rholinshead

rholinshead Feb 1, 2024

Contributor

@rossdanlm why is this needed? It shouldn't be needed since the published aiconfig editor can use the parsers here, right? This build command is specifically for the client js code and unrelated to the extension

```

Now run this command to start the AIConfig editor:
Now run go back to top-level directory (`cd <aiconfig>`) and run this command to start the AIConfig editor:

```bash
aiconfig edit --aiconfig-path=huggingface.aiconfig.json --parsers-module-path=hf_model_parsers.py
aiconfig_path=./cookbooks/Gradio/huggingface.aiconfig.json
parsers_path=./cookbooks/Gradio/aiconfig_model_registry.py
aiconfig edit --aiconfig-path=$aiconfig_path --parsers-module-path=$parsers_path
```
File renamed without changes.
29 changes: 16 additions & 13 deletions cookbooks/Gradio/huggingface.aiconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "The Tale of the Quick Brown Fox",
"schema_version": "latest",
"metadata": {
"parameters": {},
"models": {
"stevhliu/my_awesome_billsum_model": {
"model": "stevhliu/my_awesome_billsum_model",
Expand Down Expand Up @@ -47,19 +48,20 @@
"max_new_tokens": 10,
"model": "Salesforce/blip-image-captioning-base"
}
},
"parameters": {}
}
},
"outputs": [
{
"output_type": "execute_result",
"execution_count": 0,
"data": "a red fox in the woods"
"data": "a red fox in the woods",
"metadata": {}
},
{
"output_type": "execute_result",
"execution_count": 1,
"data": "a bear sitting on a rock eating honey"
"data": "a bear sitting on a rock eating honey",
"metadata": {}
}
]
},
Expand All @@ -82,6 +84,7 @@
"output_type": "execute_result",
"execution_count": 0,
"data": " Il \u00e9tait une fois, dans une for\u00eat luxuriante et vibrante, vivait une magnifique cr\u00e9ature connue sous le nom de Foxe Brun. Ce renard \u00e9tait diff\u00e9rent des autres, poss\u00e9dant une vitesse et une agilit\u00e9 incroyables qui amenaient tous les animaux dans la for\u00eat. Avec sa fourrure aussi dor\u00e9e que le soleil et ses yeux aussi aiguis\u00e9s que les \u00e9meraudes, le Foxe Brun Brun \u00e9tait admir\u00e9 par tout le monde, du plus petit colibri au",
"metadata": {}
}
]
},
Expand All @@ -106,7 +109,8 @@
{
"output_type": "execute_result",
"execution_count": 0,
"data": " Racontez l'histoire du renard brun rapide. - C'est \u00e7a. - C'est \u00e7a. - C'est \u00e7a. - C'est \u00e7a. - C'est \u00e7a. - C'est \u00e7a. - C'est \u00e7a."
"data": " Racontez l'histoire du renard brun rapide. - C'est \u00e7a. - C'est \u00e7a. - C'est \u00e7a. - C'est \u00e7a. - C'est \u00e7a. - C'est \u00e7a. - C'est \u00e7a.",
"metadata": {}
}
]
},
Expand All @@ -122,14 +126,14 @@
"model": "facebook/bart-large-cnn",
"num_beams": 1
}
},
"parameters": {}
}
},
"outputs": [
{
"output_type": "execute_result",
"execution_count": 0,
"data": "The Quick Brown Fox was a magnificent creature. It had a kind heart and would often lend a helping paw to those in need. It loved to test its skills against others, always seeking new adventures. One day it got very old and died."
"data": "The Quick Brown Fox was a magnificent creature. It had a kind heart and would often lend a helping paw to those in need. It loved to test its skills against others, always seeking new adventures. One day it got very old and died.",
"metadata": {}
}
]
},
Expand All @@ -145,8 +149,7 @@
"min_length": 50,
"num_beams": 1
}
},
"parameters": {}
}
},
"outputs": [
{
Expand All @@ -171,8 +174,7 @@
"model": "runwayml/stable-diffusion-v1-5",
"num_images_per_prompt": 2
}
},
"parameters": {}
}
},
"outputs": [
{
Expand Down Expand Up @@ -226,7 +228,8 @@
{
"output_type": "execute_result",
"execution_count": 0,
"data": " Hi."
"data": " Hi.",
"metadata": {}
}
]
}
Expand Down
4 changes: 2 additions & 2 deletions cookbooks/Gradio/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# AIConfig
python-aiconfig >= 1.1.12
python-aiconfig >= 1.1.19

# Hugging Face Extension for AIConfig
aiconfig-extension-hugging-face >= 0.0.3
aiconfig-extension-hugging-face >= 0.0.6

0 comments on commit 1d7e82d

Please sign in to comment.