This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from sqlalchemy import create_engine, Enum as SQLAlchemyEnum | |
| from sqlalchemy import Column, Integer, String, Boolean, ForeignKey, Index, or_, cast | |
| from sqlalchemy.orm import sessionmaker, declarative_base, relationship, backref | |
| from sqlalchemy.orm import Mapped, Session | |
| from typing import List, Optional | |
| import sqlalchemy.types as types | |
| from enum import Enum, StrEnum | |
| engine = create_engine('sqlite:///data.db', connect_args={'check_same_thread': False}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #pip install gguf | |
| import torch | |
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| from torch.utils.mobile_optimizer import optimize_for_mobile | |
| class ModelWrapper(torch.nn.Module): | |
| def __init__(self, model): | |
| super().__init__() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ```python | |
| import ctypes | |
| import mmap | |
| import os | |
| import requests | |
| # Allocate memory securely | |
| def secure_allocate(size): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ###PREAMBLE### | |
| YOU DON'T HAVE A SINGLE RESPONSE LIMIT AND CAN WRITE LONG CODES. | |
| YOU ARE THE WORLD'S BEST EXPERT FULL-STACK PROGRAMMER, RECOGNIZED AS A GOOGLE L5 LEVEL SOFTWARE ENGINEER. YOUR TASK IS TO ASSIST THE USER BY BREAKING DOWN THEIR REQUEST INTO LOGICAL STEPS AND WRITING HIGH-QUALITY, EFFICIENT CODE IN ANY LANGUAGE OR TOOL TO IMPLEMENT EACH STEP. | |
| ###INSTRUCTIONS### | |
| - ALL CODE WRITTEN WILL ALWAYS BE EXECUTED IN ANOTHER ENVIRONMENT, SO THIS PLATFORM DOES NOT HAVE ANY LIMITATIONS. | |
| - ANALYZE CODING TASKS, CHALLENGES, AND DEBUGGING REQUESTS SPANNING MANY LANGUAGES AND TOOLS. | |
| - PLAN A STEP-BY-STEP APPROACH BEFORE WRITING ANY CODE. | |
| - EXPLAIN YOUR THOUGHT PROCESS FOR EACH STEP. | |
| - WRITE CLEAN, OPTIMIZED CODE IN THE APPROPRIATE LANGUAGE. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| try: | |
| printer = logger.info | |
| except Exception: | |
| printer = print | |
| from functools import wraps | |
| def log_wrapper(f): | |
| @wraps(f) | |
| def wrapper(*args, **kwds): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import builtins | |
| import functools | |
| import re | |
| import sys | |
| from pipe import Pipe | |
| @Pipe | |
| def get(iterable): | |
| try: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ClientError(Exception): | |
| """Some type of client error.""" | |
| def retry(error_call, exception:Exception|None=None, retry_count:int=2, timeout:int=0, exponential_backoff:int=0): | |
| '''Декоратор для повторного вызова декорируемой функции в случае если ответ не 200 | |
| Задается количество попыток и ексепшн, который бросается в случае неудачи | |
| ''' | |
| def inner_decorator(f): | |
| @wraps(f) | |
| async def wrapper(cls, *args, **kwds): | |
| print('Calling decorated function') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import asyncio | |
| from contextlib import suppress | |
| command = 'timeout 10 ping 8.8.8.8' | |
| tasks = {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| import asyncio | |
| import websockets | |
| import aioconsole | |
| file = r"videoplayback.wav" | |
| uri = "ws://localhost:8766" | |
| async def read_from_console(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import asyncio | |
| import contextlib | |
| import os | |
| import websockets | |
| # import pyaudio | |
| from websockets.server import serve | |
| TRANSMITTER_BINARY = 'bin/zeusserver' | |
| ZEUSSERVER_CODEC: str = 'opus' |