Spaces:
Running
Running
Download config.py from codeninja3d/minigpt-multi: direct link, hf CLI and curl.
- Browser
- Download file 3.24 kB
-
https://huggingface.co/spaces/codeninja3d/minigpt-multi/resolve/main/config.py
- Command line
-
hf download hf://spaces/codeninja3d/minigpt-multi/config.py
-
curl -L -o config.py https://huggingface.co/spaces/codeninja3d/minigpt-multi/resolve/main/config.py
3.24 kB
| from dataclasses import dataclass | |
| class GenCfg: | |
| max_a: int = 200 | |
| max_qty: int = 15 | |
| allow_decimals: bool = True | |
| eos: str = "<EOS>" | |
| CFG = GenCfg() | |
| ITEMS = ["apple","mango","banana","orange","pear","kiwi","pen","notebook","ticket","cookie","product"] | |
| ASKS = [ | |
| "how much is {n} {item_plural}?", | |
| "what's the cost of {n} {item_plural}?", | |
| "price for {n} {item_plural}?", | |
| "how much would {n} {item_plural} cost?", | |
| "what do I pay for {n} {item_plural}?", | |
| "total price of {n} {item_plural}?", | |
| "what's {n} {item_plural} going to cost?" | |
| ] | |
| COPULA = ["is", "costs", "priced at", "= ", "comes to", "sells for"] | |
| def s(x: int, word: str): return word if x == 1 else (word + "s") | |
| def money(v: float) -> str: | |
| import math | |
| if abs(v - round(v)) < 1e-9: | |
| return str(int(round(v))) | |
| return f"{v:.2f}" | |
| # currencies | |
| CURRENCIES = [ | |
| {"prefix":"$", "name_sing":"dollar", "name_plur":"dollars"}, | |
| {"prefix":"£", "name_sing":"pound", "name_plur":"pounds"}, | |
| {"prefix":"€", "name_sing":"euro", "name_plur":"euros"}, | |
| {"prefix":"₹", "name_sing":"rupee", "name_plur":"rupees"}, | |
| {"prefix":"¥", "name_sing":"yen", "name_plur":"yen"}, | |
| {"prefix":"₩", "name_sing":"won", "name_plur":"won"}, | |
| {"prefix":"₦", "name_sing":"naira", "name_plur":"naira"}, | |
| {"prefix":"A$", "name_sing":"dollar", "name_plur":"dollars"}, | |
| {"prefix":"C$", "name_sing":"dollar", "name_plur":"dollars"}, | |
| {"prefix":"CHF","name_sing":"franc", "name_plur":"francs"}, | |
| {"prefix":"د.إ","name_sing":"dirham", "name_plur":"dirhams"}, | |
| {"prefix":"", "name_sing":"dollar", "name_plur":"dollars"}, | |
| {"prefix":"", "name_sing":"pound", "name_plur":"pounds"}, | |
| {"prefix":"", "name_sing":"rupee", "name_plur":"rupees"}, | |
| {"prefix":"", "name_sing":"euro", "name_plur":"euros"} | |
| ] | |
| EXTRA_CURRENCY_WORDS = [ | |
| ("peso","pesos"), ("dinar","dinars"), ("dirham","dirhams"), ("riyal","riyals"), | |
| ("rial","rials"), ("krona","kronor"), ("krone","kroner"), ("koruna","koruny"), | |
| ("rand","rand"), ("shekel","shekels"), ("lira","lire"), ("ruble","rubles"), | |
| ("rouble","roubles"), ("yuan","yuan"), ("renminbi","renminbi"), ("ringgit","ringgit"), | |
| ("baht","baht"), ("dong","dong"), ("taka","taka"), ("rupiah","rupiah"), | |
| ("shilling","shillings"), ("kuna","kuna"), ("zloty","zlotys"), ("forint","forints"), | |
| ("leu","lei"), ("riel","riel"), ("kyat","kyat"), ("quetzal","quetzales"), | |
| ("bolivar","bolivares"), ("colon","colones"), ("sol","soles") | |
| ] | |
| SYNTHETIC_CURRENCY_WORDS = [ | |
| ("credit","credits"), ("token","tokens"), ("coin","coins"), ("unit","units"), | |
| ("galactic credit","galactic credits"), ("space buck","space bucks") | |
| ] | |
| WORD_POOL = [{"prefix":"", "name_sing":a, "name_plur":b} for (a,b) in (EXTRA_CURRENCY_WORDS + SYNTHETIC_CURRENCY_WORDS)] | |
| def cur_str(cur: dict, v: float) -> str: | |
| if cur["prefix"]: | |
| return f"{cur['prefix']}{money(v)}" | |
| name = cur["name_sing"] if abs(v - 1.0) < 1e-9 else cur["name_plur"] | |
| return f"{money(v)} {name}" | |
| import random | |
| def get_random_currency() -> dict: | |
| return random.choice(CURRENCIES) if random.random() < 0.7 else random.choice(WORD_POOL) | |
| PAD_TARGET = -100 | |