Download example_usage.py from zeechimp/solver-assistant-v3: direct link, hf CLI and curl.
- Browser
- Download file 1.3 kB
-
https://huggingface.co/zeechimp/solver-assistant-v3/resolve/main/example_usage.py
- Command line
-
hf download hf://zeechimp/solver-assistant-v3/example_usage.py
-
curl -L -o example_usage.py https://huggingface.co/zeechimp/solver-assistant-v3/resolve/main/example_usage.py
1.3 kB
| #!/usr/bin/env python3 | |
| """ | |
| example_usage.py | |
| Minimal examples showing both interfaces: natural language and JSON. | |
| Run: python3 example_usage.py | |
| """ | |
| from solver_assistant_v3 import dispatch, dispatch_from_json | |
| def main(): | |
| print("=" * 70) | |
| print("Natural language interface") | |
| print("=" * 70) | |
| nl_examples = [ | |
| "max cut on A-B:3, B-C:5, C-A:2", | |
| "sat (x1 or -x2 or x3) and (x2 or x3)", | |
| "subset sum [3, 7, 1, 8, 2, 11] target 15", | |
| "tsp (0,0) (10,0) (10,10) (0,10) (5,5)", | |
| ] | |
| for text in nl_examples: | |
| print() | |
| print(f"> {text}") | |
| dispatch(text, verbose=True) | |
| print() | |
| print("=" * 70) | |
| print("JSON schema interface") | |
| print("=" * 70) | |
| json_examples = [ | |
| {"type": "maxcut", "edges": [["A", "B", 3], ["B", "C", 5], | |
| ["C", "A", 2]]}, | |
| {"type": "sat", "n_vars": 3, "clauses": [[1, -2, 3], [2, 3]]}, | |
| {"type": "subset_sum", "numbers": [3, 7, 1, 8, 2, 11], "target": 15}, | |
| {"type": "tsp", "points": [[0, 0], [10, 0], [10, 10], [0, 10], | |
| [5, 5]]}, | |
| ] | |
| for schema in json_examples: | |
| print() | |
| print(f"> {schema}") | |
| dispatch_from_json(schema, verbose=True) | |
| if __name__ == "__main__": | |
| main() |