index
int64
0
731k
package
stringlengths
2
98
name
stringlengths
1
76
docstring
stringlengths
0
281k
code
stringlengths
4
8.19k
signature
stringlengths
2
42.8k
embed_func_code
listlengths
768
768
729,564
collections
_replace
Return a new TuyaMessage object replacing specified fields with new values
def namedtuple(typename, field_names, *, rename=False, defaults=None, module=None): """Returns a new subclass of tuple with named fields. >>> Point = namedtuple('Point', ['x', 'y']) >>> Point.__doc__ # docstring for the new class 'Point(x, y)' >>> p = Point(11, y=22) #...
(self, /, **kwds)
[ 0.0541859045624733, 0.0014151688665151596, -0.015421349555253983, -0.03568440303206444, -0.032841190695762634, -0.03333566337823868, 0.0027891318313777447, 0.021468330174684525, 0.021015064790844917, -0.04615073278546333, -0.04219495505094528, 0.05707032233476639, 0.004501756746321917, 0.0...
729,565
tinytuya.core
XenonDevice
null
class XenonDevice(object): def __init__( self, dev_id, address=None, local_key="", dev_type="default", connection_timeout=5, version=3.1, persist=False, cid=None, node_id=None, parent=None, connection_retry_limit=5, connection_retry_delay=5, port=TCPPORT # pylint: disable=W0621 ): """ ...
(dev_id, address=None, local_key='', dev_type='default', connection_timeout=5, version=3.1, persist=False, cid=None, node_id=None, parent=None, connection_retry_limit=5, connection_retry_delay=5, port=6668)
[ 0.027121014893054962, -0.05033116415143013, -0.022678779438138008, 0.03154199570417404, -0.00004591350443661213, -0.03995886072516441, -0.08272334933280945, 0.04744052141904831, -0.04569763317704201, -0.09777168184518814, -0.014315050095319748, 0.017513884231448174, 0.0064986287616193295, ...
729,602
tinytuya.core
appenddevice
null
def appenddevice(newdevice, devices): if newdevice["ip"] in devices: return True devices[newdevice["ip"]] = newdevice return False
(newdevice, devices)
[ 0.010829346254467964, -0.01377464085817337, -0.06788545101881027, 0.016261978074908257, -0.024711742997169495, -0.004388758912682533, -0.021856242790818214, 0.011933831498026848, 0.026920713484287262, -0.027531323954463005, -0.01725870929658413, -0.05908548831939697, 0.0025524392258375883, ...
729,603
tinytuya.core
assign_dp_mappings
Adds mappings to all the devices in the tuyadevices list Parameters: tuyadevices = list of devices mappings = dict containing the mappings Response: Nothing, modifies tuyadevices in place
def assign_dp_mappings( tuyadevices, mappings ): """ Adds mappings to all the devices in the tuyadevices list Parameters: tuyadevices = list of devices mappings = dict containing the mappings Response: Nothing, modifies tuyadevices in place """ if type(mappings) != dict: ...
(tuyadevices, mappings)
[ 0.04867133870720863, 0.01078788097947836, -0.050685327500104904, -0.01459207758307457, -0.043972037732601166, 0.018694642931222916, -0.023496508598327637, -0.03060140460729599, 0.0067972042597830296, 0.030265741050243378, -0.03875059261918068, 0.004163171164691448, -0.0024242429062724113, ...
729,605
tinytuya.core
bin2hex
null
def bin2hex(x, pretty=False): if pretty: space = " " else: space = "" if IS_PY2: result = "".join("%02X%s" % (ord(y), space) for y in x) else: result = "".join("%02X%s" % (y, space) for y in x) return result
(x, pretty=False)
[ -0.016537640243768692, 0.01622174307703972, 0.024759503081440926, -0.00900733657181263, 0.03630255535244942, -0.04402069002389908, -0.005365982186049223, 0.009630593471229076, 0.06840453296899796, -0.022881196811795235, 0.09507649391889572, 0.03362169861793518, 0.026569508016109467, -0.017...
729,608
tinytuya.core
decrypt
null
def decrypt(msg, key): return AESCipher( key ).decrypt( msg, use_base64=False, decode_text=True )
(msg, key)
[ 0.06981678307056427, -0.030133523046970367, 0.03970114141702652, 0.054365526884794235, -0.00046496832510456443, -0.05940864235162735, 0.0044395532459020615, 0.025465955957770348, 0.07403726130723953, 0.030240824446082115, 0.021102407947182655, 0.027969632297754288, -0.022139644250273705, 0...
729,609
tinytuya.core
decrypt_udp
null
def decrypt_udp(msg): try: header = parse_header(msg) except: header = None if not header: return decrypt(msg, udpkey) if header.prefix == PREFIX_55AA_VALUE: payload = unpack_message(msg).payload try: if payload[:1] == b'{' and payload[-1:] == b'}': ...
(msg)
[ 0.03800623491406441, 0.032130271196365356, -0.001140254084020853, -0.014314848929643631, -0.026343608275055885, -0.03982796147465706, 0.025772085413336754, 0.04943668097257614, 0.006425161380320787, -0.02921907976269722, -0.001214484916999936, 0.014493449591100216, -0.02311093360185623, 0....
729,610
tinytuya.core
deviceScan
Scans your network for Tuya devices and returns dictionary of devices discovered devices = tinytuya.deviceScan(verbose) Parameters: verbose = True or False, print formatted output to stdout [Default: False] maxretry = The number of loops to wait to pick up UDP from all devices color...
def deviceScan(verbose=False, maxretry=None, color=True, poll=True, forcescan=False, byID=False): """Scans your network for Tuya devices and returns dictionary of devices discovered devices = tinytuya.deviceScan(verbose) Parameters: verbose = True or False, print formatted output to stdout [Def...
(verbose=False, maxretry=None, color=True, poll=True, forcescan=False, byID=False)
[ 0.06054094806313515, -0.022680792957544327, -0.0008019910892471671, -0.0430317297577858, 0.025593113154172897, 0.016176613047719002, -0.04126668721437454, -0.0452909842133522, -0.021004002541303635, -0.03247677907347679, -0.024798844009637833, 0.009584179148077965, -0.002490915823727846, 0...
729,611
tinytuya.core
device_info
Searches the devices.json file for devices with ID = dev_id Parameters: dev_id = The specific Device ID you are looking for Response: {dict} containing the the device info, or None if not found
def device_info( dev_id ): """Searches the devices.json file for devices with ID = dev_id Parameters: dev_id = The specific Device ID you are looking for Response: {dict} containing the the device info, or None if not found """ devinfo = None try: # Load defaults ...
(dev_id)
[ 0.061090197414159775, -0.024954665452241898, 0.006229471415281296, -0.018288441002368927, 0.029110711067914963, -0.010242998600006104, 0.011134892702102661, -0.006450146436691284, -0.022380122914910316, -0.02480754815042019, -0.05446994677186012, -0.024917885661125183, -0.019382622092962265,...
729,612
tinytuya.core
encrypt
null
def encrypt(msg, key): return AESCipher( key ).encrypt( msg, use_base64=False, pad=True )
(msg, key)
[ 0.002321253763511777, -0.06916942447423935, 0.025675999000668526, 0.07603035867214203, 0.029719049111008644, -0.04585624858736992, -0.018079964444041252, 0.004817531444132328, 0.09024229645729065, 0.01836000196635723, 0.053802330046892166, -0.01273298542946577, 0.001334556844085455, 0.0517...
729,613
tinytuya.core
error_json
Return error details in JSON
def error_json(number=None, payload=None): """Return error details in JSON""" try: spayload = json.dumps(payload) # spayload = payload.replace('\"','').replace('\'','') except: spayload = '""' vals = (error_codes[number], str(number), spayload) log.debug("ERROR %s - %s - pay...
(number=None, payload=None)
[ -0.041698064655065536, -0.016370024532079697, 0.009876787662506104, 0.019665231928229332, -0.012686106376349926, -0.009355561807751656, -0.06752966344356537, -0.0030765573028475046, -0.007288326974958181, -0.08374950289726257, 0.06092157959938049, 0.04434836655855179, 0.027351103723049164, ...
729,614
tinytuya.core
find_device
Scans network for Tuya devices with either ID = dev_id or IP = address Parameters: dev_id = The specific Device ID you are looking for address = The IP address you are tring to find the Device ID for Response: {'ip':<ip>, 'version':<version>, 'id':<id>, 'product_id':<product_id>, 'data...
def find_device(dev_id=None, address=None): """Scans network for Tuya devices with either ID = dev_id or IP = address Parameters: dev_id = The specific Device ID you are looking for address = The IP address you are tring to find the Device ID for Response: {'ip':<ip>, 'version':<ve...
(dev_id=None, address=None)
[ 0.05377412214875221, -0.03381526097655296, -0.06525398790836334, -0.013342829421162605, -0.023000016808509827, -0.027310002595186234, -0.03607095405459404, -0.01196323148906231, -0.04048164188861847, -0.06646239757537842, -0.05542561039328575, -0.015417261980473995, -0.02624257653951645, 0...
729,615
tinytuya.core
has_suffix
Check to see if payload has valid Tuya suffix
def has_suffix(payload): """Check to see if payload has valid Tuya suffix""" if len(payload) < 4: return False log.debug("buffer %r = %r", payload[-4:], SUFFIX_BIN) return payload[-4:] == SUFFIX_BIN
(payload)
[ 0.00467224046587944, 0.013796699233353138, -0.011216828599572182, 0.02410755306482315, -0.01763630472123623, 0.006902663502842188, -0.012847582809627056, 0.06747353821992874, 0.017394712194800377, -0.0827629342675209, 0.05363369733095169, 0.05083811655640602, 0.007398792542517185, -0.05746...
729,616
tinytuya.core
hex2bin
null
def hex2bin(x): if IS_PY2: return x.decode("hex") else: return bytes.fromhex(x)
(x)
[ 0.009174341335892677, 0.010345346294343472, 0.00847437884658575, 0.007263753563165665, 0.021007655188441277, -0.029671333730220795, -0.008553620427846909, 0.07966356724500656, 0.02585015818476677, -0.041064418852329254, 0.0886089876294136, 0.0406770221889019, 0.004706032108515501, 0.001800...
729,622
tinytuya.core
pack_message
Pack a TuyaMessage into bytes.
def pack_message(msg, hmac_key=None): """Pack a TuyaMessage into bytes.""" if msg.prefix == PREFIX_55AA_VALUE: header_fmt = MESSAGE_HEADER_FMT_55AA end_fmt = MESSAGE_END_FMT_HMAC if hmac_key else MESSAGE_END_FMT_55AA msg_len = len(msg.payload) + struct.calcsize(end_fmt) header_da...
(msg, hmac_key=None)
[ -0.017398707568645477, -0.003759038867428899, -0.029345372691750526, -0.014060527086257935, -0.016250908374786377, -0.03426177427172661, -0.017389141023159027, 0.02825496345758438, -0.029307112097740173, -0.04939357936382294, 0.047097984701395035, 0.06025940179824829, -0.013477062806487083, ...
729,623
tinytuya.core
pad
null
def pad(s): return s + (16 - len(s) % 16) * chr(16 - len(s) % 16)
(s)
[ -0.03781580924987793, 0.040984537452459335, 0.028031056746840477, 0.050734471529722214, -0.011517108418047428, -0.011351707391440868, -0.007786888163536787, -0.00014758198813069612, 0.04993358626961708, 0.0018977548461407423, 0.03952204808592796, 0.03330646827816963, 0.03812920302152634, 0...
729,624
tinytuya.core
parse_header
null
def parse_header(data): if( data[:4] == PREFIX_6699_BIN ): fmt = MESSAGE_HEADER_FMT_6699 else: fmt = MESSAGE_HEADER_FMT_55AA header_len = struct.calcsize(fmt) if len(data) < header_len: raise DecodeError('Not enough data to unpack header') unpacked = struct.unpack( fmt, da...
(data)
[ -0.06376742571592331, 0.07711320370435715, -0.03349905088543892, -0.0363643541932106, -0.027922285720705986, -0.013499617576599121, 0.02742229960858822, 0.045306410640478134, -0.03407595679163933, -0.051344700157642365, 0.027845365926623344, 0.04676790535449982, -0.020595571026206017, 0.00...
729,625
tinytuya.core
scan
Scans your network for Tuya devices with output to stdout
def scan(maxretry=None, color=True, forcescan=False): """Scans your network for Tuya devices with output to stdout""" from . import scanner scanner.scan(scantime=maxretry, color=color, forcescan=forcescan)
(maxretry=None, color=True, forcescan=False)
[ 0.021504735574126244, -0.03920025750994682, 0.006012495141476393, -0.006808966863900423, 0.012769518420100212, 0.04134726896882057, -0.05672263354063034, -0.05409081652760506, -0.01927115209400654, -0.030439069494605064, 0.008873732760548592, 0.0431479848921299, 0.020413914695382118, 0.003...
729,627
tinytuya.core
set_debug
Enable tinytuya verbose logging
def set_debug(toggle=True, color=True): """Enable tinytuya verbose logging""" if toggle: if color: logging.basicConfig( format="\x1b[31;1m%(levelname)s:%(message)s\x1b[0m", level=logging.DEBUG ) else: logging.basicConfig(format="%(levelname)s:%...
(toggle=True, color=True)
[ 0.012692468240857124, -0.027477404102683067, 0.06971221417188644, 0.04511654004454613, 0.05069645494222641, -0.046181127429008484, -0.0656006932258606, 0.0009917424758896232, -0.03983030468225479, 0.003618225222453475, -0.035994116216897964, -0.030781300738453865, -0.011269957758486271, 0....
729,631
tinytuya.core
termcolor
null
def termcolor(color=True): if color is False: # Disable Terminal Color Formatting bold = subbold = normal = dim = alert = alertdim = cyan = red = yellow = "" else: # Terminal Color Formatting bold = "\033[0m\033[97m\033[1m" subbold = "\033[0m\033[32m" normal = "\0...
(color=True)
[ 0.004861247260123491, 0.01817113533616066, 0.008312826044857502, -0.0008886528667062521, 0.06290584802627563, -0.01685045100748539, -0.05608699098229408, -0.03298904001712799, 0.037784721702337265, 0.025964118540287018, 0.009249483235180378, -0.010668517090380192, 0.0014354260638356209, -0...
729,633
tinytuya.core
unpack_message
Unpack bytes into a TuyaMessage.
def unpack_message(data, hmac_key=None, header=None, no_retcode=False): """Unpack bytes into a TuyaMessage.""" if header is None: header = parse_header(data) if header.prefix == PREFIX_55AA_VALUE: # 4-word header plus return code header_len = struct.calcsize(MESSAGE_HEADER_FMT_55AA)...
(data, hmac_key=None, header=None, no_retcode=False)
[ 0.01750248111784458, 0.026754364371299744, -0.01108423713594675, -0.007134163286536932, -0.025552822276949883, -0.0421341210603714, 0.010333272628486156, 0.05230718478560448, -0.008380765095353127, -0.0434558168053627, 0.03294231370091438, 0.06924894452095032, -0.012045471929013729, -0.002...
729,634
tinytuya.core
unpad
null
def unpad(s): return s[: -ord(s[len(s) - 1 :])]
(s)
[ -0.044903554022312164, 0.10505086183547974, 0.024538308382034302, 0.025090118870139122, -0.03945442661643028, -0.0202445350587368, -0.0035156344529241323, 0.018813278526067734, 0.03890261799097061, -0.031660109758377075, -0.011820808984339237, 0.025090118870139122, -0.007863295264542103, 0...
729,635
avltree._avl_tree
AvlTree
Lightweight, pure-python AVL tree. This class implements the MutableMapping interface and can be used in almost every way that a built-in dictionary can. # Sorting The AVL tree data structure makes it possible to easily iterate on keys in sort-order, and any method which returns an iterable of key...
class AvlTree(MutableMapping[_K, _V]): """Lightweight, pure-python AVL tree. This class implements the MutableMapping interface and can be used in almost every way that a built-in dictionary can. # Sorting The AVL tree data structure makes it possible to easily iterate on keys in sort-order, a...
(mapping: 'Mapping[_K, _V] | None' = None) -> 'None'
[ 0.053404469043016434, -0.03112207166850567, -0.0495571494102478, 0.02448086440563202, 0.023656439036130905, 0.01165073923766613, -0.05367927625775337, -0.0006501656025648117, 0.031442683190107346, -0.06577085703611374, -0.0508853904902935, 0.007608762942254543, 0.048137303441762924, 0.0459...
729,636
avltree._avl_tree
__calculate_balance
Calculates the balance factor of the given node. Args: node (AvlTreeNode[_K, _V]): The node. Returns: int: The balance factor of the given node.
def __calculate_balance(self, node: AvlTreeNode[_K, _V]) -> int: """Calculates the balance factor of the given node. Args: node (AvlTreeNode[_K, _V]): The node. Returns: int: The balance factor of the given node. """ return ( -1 if node.greater_child_key is None ...
(self, node: avltree._avl_tree_node.AvlTreeNode[~_K, ~_V]) -> int
[ 0.030179355293512344, -0.04302047938108444, 0.045946307480335236, 0.06978636980056763, 0.006592139136046171, -0.034568093717098236, 0.004619012586772442, 0.03404433652758598, -0.0150806475430727, -0.0481497086584568, -0.010032693855464458, 0.024995947256684303, 0.053278934210538864, -0.012...
729,637
avltree._avl_tree
__enforce_avl
Enforces the AVL property on this tree. Args: stack (list[_K]): The stack to traverse in reverse order.
def __enforce_avl(self, stack: list[_K]) -> None: """Enforces the AVL property on this tree. Args: stack (list[_K]): The stack to traverse in reverse order. """ while len(stack) > 0: key: _K = stack.pop(-1) node: AvlTreeNode[_K, _V] = self.__nodes[key] balance: int = self...
(self, stack: list[~_K]) -> NoneType
[ 0.02208845131099224, 0.02593611739575863, -0.06145577132701874, 0.06220392882823944, 0.03744348883628845, -0.024404175579547882, -0.0262389425188303, -0.03658844903111458, 0.008750767447054386, -0.02536609210073948, -0.007521652150899172, 0.005143580958247185, 0.04481818154454231, -0.02477...
729,638
avltree._avl_tree
__get_closer_key
Gets the next closest key to the given key. Args: key (_K): The key to search for. current_key (_K): The current key. Returns: _K: The next closest key to the given key. Raises: KeyError: If the given key is not present in this tree.
def __get_closer_key(self, key: _K, current_key: _K) -> _K: """Gets the next closest key to the given key. Args: key (_K): The key to search for. current_key (_K): The current key. Returns: _K: The next closest key to the given key. Raises: KeyError: If the given key is n...
(self, key: ~_K, current_key: ~_K) -> ~_K
[ 0.06842037290334702, -0.03576922044157982, -0.06508971005678177, 0.06785345077514648, -0.010505769401788712, 0.011329577304422855, 0.03421018645167351, -0.0014361280482262373, 0.04623955860733986, -0.02997598983347416, -0.04868440702557564, -0.05956222116947174, 0.05304262042045593, -0.003...
729,639
avltree._avl_tree
__rotate
Performs a rotation at the given key. Args: key (_K): The key to perform a right rotation on. direction (Literal["left", "right"]): The direction of the rotation. Returns: _K: The new root key of this subtree. Raises: ValueError: If the shape of...
def __rotate(self, key: _K, direction: Literal["left", "right"]) -> _K: """Performs a rotation at the given key. Args: key (_K): The key to perform a right rotation on. direction (Literal["left", "right"]): The direction of the rotation. Returns: _K: The new root key of this subtree....
(self, key: ~_K, direction: Literal['left', 'right']) -> ~_K
[ 0.050574298948049545, 0.007131932303309441, 0.02840377204120159, 0.0688844621181488, 0.030705824494361877, -0.006999121513217688, -0.03472556173801422, 0.043809808790683746, 0.044943127781152725, -0.04005569592118263, 0.01885911263525486, 0.02208198606967926, 0.06548450887203217, 0.0435264...
729,640
avltree._avl_tree
__update_height
Updates the height of the given node. Args: node (AvlTreeNode[_K, _V]): The node.
def __update_height(self, node: AvlTreeNode[_K, _V]) -> None: """Updates the height of the given node. Args: node (AvlTreeNode[_K, _V]): The node. """ node.height = 1 + max( ( -1 if node.greater_child_key is None else self.__nodes[node.greater_child_ke...
(self, node: avltree._avl_tree_node.AvlTreeNode[~_K, ~_V]) -> NoneType
[ 0.05324268341064453, -0.023579925298690796, 0.02232757769525051, 0.05653456971049309, -0.03957419842481613, -0.010394489392638206, -0.028177831321954727, 0.03118346631526947, -0.023293673992156982, -0.020431164652109146, -0.024420786648988724, -0.03567402809858322, 0.04991501569747925, 0.0...
729,642
avltree._avl_tree
__delitem__
Deletes the given key from this tree. This method has an amortized and worst-case time complexity of O[log(n)]. Example usage: ``` >>> from avltree import AvlTree >>> avl_tree = AvlTree[int, str]({0: 'a', 1: 'b'}) >>> del avl_tree[0] >>> avl_tree AvlTree...
def __delitem__(self, __k: _K) -> None: # noqa: C901, PLR0912 """Deletes the given key from this tree. This method has an amortized and worst-case time complexity of O[log(n)]. Example usage: ``` >>> from avltree import AvlTree >>> avl_tree = AvlTree[int, str]({0: 'a', 1: 'b'}) >>> del avl_...
(self, _AvlTree__k: ~_K) -> NoneType
[ 0.05854947865009308, -0.01511321309953928, -0.04928086698055267, 0.008989309892058372, -0.00970824807882309, -0.010592697188258171, -0.042991455644369125, 0.04007432609796524, 0.0547427274286747, -0.04870158061385155, -0.02768169716000557, -0.009940997697412968, 0.03597792983055115, 0.0136...
729,644
avltree._avl_tree
__getitem__
Gets the value associated with the given key. This method has an amortized and worst-case time complexity of O[log(n)]. Example usage: ``` >>> from avltree import AvlTree >>> avl_tree = AvlTree[int, str]({0: 'a', 1: 'b'}) >>> avl_tree[0] 'a' >>> avl_tree...
def __getitem__(self, __k: _K) -> _V: """Gets the value associated with the given key. This method has an amortized and worst-case time complexity of O[log(n)]. Example usage: ``` >>> from avltree import AvlTree >>> avl_tree = AvlTree[int, str]({0: 'a', 1: 'b'}) >>> avl_tree[0] 'a' >...
(self, _AvlTree__k: ~_K) -> ~_V
[ 0.07337706536054611, -0.05779154598712921, -0.06947120279073715, 0.04979022219777107, 0.059990961104631424, 0.021577028557658195, 0.0063090999610722065, -0.04497426003217697, 0.08410869538784027, -0.062076617032289505, -0.059422146528959274, -0.010039574466645718, 0.050852011889219284, -0....
729,645
avltree._avl_tree
__init__
Constructor. Inserting the elements of a passed-in mapping has an amortized and worst-case time complexity of O[n*log(n)]. Example usage: ``` >>> from avltree import AvlTree >>> avl_tree = AvlTree[int, str]({0: 'a', 1: 'b'}) >>> avl_tree AvlTree({0: 'a',...
def __init__(self, mapping: Mapping[_K, _V] | None = None) -> None: """Constructor. Inserting the elements of a passed-in mapping has an amortized and worst-case time complexity of O[n*log(n)]. Example usage: ``` >>> from avltree import AvlTree >>> avl_tree = AvlTree[int, str]({0: 'a', 1: 'b...
(self, mapping: Optional[Mapping[~_K, ~_V]] = None) -> NoneType
[ 0.006278782617300749, -0.0005788328126072884, -0.00121075299102813, 0.0007329670479521155, 0.010723640210926533, 0.03928462043404579, -0.016708029434084892, -0.0023672122042626143, 0.005067426711320877, -0.048338424414396286, -0.03826148435473442, 0.04335786774754524, 0.014111576601862907, ...
729,646
avltree._avl_tree
__iter__
Iterates over all keys contained in this tree in sort order. Getting the first key has an amortized and worst-case time complexity of O[log(n)]. Iterating over all keys has an amortized and worst-case time complexity of O[n]. Example usage: ``` >>> from avltree import A...
def __iter__(self) -> Iterator[_K]: """Iterates over all keys contained in this tree in sort order. Getting the first key has an amortized and worst-case time complexity of O[log(n)]. Iterating over all keys has an amortized and worst-case time complexity of O[n]. Example usage: ``` >>> from...
(self) -> Iterator[~_K]
[ 0.01625014655292034, -0.007285820320248604, -0.07769082486629486, -0.0032601740676909685, 0.039361875504255295, 0.016277814283967018, -0.008291078731417656, -0.02209724672138691, 0.0733746662735939, -0.046592358499765396, -0.028239469975233078, -0.011537418700754642, 0.012902357615530491, ...
729,647
avltree._avl_tree
__len__
Returns the number of items contained in this tree. This method has an amortized and worst-case time complexity of O[1]. Example usage: ``` >>> from avltree import AvlTree >>> avl_tree = AvlTree[int, str]({0: 'a', 1: 'b'}) >>> len(avl_tree) 2 ``` ...
def __len__(self) -> int: """Returns the number of items contained in this tree. This method has an amortized and worst-case time complexity of O[1]. Example usage: ``` >>> from avltree import AvlTree >>> avl_tree = AvlTree[int, str]({0: 'a', 1: 'b'}) >>> len(avl_tree) 2 ``` Retu...
(self) -> int
[ -0.043786048889160156, -0.026344604790210724, 0.008355837315320969, 0.01251551229506731, 0.03050428070127964, 0.06068016588687897, -0.026964908465743065, -0.036087002605199814, 0.0323469415307045, -0.029920466244220734, -0.012086773291230202, -0.02601620927453041, 0.022330883890390396, 0.0...
729,648
avltree._avl_tree
__repr__
Builds a developer-friendly string representation of this AvlTree. Example usage: ``` >>> from avltree import AvlTree >>> avl_tree = AvlTree[int, str]({0: 'a', 1: 'b'}) >>> repr(avl_tree) "AvlTree({0: 'a', 1: 'b'})" ``` Returns: str: A string...
def __repr__(self) -> str: """Builds a developer-friendly string representation of this AvlTree. Example usage: ``` >>> from avltree import AvlTree >>> avl_tree = AvlTree[int, str]({0: 'a', 1: 'b'}) >>> repr(avl_tree) "AvlTree({0: 'a', 1: 'b'})" ``` Returns: str: A string rep...
(self) -> str
[ 0.034442782402038574, -0.030415276065468788, 0.06478206813335419, -0.022664224728941917, 0.035829611122608185, -0.042706768959760666, -0.01884569227695465, -0.05927274376153946, 0.029009448364377022, -0.046962250024080276, -0.039211198687553406, -0.0017074159113690257, -0.008221243508160114,...
729,649
avltree._avl_tree
__setitem__
Maps the given key to the given value in this tree. This method has an amortized and worst-case time complexity of O[log(n)]. Example usage: ``` >>> from avltree import AvlTree >>> avl_tree = AvlTree[int, str]({0: 'a', 1: 'b'}) >>> avl_tree[0] = 'foo' >>> avl_tr...
def __setitem__(self, __k: _K, __v: _V) -> None: """Maps the given key to the given value in this tree. This method has an amortized and worst-case time complexity of O[log(n)]. Example usage: ``` >>> from avltree import AvlTree >>> avl_tree = AvlTree[int, str]({0: 'a', 1: 'b'}) >>> avl_tree...
(self, _AvlTree__k: ~_K, _AvlTree__v: ~_V) -> NoneType
[ 0.05582147464156151, -0.008941666223108768, -0.0482550784945488, 0.04234865680336952, 0.039086613804101944, 0.03223439306020737, -0.026366574689745903, -0.0272158645093441, -0.00037669119774363935, -0.052385713905096054, -0.0374845452606678, -0.011368895880877972, 0.05887119472026825, 0.02...
729,650
avltree._avl_tree
between
Iterates over all keys between the given start and stop in sort order. Getting the first key has an amortized and worst-case time complexity of O[log(n)]. Iterating over all keys has an amortized and worst-case time complexity of O[k], where k is the number of items in only the interval between...
def between( # noqa: C901, PLR0912 self, start: _K | None = None, stop: _K | None = None, treatment: Literal["inclusive", "exclusive"] = "inclusive", ) -> Iterator[_K]: """Iterates over all keys between the given start and stop in sort order. Getting the first key has an amortized and worst-cas...
(self, start: Optional[~_K] = None, stop: Optional[~_K] = None, treatment: Literal['inclusive', 'exclusive'] = 'inclusive') -> Iterator[~_K]
[ 0.03893772512674332, 0.0026554346550256014, -0.07214687019586563, -0.016998931765556335, 0.012266629375517368, 0.03800371661782265, -0.010538715869188309, -0.016978176310658455, -0.012526075355708599, -0.06953164935112, -0.03266949951648712, 0.021668968722224236, 0.06529748439788818, 0.023...
729,655
avltree._avl_tree
maximum
Gets the maximum key contained in this tree. This method has an amortized and worst-case time complexity of O[log(n)]. Example usage: ``` >>> from avltree import AvlTree >>> avl_tree = AvlTree[int, str]({0: 'a', 1: 'b'}) >>> avl_tree.maximum() 1 ``` ...
def maximum(self) -> _K: """Gets the maximum key contained in this tree. This method has an amortized and worst-case time complexity of O[log(n)]. Example usage: ``` >>> from avltree import AvlTree >>> avl_tree = AvlTree[int, str]({0: 'a', 1: 'b'}) >>> avl_tree.maximum() 1 ``` Re...
(self) -> ~_K
[ 0.0841929167509079, 0.01955130323767662, -0.011482511647045612, 0.04403150826692581, 0.023421403020620346, -0.0032311677932739258, 0.006161124911159277, -0.025027858093380928, 0.045710984617471695, -0.06349153071641922, -0.029719442129135132, 0.0027679423801600933, 0.006832003127783537, -0...
729,656
avltree._avl_tree
minimum
Gets the minimum key contained in this tree. This method has an amortized and worst-case time complexity of O[log(n)]. Example usage: ``` >>> from avltree import AvlTree >>> avl_tree = AvlTree[int, str]({0: 'a', 1: 'b'}) >>> avl_tree.minimum() 0 ``` ...
def minimum(self) -> _K: """Gets the minimum key contained in this tree. This method has an amortized and worst-case time complexity of O[log(n)]. Example usage: ``` >>> from avltree import AvlTree >>> avl_tree = AvlTree[int, str]({0: 'a', 1: 'b'}) >>> avl_tree.minimum() 0 ``` Re...
(self) -> ~_K
[ 0.06188405677676201, 0.007775749545544386, 0.014675106853246689, 0.040564462542533875, 0.06825131922960281, 0.02173096314072609, 0.06635545194149017, -0.01724168471992016, 0.05501599982380867, -0.04392695054411888, -0.03625404089689255, -0.03852550685405731, 0.0267746914178133, -0.00444903...
729,665
allpairspy.allpairs
AllPairs
null
class AllPairs: def __init__(self, parameters, filter_func=lambda x: True, previously_tested=None, n=2): """ TODO: check that input arrays are: - (optional) has no duplicated values inside single array / or compress such values """ if not previously_tested: p...
(parameters, filter_func=<function AllPairs.<lambda> at 0x7f625a34cca0>, previously_tested=None, n=2)
[ 0.06454934924840927, -0.0011813208693638444, -0.1150873601436615, 0.013100196607410908, 0.0013958188937976956, -0.04887770488858223, -0.05665278434753418, -0.02318350225687027, 0.03195071220397949, -0.02917679026722908, -0.039908017963171005, 0.03101932257413864, -0.0038900701329112053, 0....
729,666
allpairspy.allpairs
__extract_param_name_list
null
def __extract_param_name_list(self, parameters): if not self.__is_ordered_dict_param: return [] return list(parameters)
(self, parameters)
[ 0.020596181973814964, 0.04070114344358444, -0.013491025194525719, -0.05024486035108566, 0.007956020534038544, 0.02440314181149006, 0.007631464395672083, -0.010534930042922497, 0.0711568295955658, 0.015464680269360542, -0.008618291467428207, -0.03957835212349892, -0.04277128726243973, -0.04...
729,667
allpairspy.allpairs
__extract_value_matrix
null
def __extract_value_matrix(self, parameters): if not self.__is_ordered_dict_param: return parameters return [v for v in parameters.values()]
(self, parameters)
[ 0.07692839205265045, 0.017264002934098244, 0.0034161144867539406, -0.04647469520568848, 0.01014260109513998, 0.00022996190818957984, -0.014622610062360764, -0.002995304297655821, 0.06128720939159393, 0.06253021955490112, -0.03290518745779991, 0.03440715745091438, -0.03725571557879448, -0.0...
729,668
allpairspy.allpairs
__get_iteration_value
null
def __get_iteration_value(self, item_list): if not self.__param_name_list: return [item.value for item in item_list] return self.__pairs_class(*[item.value for item in item_list])
(self, item_list)
[ 0.07912025600671768, -0.037362340837717056, -0.06806043535470963, -0.013957706280052662, 0.0005799094797112048, 0.0006746224826201797, 0.026249349117279053, -0.021056197583675385, 0.09819135814905167, 0.012717021629214287, 0.0078163156285882, 0.03286042809486389, 0.012504332698881626, 0.00...
729,669
allpairspy.allpairs
__get_values
null
@staticmethod def __get_values(item_list): return [item.value for item in item_list]
(item_list)
[ 0.06310777366161346, -0.0922045186161995, -0.07254742085933685, -0.02674567513167858, -0.00929823238402605, 0.00833924114704132, 0.02107127755880356, -0.05253677815198898, 0.1138414740562439, 0.00891817081719637, -0.009377779439091682, 0.042354684323072433, 0.02361680194735527, -0.01302813...
729,670
allpairspy.allpairs
__get_working_item_matrix
null
def __get_working_item_matrix(self, parameter_matrix): return [ [ Item(f"a{param_idx:d}v{value_idx:d}", value) for value_idx, value in enumerate(value_list) ] for param_idx, value_list in enumerate(parameter_matrix) ]
(self, parameter_matrix)
[ 0.07411634176969528, -0.04497181624174118, -0.041102148592472076, -0.0069287968799471855, -0.010214528068900108, -0.029806900769472122, -0.005303362384438515, -0.0042771161533892155, 0.05030568316578865, 0.05567441135644913, -0.025658337399363518, 0.04929468780755997, -0.03688386082649231, ...
729,671
allpairspy.allpairs
__resort_working_array
null
def __resort_working_array(self, chosen_item_list, num): for item in self.__working_item_matrix[num]: data_node = self.__pairs.get_node_info(item) new_combs = [ # numbers of new combinations to be created if this item is # appended to array {key(z) for z in combin...
(self, chosen_item_list, num)
[ 0.03783199191093445, 0.01029890961945057, -0.08731015771627426, 0.03826601058244705, 0.011429167352616787, -0.05598845332860947, -0.014123701490461826, -0.01528108585625887, 0.012478046119213104, -0.02652941271662712, -0.0363490916788578, 0.014548678882420063, -0.0031782849691808224, -0.00...
729,672
allpairspy.allpairs
__validate_parameter
null
def __validate_parameter(self, value): if isinstance(value, OrderedDict): for parameter_list in value.values(): if not parameter_list: raise ValueError("each parameter arrays must have at least one item") return if len(value) < 2: raise ValueError("must provid...
(self, value)
[ 0.05088719353079796, 0.01629222184419632, -0.03709080070257187, -0.010997248813509941, -0.01699417270720005, -0.030279265716671944, -0.04177048057317734, -0.03402300924062729, 0.032948415726423264, 0.0040557230822741985, 0.004179214593023062, 0.026726175099611282, -0.0024568322114646435, -...
729,673
allpairspy.allpairs
__init__
TODO: check that input arrays are: - (optional) has no duplicated values inside single array / or compress such values
def __init__(self, parameters, filter_func=lambda x: True, previously_tested=None, n=2): """ TODO: check that input arrays are: - (optional) has no duplicated values inside single array / or compress such values """ if not previously_tested: previously_tested = [[]] self.__validate_p...
(self, parameters, filter_func=<function AllPairs.<lambda> at 0x7f625a34cca0>, previously_tested=None, n=2)
[ 0.045276153832674026, 0.01676124706864357, -0.08034816384315491, 0.018679248169064522, 0.012528417631983757, -0.037434082478284836, -0.07483036816120148, -0.02885504439473152, -0.00574455363675952, -0.02227904088795185, -0.0339004248380661, 0.07607754319906235, -0.013577176257967949, 0.020...
729,675
allpairspy.allpairs
__next__
null
def __next__(self): assert len(self.__pairs) <= self.__max_unique_pairs_expected if len(self.__pairs) == self.__max_unique_pairs_expected: # no reasons to search further - all pairs are found raise StopIteration() previous_unique_pairs_count = len(self.__pairs) chosen_item_list = [None] ...
(self)
[ 0.02988700196146965, -0.03553081676363945, -0.0936368927359581, 0.01593262329697609, -0.017746014520525932, -0.03576355054974556, -0.0269390307366848, 0.015447760000824928, 0.05166708305478096, -0.006051099859178066, -0.023894086480140686, 0.018579980358481407, 0.009663335047662258, 0.0699...
729,679
scs
SCS
null
class SCS(object): def __init__(self, data, cone, **settings): """Initialize the SCS solver. @param data Dictionary containing keys `P`, `A`, `b`, `c`. @param cone Dictionary containing cone information. @param settings Settings as kwargs, see docs. """ self...
(data, cone, **settings)
[ -0.008927764371037483, -0.03765592351555824, 0.005834599491208792, 0.029255757108330727, -0.029441967606544495, -0.015186510048806667, -0.03422137349843979, -0.02702122926712036, 0.05664940923452377, -0.04978030547499657, -0.055697664618492126, 0.0020871106535196304, -0.015858937054872513, ...
729,680
scs
__init__
Initialize the SCS solver. @param data Dictionary containing keys `P`, `A`, `b`, `c`. @param cone Dictionary containing cone information. @param settings Settings as kwargs, see docs.
def __init__(self, data, cone, **settings): """Initialize the SCS solver. @param data Dictionary containing keys `P`, `A`, `b`, `c`. @param cone Dictionary containing cone information. @param settings Settings as kwargs, see docs. """ self._settings = settings if not data or not cone...
(self, data, cone, **settings)
[ -0.0257708877325058, -0.014535893686115742, 0.017488807439804077, 0.027142947539687157, -0.017031453549861908, -0.01926851086318493, -0.013690783642232418, -0.02585042640566826, 0.06852351874113083, -0.04227539151906967, -0.041639070957899094, 0.0162559412419796, -0.01573893241584301, 0.02...
729,681
scs
solve
Solve the optimization problem. @param warm_start Whether to warm-start. By default the solution of the previous problem is used as the warm-start. The warm-start can be overriden to another value by passing `x`, `y`, `s` arg...
def solve(self, warm_start=True, x=None, y=None, s=None): """Solve the optimization problem. @param warm_start Whether to warm-start. By default the solution of the previous problem is used as the warm-start. The warm-start can be overriden to another value by ...
(self, warm_start=True, x=None, y=None, s=None)
[ 0.03564241901040077, -0.06699838489294052, 0.03484996780753136, 0.03222046047449112, -0.024476023390889168, -0.014183125458657742, -0.05125736817717552, -0.025736745446920395, -0.0239357128739357, -0.002940184436738491, -0.029735036194324493, 0.018676700070500374, -0.034111544489860535, 0....
729,682
scs
update
Update the `b` vector, `c` vector, or both, before another solve. After a solve we can reuse the SCS workspace in another solve if the only problem data that has changed are the `b` and `c` vectors. @param b New `b` vector. @param c New `c` vector.
def update(self, b=None, c=None): """Update the `b` vector, `c` vector, or both, before another solve. After a solve we can reuse the SCS workspace in another solve if the only problem data that has changed are the `b` and `c` vectors. @param b New `b` vector. @param c New `c` vector. """ ...
(self, b=None, c=None)
[ -0.029297102242708206, -0.026761775836348534, -0.03655095398426056, 0.05922803655266762, -0.08429959416389465, -0.0012621610658243299, -0.07479212433099747, -0.010704710148274899, 0.027061086148023605, -0.01656765304505825, -0.03774819150567055, -0.046586617827415466, -0.04415693134069443, ...
729,684
scs
_select_scs_module
null
def _select_scs_module(stgs): if stgs.pop("gpu", False): # False by default if not stgs.pop("use_indirect", _USE_INDIRECT_DEFAULT): raise NotImplementedError( "GPU direct solver not yet available, pass `use_indirect=True`." ) import _scs_gpu return _...
(stgs)
[ 0.04614492505788803, -0.04244918376207352, 0.009878329932689667, 0.01227019727230072, -0.016656728461384773, 0.017053933814167976, 0.015413302928209305, 0.033434346318244934, 0.02340058796107769, -0.0156723503023386, -0.00969699677079916, -0.004280753433704376, -0.0605824813246727, 0.00228...
729,685
scs
solve
null
def solve(data, cone, **settings): solver = SCS(data, cone, **settings) # Hack out the warm start data from old API x = y = s = None if "x" in data: x = data["x"] if "y" in data: y = data["y"] if "s" in data: s = data["s"] return solver.solve(warm_start=True, x=x, y...
(data, cone, **settings)
[ 0.017293576151132584, -0.06231260672211647, 0.005333492066711187, 0.01896546222269535, -0.015325626358389854, 0.01686689630150795, -0.01450709905475378, -0.06684063374996185, 0.06144183129072189, -0.0517936535179615, -0.035039953887462616, 0.01938343420624733, -0.07182145863771439, -0.0179...
729,687
aiconfig_extension_groq.groq
GroqParser
null
class GroqParser(DefaultOpenAIParser): def __init__(self, model: str): super().__init__(model_id = model) # "Model" field is a custom name for the specific model they want to use # when registering the Groq model parser. See the cookbook for reference: # https://github.com/lastmile-...
(model: str)
[ -0.009592128917574883, -0.03497662395238876, -0.14245952665805817, -0.022466735914349556, 0.005092399660497904, 0.009355061687529087, 0.016011197119951248, 0.045261722058057785, 0.009619483724236488, -0.04048389196395874, 0.03433836251497269, 0.028046948835253716, -0.004337885417044163, 0....
729,688
aiconfig_extension_groq.groq
__init__
null
def __init__(self, model: str): super().__init__(model_id = model) # "Model" field is a custom name for the specific model they want to use # when registering the Groq model parser. See the cookbook for reference: # https://github.com/lastmile-ai/aiconfig/blob/main/cookbooks/Groq/aiconfig_model_registry...
(self, model: str)
[ 0.013730534352362156, 0.010530184023082256, -0.02055356837809086, 0.003730613272637129, 0.007099896669387817, -0.0021409967448562384, 0.027798935770988464, 0.0389673113822937, 0.021060368046164513, -0.008789231069386005, -0.010990058071911335, 0.051092978566884995, 0.018732840195298195, 0....
729,690
aiconfig.model_parser
get_model_settings
Extracts the AI model's settings from the configuration. If both prompt and config level settings are defined, merge them with prompt settings taking precedence. Args: prompt: The prompt object. Returns: dict: The settings of the model used by the prompt.
def get_model_settings( self, prompt: Prompt, aiconfig: "AIConfigRuntime" ) -> Dict[str, Any]: """ Extracts the AI model's settings from the configuration. If both prompt and config level settings are defined, merge them with prompt settings taking precedence. Args: prompt: The prompt object. ...
(self, prompt: aiconfig.schema.Prompt, aiconfig: 'AIConfigRuntime') -> Dict[str, Any]
[ -0.024231255054473877, -0.027353648096323013, -0.045657966285943985, -0.057810988277196884, 0.014434050768613815, 0.00012905281619168818, -0.012498915195465088, -0.04087154567241669, 0.07101104408502579, -0.015696095302700996, -0.02079101651906967, -0.009787856601178646, -0.04393784701824188...
729,691
aiconfig.default_parsers.openai
get_output_text
null
def get_output_text( self, prompt: Prompt, aiconfig: "AIConfigRuntime", output: Optional[Output] = None, ) -> str: if not output: output = aiconfig.get_latest_output(prompt) if not output: return "" if output.output_type == "execute_result": output_data = output.data ...
(self, prompt: aiconfig.schema.Prompt, aiconfig: 'AIConfigRuntime', output: Union[aiconfig.schema.ExecuteResult, aiconfig.schema.Error, NoneType] = None) -> str
[ 0.015308971516788006, -0.051072556525468826, 0.012164919637143612, -0.04818441718816757, 0.03911785036325455, -0.007686474360525608, -0.014267046935856342, 0.028790006414055824, 0.07567659020423889, -0.08189157396554947, 0.051255349069833755, 0.0420059897005558, -0.03937375918030739, -0.00...
729,692
aiconfig.default_parsers.openai
get_prompt_template
Returns a template for a prompt.
def get_prompt_template( self, prompt: Prompt, aiconfig: "AIConfigRuntime" ) -> str: """ Returns a template for a prompt. """ if isinstance(prompt.input, str): return prompt.input elif isinstance(prompt.input, PromptInput) and isinstance( prompt.input.data, str ): ret...
(self, prompt: aiconfig.schema.Prompt, aiconfig: 'AIConfigRuntime') -> str
[ 0.03799542784690857, -0.028407461941242218, 0.04954375699162483, -0.10493296384811401, 0.035429131239652634, 0.0032657890114933252, 0.013392853550612926, -0.0017999709816649556, 0.07884228974580765, -0.04220129922032356, 0.040739938616752625, 0.049472469836473465, -0.0758482813835144, 0.01...
729,693
aiconfig.default_parsers.openai
id
null
def id(self) -> str: return self.model_id
(self) -> str
[ -0.014817651361227036, 0.009814174845814705, 0.033403243869543076, 0.028443582355976105, 0.048404913395643234, -0.024868417531251907, 0.05313674733042717, 0.06274061650037766, 0.0007513977470807731, -0.002567458199337125, -0.08005562424659729, -0.03617224469780922, -0.0008888619486242533, ...
729,694
aiconfig_extension_groq.groq
initialize_openai_client
null
def initialize_openai_client(self) -> None: # Initialize Groq Client self.client = Groq( api_key=os.getenv("GROQ_API_KEY"), )
(self) -> NoneType
[ -0.06803854554891586, -0.061305757611989975, -0.09268802404403687, -0.017916692420840263, -0.00826636515557766, 0.008359876461327076, 0.003151318058371544, 0.07088127732276917, 0.022087279707193375, -0.02270445041358471, 0.006629924289882183, 0.016719752922654152, 0.02016095444560051, 0.03...
729,695
aiconfig.default_parsers.parameterized_model_parser
resolve_prompt_template
Resolves a templated string with the provided parameters (applied from the AIConfig as well as passed in params). Args: prompt_template (str): The template string to resolve. prompt (Prompt): The prompt object that the template string belongs to (if any). ai_config ...
def resolve_prompt_template( prompt_template: str, prompt: Prompt, ai_config: "AIConfigRuntime", params: Optional[JSONObject] = {}, ): """ Resolves a templated string with the provided parameters (applied from the AIConfig as well as passed in params). Args: prompt_template (str): Th...
(prompt_template: str, prompt: aiconfig.schema.Prompt, ai_config: 'AIConfigRuntime', params: Optional[Dict[str, Any]] = {})
[ 0.034879740327596664, -0.013875006698071957, 0.003842275822535157, -0.11330672353506088, 0.02221049554646015, -0.0029357695020735264, 0.0015814710641279817, 0.007522909436374903, 0.0494537390768528, -0.07444272935390472, 0.033901147544384, 0.05703780800104141, -0.08073366433382034, 0.01352...
729,696
aiconfig.default_parsers.parameterized_model_parser
run
null
@abstractmethod async def run_inference(self) -> List[Output]: pass
(self, prompt: aiconfig.schema.Prompt, aiconfig: aiconfig.schema.AIConfig, options: Optional[aiconfig.model_parser.InferenceOptions] = None, parameters: Dict = {}, run_with_dependencies: Optional[bool] = False) -> List[Union[aiconfig.schema.ExecuteResult, aiconfig.schema.Error]]
[ 0.007228159345686436, -0.07212400436401367, -0.06545569002628326, 0.017699245363473892, -0.03851700574159622, 0.022576075047254562, -0.0342705138027668, -0.04037484526634216, 0.01635562814772129, -0.003578830510377884, 0.04697681590914726, 0.027369966730475426, -0.008468101732432842, 0.028...
729,697
aiconfig.model_parser
run_batch
Concurrently runs inference on multiple parameter sets, one set at a time. Default implementation for the run_batch method. Model Parsers may choose to override this method if they need to implement custom batch execution logic. For each dictionary of parameters in `params_list``, the `run` met...
@abstractmethod async def run( self, prompt: Prompt, aiconfig: AIConfig, options: Optional["InferenceOptions"] = None, parameters: Dict = {}, run_with_dependencies: Optional[bool] = False, ) -> ExecuteResult: """ Execute model inference based on completion data to be constructed in deser...
(self, prompt: aiconfig.schema.Prompt, aiconfig: 'AIConfigRuntime', parameters_list: list[dict[str, typing.Any]], options: Optional[ForwardRef('InferenceOptions')] = None, **kwargs: Any) -> list['AIConfigRuntime']
[ 0.020260704681277275, -0.031360045075416565, -0.0735023096203804, -0.021828705444931984, 0.019696928560733795, -0.0006964617059566081, -0.04348123073577881, -0.045524921268224716, 0.03178287670016289, -0.020771626383066177, 0.043269816786050797, 0.009593002498149872, -0.021722998470067978, ...
729,698
aiconfig.default_parsers.openai
run_inference
Invoked to run a prompt in the .aiconfig. This method should perform the actual model inference based on the provided prompt and inference settings. Args: prompt (str): The input prompt. inference_settings (dict): Model-specific inference settings. Returns: ...
@abstractmethod def id(self) -> str: """ Returns an identifier for the model (e.g. gpt-3.5, gpt-4, etc.). """ return self.id
(self, prompt: aiconfig.schema.Prompt, aiconfig: 'AIConfigRuntime', options: aiconfig.model_parser.InferenceOptions, parameters) -> List[Union[aiconfig.schema.ExecuteResult, aiconfig.schema.Error]]
[ 0.012052255682647228, -0.038461651653051376, 0.007213759236037731, 0.03598082438111305, 0.0004898977931588888, -0.07090597599744797, 0.015940647572278976, 0.013363048434257507, 0.014251573011279106, -0.0016648827586323023, -0.03140624240040779, -0.008256235159933567, 0.01692594215273857, 0...
729,699
aiconfig.default_parsers.parameterized_model_parser
run_with_dependencies
Executes the AI model with the resolved dependencies and prompt references and returns the API response. Args: prompt: The prompt to be used. aiconfig: The AIConfig object containing all prompts and parameters. parameters (dict): The resolved parameters to use for i...
@abstractmethod async def run_inference(self) -> List[Output]: pass
(self, prompt: aiconfig.schema.Prompt, aiconfig: aiconfig.schema.AIConfig, options=None, parameters: Dict = {}) -> List[Union[aiconfig.schema.ExecuteResult, aiconfig.schema.Error]]
[ 0.007228159345686436, -0.07212400436401367, -0.06545569002628326, 0.017699245363473892, -0.03851700574159622, 0.022576075047254562, -0.0342705138027668, -0.04037484526634216, 0.01635562814772129, -0.003578830510377884, 0.04697681590914726, 0.027369966730475426, -0.008468101732432842, 0.028...
729,700
aiconfig.default_parsers.openai
serialize
Defines how prompts and model inference settings get serialized in the .aiconfig. Args: prompt (str): The prompt to be serialized. inference_settings (dict): Model-specific inference settings to be serialized. Returns: str: Serialized representation of the ...
@abstractmethod def id(self) -> str: """ Returns an identifier for the model (e.g. gpt-3.5, gpt-4, etc.). """ return self.id
(self, prompt_name: str, data: Dict, ai_config: 'AIConfigRuntime', parameters: Optional[Dict], **kwargs) -> List[aiconfig.schema.Prompt]
[ 0.012052255682647228, -0.038461651653051376, 0.007213759236037731, 0.03598082438111305, 0.0004898977931588888, -0.07090597599744797, 0.015940647572278976, 0.013363048434257507, 0.014251573011279106, -0.0016648827586323023, -0.03140624240040779, -0.008256235159933567, 0.01692594215273857, 0...
729,707
dotchain.dot_chain
DotChain
null
class DotChain: __slots__ = ('__chain__') def __init__(self, data: t.Any = None, context: t.Optional[t.Any | list[t.Any]] = [], parent: t.Optional[Chain] = None, pipe: t.Optional[bool] = False, **kwargs): if 'chain' in kwargs: ...
(data: 't.Any' = None, context: 't.Optional[t.Any | list[t.Any]]' = [], parent: 't.Optional[Chain]' = None, pipe: 't.Optional[bool]' = False, **kwargs)
[ 0.0009013913222588599, -0.03246867284178734, 0.02155905030667782, 0.024309687316417694, -0.007935960777103901, -0.0003275674534961581, -0.04375000298023224, -0.046017419546842575, 0.06661003082990646, -0.014013382606208324, 0.03310057520866394, 0.021744903177022934, 0.012628771364688873, 0...
729,708
dotchain.dot_chain
Call
null
def Call(self, callable: t.Callable) -> DotChain: attr_chain = GetAttrChain(parent=self.__chain__, item=callable, context=self.__chain__.contexts, pipe=self.__chain__.pipe) return DotChain( chain=CallChain(parent=a...
(self, callable: Callable) -> dotchain.dot_chain.DotChain
[ 0.026737909764051437, -0.043799590319395065, 0.025491729378700256, 0.008732428774237633, -0.02244958095252514, -0.012498460710048676, 0.001384772709570825, -0.02551005594432354, 0.04625530168414116, -0.01951739192008972, 0.0023709507659077644, 0.009694553911685944, 0.04050087928771973, 0.0...
729,709
dotchain.dot_chain
Result
null
def Result(self) -> t.Any: return self.__chain__.result_sync()
(self) -> Any
[ 0.008659306913614273, -0.06037836894392967, -0.0085366889834404, 0.05878857150673866, 0.027432411909103394, -0.022460076957941055, -0.027601540088653564, -0.06179903447628021, 0.08639011532068253, -0.008633937686681747, 0.04776148870587349, -0.00014243670739233494, -0.01024064514786005, 0....
729,710
dotchain.dot_chain
With
null
def With(self, *contexts: t.Any | list[t.Any], clear: bool = False) -> t.Self: self.__chain__.set_contexts(*contexts, clear=clear) return self
(self, *contexts: 't.Any | list[t.Any]', clear: 'bool' = False) -> 't.Self'
[ -0.04054044559597969, -0.045324284583330154, 0.04099438339471817, -0.006586512550711632, -0.03900402784347534, 0.015128464438021183, -0.007490030489861965, -0.006088923197239637, 0.03324246406555176, 0.03778187930583954, -0.001439299201592803, -0.04846695438027382, -0.054857052862644196, 0...
729,711
dotchain.dot_chain
__aiter__
null
def __aiter__(self): self.__chain__.__aiter__() return self
(self)
[ -0.038104455918073654, 0.0018781159305945039, 0.010317805223166943, 0.05569377541542053, -0.029929380863904953, -0.02702077478170395, -0.022735314443707466, 0.0007760943262837827, 0.06946232169866562, 0.011780713684856892, 0.052733536809682846, 0.0010052114957943559, 0.027227303013205528, ...
729,712
dotchain.dot_chain
__anext__
null
def __iter__(self): self.__chain__.__iter__() return self
(self)
[ -0.016319777816534042, -0.038512952625751495, -0.031537216156721115, 0.023906966671347618, -0.06686372309923172, -0.006217878311872482, -0.01757713221013546, -0.004351222887635231, 0.1079602763056755, 0.03417249396443367, 0.03734171763062477, -0.003916315734386444, 0.006093003787100315, 0....
729,713
dotchain.dot_chain
__await__
null
def __await__(self): return self.__chain__.__await__()
(self)
[ 0.019938072189688683, -0.01822333224117756, -0.0360431931912899, 0.07907984405755997, 0.01333968061953783, -0.020425597205758095, 0.005430014804005623, -0.016130337491631508, 0.05978059768676758, -0.004404532257467508, 0.04582730680704117, 0.004259535577148199, 0.02387189120054245, 0.02590...
729,714
dotchain.dot_chain
__call__
null
def __call__(self, *args, **kwargs) -> DotChain: return DotChain( chain=CallChain(self.__chain__, args=args, kwargs=kwargs, context=self.__chain__.contexts, pipe=self.__chain__.pipe))
(self, *args, **kwargs) -> dotchain.dot_chain.DotChain
[ -0.02821815386414528, -0.07414884865283966, 0.06328468024730682, 0.0317499041557312, -0.04166390746831894, -0.028182297945022583, -0.05503794923424721, -0.029383452609181404, 0.07988569885492325, -0.015606037341058254, 0.014162859879434109, 0.011177903041243553, 0.016206614673137665, 0.035...
729,715
dotchain.dot_chain
__getattr__
null
def __getattr__(self, item: str) -> DotChain: # https://github.com/python/cpython/issues/69718#issuecomment-1093697247 if item.startswith('__'): raise AttributeError(item) return DotChain( chain=GetAttrChain(self.__chain__, item, context=...
(self, item: str) -> dotchain.dot_chain.DotChain
[ 0.022754358127713203, -0.0181931983679533, 0.06217581033706665, 0.03391719609498978, 0.00023697990400251, -0.06217581033706665, 0.03974724933505058, -0.021159665659070015, 0.05624287202954292, 0.013940688222646713, 0.00906230416148901, 0.0605296790599823, 0.039438601583242416, 0.0568258799...
729,716
dotchain.dot_chain
__init__
null
def __init__(self, data: t.Any = None, context: t.Optional[t.Any | list[t.Any]] = [], parent: t.Optional[Chain] = None, pipe: t.Optional[bool] = False, **kwargs): if 'chain' in kwargs: self.__chain__ = kwargs.get('chain') else: self.__chain__ =...
(self, data: Optional[Any] = None, context: Union[Any, list[Any], NoneType] = [], parent: Optional[dotchain.chain.Chain] = None, pipe: Optional[bool] = False, **kwargs)
[ -0.03479931503534317, 0.01628200151026249, 0.027038317173719406, -0.028629858046770096, -0.033404480665922165, -0.011945500038564205, -0.03862616792321205, -0.012964801862835884, 0.07539255917072296, -0.02920209802687168, 0.018070250749588013, 0.019474025815725327, -0.0768231526017189, 0.0...
729,718
dotchain.dot_chain
__next__
null
def __next__(self): return self.__chain__.__next__()
(self)
[ -0.017710017040371895, -0.0374138206243515, -0.007936133071780205, 0.03824600949883461, -0.05076351389288902, 0.000024295875846291892, 0.013661765493452549, -0.032559383660554886, 0.08266407996416092, 0.009067390114068985, 0.02931731566786766, -0.0012341965921223164, 0.03486524149775505, 0...
729,721
addfips.addfips
AddFIPS
Get state or county FIPS codes
class AddFIPS: """Get state or county FIPS codes""" default_county_field = 'county' default_state_field = 'state' data = files('addfips') def __init__(self, vintage=None): # Handle de-diacreticizing self.diacretic_pattern = '(' + ('|'.join(DIACRETICS)) + ')' self.delete_di...
(vintage=None)
[ 0.03373221307992935, -0.04146377369761467, -0.02037861756980419, 0.029977459460496902, -0.07230927050113678, -0.08462323993444443, -0.056321289390325546, -0.010098467580974102, 0.07121917605400085, -0.08720715343952179, -0.058662962168455124, 0.031471285969018936, -0.03732547163963318, 0.0...
729,722
addfips.addfips
__init__
null
def __init__(self, vintage=None): # Handle de-diacreticizing self.diacretic_pattern = '(' + ('|'.join(DIACRETICS)) + ')' self.delete_diacretics = lambda x: DIACRETICS[x.group()] if vintage is None or vintage not in COUNTY_FILES: vintage = max(COUNTY_FILES.keys()) self._states, self._state_fi...
(self, vintage=None)
[ -0.0004496534529607743, -0.034084502607584, -0.03669029474258423, -0.008544901385903358, -0.0675603598356247, -0.050213780254125595, -0.024212932214140892, -0.009120267815887928, 0.019724125042557716, -0.03727992624044418, -0.058392539620399475, 0.10430771112442017, -0.0637943223118782, 0....
729,723
addfips.addfips
_delete_diacretics
null
def _delete_diacretics(self, string): return re.sub(self.diacretic_pattern, self.delete_diacretics, string)
(self, string)
[ -0.00806625559926033, 0.027030080556869507, 0.06169017404317856, 0.0283815860748291, -0.04653279855847359, -0.08964406698942184, -0.025148240849375725, 0.05005697160959244, 0.040921490639448166, 0.0032504526898264885, -0.011915476061403751, 0.0563868023455143, -0.04643015190958977, -0.0073...
729,724
addfips.addfips
_load_county_data
null
def _load_county_data(self, vintage): with self.data.joinpath(COUNTY_FILES[vintage]).open('rt', encoding='utf-8') as f: counties = {} for row in csv.DictReader(f): if row['statefp'] not in counties: counties[row['statefp']] = {} state = counties[row['statefp']...
(self, vintage)
[ -0.0017779755871742964, -0.04171304032206535, -0.04463560879230499, -0.009707106277346611, -0.07735320925712585, -0.036114610731601715, -0.024101709946990013, 0.004519070498645306, 0.056515663862228394, -0.08281879127025604, -0.06152578443288803, 0.024974685162305832, -0.07473427802324295, ...
729,725
addfips.addfips
_load_state_data
null
def _load_state_data(self): with self.data.joinpath(STATES).open('rt', encoding='utf-8') as f: reader = csv.DictReader(f) states = {} state_fips = {} for row in reader: states[row['postal'].lower()] = row['fips'] states[row['name'].lower()] = row['fips'] ...
(self)
[ 0.02849714830517769, -0.0267731212079525, -0.017219984903931618, -0.02628633752465248, -0.0495302751660347, -0.028071211650967598, -0.020546341314911842, -0.013285147026181221, 0.046244483441114426, -0.048313312232494354, -0.03695502132177353, 0.008336176164448261, -0.045676566660404205, 0...
729,726
addfips.addfips
add_county_fips
Add county FIPS to a dictionary containing a state name, FIPS code, or using a passed state name or FIPS code. :row dict/list A dictionary with state and county names :county_field str county name field. default: county :state_fips_field str state FIPS field containing state fips ...
def add_county_fips(self, row, county_field=None, state_field=None, state=None): """ Add county FIPS to a dictionary containing a state name, FIPS code, or using a passed state name or FIPS code. :row dict/list A dictionary with state and county names :county_field str county name field. default: county...
(self, row, county_field=None, state_field=None, state=None)
[ -0.014998691156506538, -0.04081227630376816, 0.03226473182439804, 0.032390695065259933, -0.0580873116850853, -0.03575572744011879, -0.03060920722782612, -0.003398773493245244, 0.047254424542188644, -0.08493559807538986, -0.0062397075816988945, 0.042143892496824265, -0.027981961145997047, 0...
729,727
addfips.addfips
add_state_fips
Add state FIPS to a dictionary. :row dict/list A dictionary with state and county names :state_field str name of state name field. default: state
def add_state_fips(self, row, state_field=None): """ Add state FIPS to a dictionary. :row dict/list A dictionary with state and county names :state_field str name of state name field. default: state """ if state_field is None: state_field = self.default_state_field fips = self.get_st...
(self, row, state_field=None)
[ -0.00007318480493267998, -0.045505259186029434, 0.011184578761458397, 0.02739080600440502, -0.04265661537647247, -0.01970311999320984, -0.025290843099355698, -0.01083762850612402, 0.04503048583865166, -0.07910464704036713, -0.021529173478484154, 0.03162724897265434, -0.021583953872323036, ...
729,728
addfips.addfips
get_county_fips
Get a county's FIPS code. :county str County name :state str Name, postal abbreviation or FIPS code for a state
def get_county_fips(self, county, state): """ Get a county's FIPS code. :county str County name :state str Name, postal abbreviation or FIPS code for a state """ state_fips = self.get_state_fips(state) counties = self._counties.get(state_fips, {}) try: name = self._delete_diacret...
(self, county, state)
[ -0.02195850759744644, -0.05754394084215164, 0.030181651934981346, 0.004506915807723999, -0.0620260052382946, -0.05389322713017464, -0.007992716506123543, -0.03415767848491669, 0.10062960535287857, -0.1071358323097229, -0.017169203609228134, 0.0435917042195797, -0.04641106724739075, -0.0025...
729,729
addfips.addfips
get_state_fips
Get FIPS code from a state name or postal code
def get_state_fips(self, state): '''Get FIPS code from a state name or postal code''' if state is None: return None # Check if we already have a FIPS code if state in self._state_fips: return state return self._states.get(state.lower())
(self, state)
[ 0.021182727068662643, -0.048872094601392746, 0.04453433305025101, 0.025574708357453346, -0.05418584868311882, -0.06394580751657486, 0.0217610951513052, -0.044389743357896805, 0.08783963322639465, -0.10685348510742188, -0.042690787464380264, 0.032551273703575134, -0.04070264473557472, 0.018...
729,731
minidir
Directory
Directory is a interface that can add, remove and iterate files
class Directory(typing.Protocol): """Directory is a interface that can add, remove and iterate files""" def __iter__(self) -> typing.Iterator[Path]: pass def create(self, path: Path) -> File: pass def remove(self, path: Path) -> None: pass def get(self, path: Path) -> Fil...
(*args, **kwargs)
[ -0.008052605204284191, 0.003021512646228075, -0.0981360673904419, -0.02761981636285782, -0.010314572602510452, -0.007357347756624222, -0.04541078582406044, 0.03923918679356575, 0.012543206103146076, 0.007004956714808941, 0.058820683509111404, -0.04057255759835243, -0.009790748357772827, 0....
729,733
minidir
__iter__
null
def __iter__(self) -> typing.Iterator[Path]: pass
(self) -> Iterator[minidir.Path]
[ 0.03088340349495411, -0.03812384605407715, -0.07521824538707733, -0.0024427915923297405, -0.027297498658299446, -0.000664851046167314, 0.004027710761874914, 0.059193190187215805, 0.07068867981433868, 0.022218894213438034, 0.06427179276943207, -0.008111182600259781, 0.00897334422916174, 0.0...
729,735
minidir
create
null
def create(self, path: Path) -> File: pass
(self, path: minidir.Path) -> minidir.File
[ -0.006111571099609137, 0.024904971942305565, -0.025975238531827927, 0.024395320564508438, -0.01572274975478649, -0.054124992340803146, 0.008460215292870998, 0.07773884385824203, -0.019485676661133766, -0.0036248965188860893, 0.09785309433937073, 0.019519653171300888, 0.018738187849521637, ...
729,736
minidir
get
null
def get(self, path: Path) -> File: pass
(self, path: minidir.Path) -> minidir.File
[ 0.047557249665260315, -0.021689502522349358, -0.042393893003463745, 0.06596869975328445, 0.01259417925029993, -0.04266564920544624, 0.034954577684402466, 0.027005724608898163, 0.02598663978278637, -0.001118869287893176, 0.08132290095090866, -0.007503005675971508, -0.026139503344893456, 0.0...
729,737
minidir
remove
null
def remove(self, path: Path) -> None: pass
(self, path: minidir.Path) -> NoneType
[ 0.04327651113271713, 0.04052671790122986, -0.026123037561774254, 0.002418345073238015, -0.008081610314548016, -0.0487433597445488, -0.02018151991069317, 0.09447504580020905, 0.02219475992023945, 0.02546832337975502, 0.04720478504896164, -0.006416184362024069, 0.022702163085341454, -0.01442...
729,738
minidir
FakeDirectory
FakeDirectory implements Directory protocol in memory.
class FakeDirectory: """FakeDirectory implements Directory protocol in memory.""" _dir: typing.Dict[str, bytes] def __init__(self) -> None: self._dir = {} pass def __iter__(self) -> typing.Iterator[Path]: paths: typing.List[Path] = [] for key in self._dir: ...
() -> None
[ 0.026432648301124573, 0.017257902771234512, -0.08703829348087311, 0.0112225990742445, 0.015985887497663498, -0.015291241928935051, -0.0336497537791729, 0.08545053005218506, -0.011520304717123508, -0.01957639865577221, 0.059324607253074646, 0.02917514741420746, -0.021290460601449013, 0.0507...
729,739
minidir
__init__
null
def __init__(self) -> None: self._dir = {} pass
(self) -> NoneType
[ 0.0009170864359475672, 0.013269690796732903, -0.02465616539120674, -0.010819767601788044, -0.001291440799832344, 0.0019845685455948114, -0.0018167357193306088, 0.09478848427534103, -0.013949739746749401, 0.004202359355986118, 0.007877243682742119, 0.02612088806927204, -0.005902483593672514, ...
729,740
minidir
__iter__
null
def __iter__(self) -> typing.Iterator[Path]: paths: typing.List[Path] = [] for key in self._dir: paths.append(SomePath(key)) return iter(paths)
(self) -> Iterator[minidir.Path]
[ 0.006121609825640917, -0.04980170726776123, -0.09859440475702286, 0.003229723544791341, 0.0010287142358720303, 0.017873840406537056, 0.0019831042736768723, 0.05567556992173195, 0.07927913218736649, 0.029909852892160416, 0.03517110273241997, 0.010981961153447628, 0.0016463932115584612, 0.07...
729,741
minidir
create
null
def create(self, path: Path) -> File: if str(path) in self._dir: raise NameCollision() self._dir[str(path)] = b"" return _FakeDirectoryFile(self._dir, str(path))
(self, path: minidir.Path) -> minidir.File
[ -0.002269681077450514, 0.051701951771974564, -0.031791433691978455, 0.0058042071759700775, -0.008956100791692734, -0.047305651009082794, -0.029738614335656166, 0.07535477727651596, -0.021291175857186317, 0.002269681077450514, 0.09984326362609863, 0.055371589958667755, -0.015477885492146015, ...
729,742
minidir
get
null
def get(self, path: Path) -> File: if str(path) not in self._dir: raise NotFound() return _FakeDirectoryFile(self._dir, str(path))
(self, path: minidir.Path) -> minidir.File
[ 0.06846857070922852, 0.007476716302335262, -0.048995181918144226, 0.04386095702648163, 0.02200382575392723, -0.04734489694237709, 0.040890440344810486, 0.036856405436992645, -0.007307103369385004, 0.018309015780687332, 0.0870618000626564, 0.03769988566637039, -0.03161216154694557, 0.009223...
729,743
minidir
remove
null
def remove(self, path: Path) -> None: if str(path) not in self._dir: raise NotFound() del self._dir[str(path)]
(self, path: minidir.Path) -> NoneType
[ 0.06048315390944481, 0.0674886554479599, -0.0182073712348938, -0.021502038463950157, 0.027501801028847694, -0.03464602679014206, -0.00913836620748043, 0.07338438183069229, -0.0023799636401236057, 0.03613729774951935, 0.042414505034685135, 0.03464602679014206, 0.03187157213687897, -0.025143...
729,744
minidir
File
File is a interface that can read and write content.
class File(typing.Protocol): """File is a interface that can read and write content.""" def read(self) -> bytes: pass def write(self, content: bytes) -> None: pass
(*args, **kwargs)
[ -0.010736407712101936, -0.048426516354084015, -0.0530780591070652, 0.006422913633286953, -0.007842715829610825, -0.015153569169342518, -0.049508269876241684, 0.04864286631345749, 0.032362472265958786, -0.03275911509990692, 0.07932861894369125, -0.03398510068655014, -0.015568241477012634, 0...
729,747
minidir
read
null
def read(self) -> bytes: pass
(self) -> bytes
[ -0.01278314832597971, -0.03378164395689964, -0.04206392168998718, 0.041796211153268814, 0.004362835083156824, -0.013820524327456951, -0.03219211846590042, 0.05739031359553337, 0.060402050614356995, -0.06595703214406967, 0.04929208755493164, 0.0147909726947546, 0.008658742532134056, 0.05367...