id int64 0 190k | prompt stringlengths 21 13.4M | docstring stringlengths 1 12k ⌀ |
|---|---|---|
188,431 | from flask import request, jsonify, Response
from backend.api.chat_plugin import plugins
from backend.main import app, api_key_pool
from backend.schemas import DEFAULT_USER_ID
global plugins
plugins = []
# Load icon image
# If image is base64 encoded
plugins.append(
... | parameters: { user_id: id of the user } return value: [{ id: id of a plugin, name: name of a plugin, description: description of the plugin, icon: icon of the plugin, require_api_key: whether the plugin requires api_key, api_key: the api key of the plugin, None if no api key }] |
188,432 | from flask import request, jsonify, Response
from backend.api.chat_plugin import plugins
from backend.main import app, api_key_pool
from backend.schemas import DEFAULT_USER_ID
api_key_pool: UserMemoryManager = UserMemoryManager(name="api_key_pool", backend=API_KEY_MEMORY_MANAGER_BACKEND)
DEFAULT_USER_ID = "DefaultUse... | parameters: { user_id: id of the user, tool_id: id of the tool, tool_name: name of the tool, api_key: api_key of the tool } |
188,433 | import os
from backend.app import app
from real_agents.adapters.models import ChatOpenAI, ChatAnthropic, AzureChatOpenAI
from real_agents.adapters.llm import BaseLanguageModel
The provided code snippet includes necessary dependencies for implementing the `get_llm_list` function. Write a Python function `def get_llm_li... | Gets the whole llm list. |
188,434 | import json
import os
import shutil
from typing import Dict, Any
from flask import Response, jsonify, request, send_file
from backend.app import app
from backend.main import (
grounding_source_pool,
logger,
message_id_register,
message_pool,
)
from backend.schemas import DEFAULT_USER_ID
from backend.uti... | Uploads a new file. |
188,435 | import json
import os
import shutil
from typing import Dict, Any
from flask import Response, jsonify, request, send_file
from backend.app import app
from backend.main import (
grounding_source_pool,
logger,
message_id_register,
message_pool,
)
from backend.schemas import DEFAULT_USER_ID
from backend.uti... | Applies data to the conversation. |
188,436 | import json
import os
import shutil
from typing import Dict, Any
from flask import Response, jsonify, request, send_file
from backend.app import app
from backend.main import (
grounding_source_pool,
logger,
message_id_register,
message_pool,
)
from backend.schemas import DEFAULT_USER_ID
from backend.uti... | Moves file from source path from target source. |
188,437 | import json
import os
import shutil
from typing import Dict, Any
from flask import Response, jsonify, request, send_file
from backend.app import app
from backend.main import (
grounding_source_pool,
logger,
message_id_register,
message_pool,
)
from backend.schemas import DEFAULT_USER_ID
from backend.uti... | Deletes a file from the filesystem. |
188,438 | import json
import os
import shutil
from typing import Dict, Any
from flask import Response, jsonify, request, send_file
from backend.app import app
from backend.main import (
grounding_source_pool,
logger,
message_id_register,
message_pool,
)
from backend.schemas import DEFAULT_USER_ID
from backend.uti... | Downloads a file to local. |
188,439 | import json
import os
import shutil
from typing import Dict, Any
from flask import Response, jsonify, request, send_file
from backend.app import app
from backend.main import (
grounding_source_pool,
logger,
message_id_register,
message_pool,
)
from backend.schemas import DEFAULT_USER_ID
from backend.uti... | Creates a folder in the filesystem. |
188,440 | import json
import os
import shutil
from typing import Dict, Any
from flask import Response, jsonify, request, send_file
from backend.app import app
from backend.main import (
grounding_source_pool,
logger,
message_id_register,
message_pool,
)
from backend.schemas import DEFAULT_USER_ID
from backend.uti... | Renames a folder in the filesystem. |
188,441 | import json
import os
import shutil
from typing import Dict, Any
from flask import Response, jsonify, request, send_file
from backend.app import app
from backend.main import (
grounding_source_pool,
logger,
message_id_register,
message_pool,
)
from backend.schemas import DEFAULT_USER_ID
from backend.uti... | Gets a file path tree of one file. |
188,442 | import json
import os
import shutil
from typing import Dict, Any
from flask import Response, jsonify, request, send_file
from backend.app import app
from backend.main import (
grounding_source_pool,
logger,
message_id_register,
message_pool,
)
from backend.schemas import DEFAULT_USER_ID
from backend.uti... | Sets default files for each user. |
188,443 | import traceback
from typing import Dict, List, Union
from flask import Response, request, stream_with_context, Response
from backend.api.file import _get_file_path_from_node
from backend.api.language_model import get_llm
from backend.app import app
from backend.main import (
grounding_source_pool,
jupyter_kern... | Returns the chat response of data agent. |
188,444 | from time import sleep
import copy
import redis
import json
import pickle
import traceback
from flask import Response, request, stream_with_context
from typing import Dict, Union
import os
from langchain.schema import HumanMessage, SystemMessage
from backend.api.language_model import get_llm
from backend.main import ap... | null |
188,445 | from time import sleep
import copy
import redis
import json
import pickle
import traceback
from flask import Response, request, stream_with_context
from typing import Dict, Union
import os
from langchain.schema import HumanMessage, SystemMessage
from backend.api.language_model import get_llm
from backend.main import ap... | Returns the chat response of web agent. |
188,446 | from flask import request, jsonify, Response
from backend.main import app
from backend.schemas import DEFAULT_USER_ID
from backend.api.chat_webot import get_webot_from_redis, \
get_webot_status_from_redis, reset_webot_status
DEFAULT_USER_ID = "DefaultUser"
def get_webot_from_redis(user_id: str, chat_id: str, ) ->... | null |
188,447 | from flask import request, jsonify, Response
from backend.main import app
from backend.schemas import DEFAULT_USER_ID
from backend.api.chat_webot import get_webot_from_redis, \
get_webot_status_from_redis, reset_webot_status
DEFAULT_USER_ID = "DefaultUser"
def get_webot_status_from_redis(user_id: str, chat_id: st... | null |
188,448 | from flask import request, jsonify, Response
from backend.main import app
from backend.schemas import DEFAULT_USER_ID
from backend.api.chat_webot import get_webot_from_redis, \
get_webot_status_from_redis, reset_webot_status
DEFAULT_USER_ID = "DefaultUser"
def reset_webot_status(user_id: str, chat_id: str):
w... | null |
188,449 | from flask import request, jsonify, Response
from backend.api.chat_webot import get_webot_from_redis, save_webot_to_redis
from backend.main import app
from backend.schemas import DEFAULT_USER_ID
from backend.api.language_model import get_llm
def get_webot_from_redis(user_id: str, chat_id: str, ) -> WebBrowsingExecutor... | Gets the next action to take for a given the current page HTML. |
188,450 | from flask import request, jsonify, Response
from backend.api.chat_webot import get_webot_from_redis, save_webot_to_redis
from backend.main import app
from backend.schemas import DEFAULT_USER_ID
from backend.api.language_model import get_llm
def get_webot_from_redis(user_id: str, chat_id: str, ) -> WebBrowsingExecutor... | Interrupts the current webot. |
188,451 | from flask import request, jsonify, Response
from backend.api.chat_webot import get_webot_from_redis, save_webot_to_redis
from backend.main import app
from backend.schemas import DEFAULT_USER_ID
from backend.api.language_model import get_llm
def get_webot_from_redis(user_id: str, chat_id: str, ) -> WebBrowsingExecutor... | Appends action 'error' to the current webot. |
188,452 | from typing import Dict
from flask import request, jsonify, Response
from backend.main import message_pool
from backend.app import app
from backend.api.language_model import get_llm
from backend.utils.utils import get_user_and_chat_id_from_request_json
from real_agents.adapters.executors import QuestionSuggestionExecut... | Recommends potential inputs for users. |
188,453 | from typing import List
from flask import jsonify
from backend.app import app
DATA_TOOLS = [
{
"type": "language",
"id": "1cea1f39-fe63-4b08-83d5-fa4c93db0c87",
"name": "SQLQueryBuilder",
"name_for_human": "SQL",
"pretty_name_for_human": "SQL Query Generation",
"icon"... | Gets the data tool list. |
188,454 | import base64
import copy
import json
import os
import random
import traceback
from typing import Dict, List, Union
import requests
from flask import Response, request, stream_with_context
from retrying import retry
from backend.api.language_model import get_llm
from backend.app import app
from backend.main import mess... | null |
188,455 | import base64
import copy
import json
import os
import random
import traceback
from typing import Dict, List, Union
import requests
from flask import Response, request, stream_with_context
from retrying import retry
from backend.api.language_model import get_llm
from backend.app import app
from backend.main import mess... | Returns the chat response of plugins agent. |
188,456 | from typing import Dict, Optional, List
import json
import base64
import re
import ast
import mo_sql_parsing
from pydantic import BaseModel
from real_agents.adapters.data_model import MessageDataModel, DataModel
def split_text_and_code(text: str) -> List:
pattern = r"(```[\s\S]+?```)"
result = [x for x in re.s... | null |
188,457 | from typing import Dict, Optional, List
import json
import base64
import re
import ast
import mo_sql_parsing
from pydantic import BaseModel
from real_agents.adapters.data_model import MessageDataModel, DataModel
def is_json(text: str) -> bool:
try:
json.loads(text)
return True
except json.JSONDe... | Add backticks to code blocks. |
188,458 | import redis
from typing import Any
from backend.utils.utils import logger
import os
r = redis.Redis(host=os.getenv("REDIS_SERVER"), port=6379, decode_responses=True)
QUEUE_RUNNING = "kernel_running_queue"
QUEUE_PENDING = "kernel_pending_queue"
SUBMIT_EVENT = "job_submitted"
COMPLETE_EVENT = "job_completed"
def handle_... | null |
188,459 | import json
import re
import struct
import time
from typing import Any, Dict, List, Optional, Literal
import multiprocess
import requests
from bs4 import BeautifulSoup
from backend.display_streaming import DisplayStream
from backend.main import logger, message_pool, threading_pool
from backend.utils.user_conversation_s... | null |
188,460 | import os
import sys
import base64
from pathlib import Path
from typing import Any, Dict, Tuple, Union
import pandas as pd
import tiktoken
from flask import Request
from sqlalchemy import create_engine
from PIL import Image
from loguru import logger
from real_agents.adapters.data_model import (
DatabaseDataModel,
... | null |
188,461 | import os
import sys
import base64
from pathlib import Path
from typing import Any, Dict, Tuple, Union
import pandas as pd
import tiktoken
from flask import Request
from sqlalchemy import create_engine
from PIL import Image
from loguru import logger
from real_agents.adapters.data_model import (
DatabaseDataModel,
... | We only support csv file in the current version By default, we remove columns that contain only nan values For columns that have both nan values and non-nan values, we replace nan values with the mean (number type) or the mode (other type) |
188,462 | import os
import sys
import base64
from pathlib import Path
from typing import Any, Dict, Tuple, Union
import pandas as pd
import tiktoken
from flask import Request
from sqlalchemy import create_engine
from PIL import Image
from loguru import logger
from real_agents.adapters.data_model import (
DatabaseDataModel,
... | null |
188,463 | import os
import sys
import base64
from pathlib import Path
from typing import Any, Dict, Tuple, Union
import pandas as pd
import tiktoken
from flask import Request
from sqlalchemy import create_engine
from PIL import Image
from loguru import logger
from real_agents.adapters.data_model import (
DatabaseDataModel,
... | Initialize loguru log information |
188,464 | import redis
from flask import g
import os
The provided code snippet includes necessary dependencies for implementing the `get_running_time_storage` function. Write a Python function `def get_running_time_storage()` to solve the following problem:
Connects to redis.
Here is the function:
def get_running_time_storage... | Connects to redis. |
188,465 | import pymongo
from flask import g
import os
The provided code snippet includes necessary dependencies for implementing the `close_user_conversation_storage` function. Write a Python function `def close_user_conversation_storage()` to solve the following problem:
Closes mongodb.
Here is the function:
def close_user_... | Closes mongodb. |
188,466 | import os
from transformers import GenerationMixin
from transformers.models.llama import modeling_llama
from lade.decoding import greedy_search_proxy, sample_proxy, FUNC_MAP, CONFIG_MAP
from lade.models import modeling_llama as lade_modeling_llama
from transformers import AutoConfig, AutoTokenizer, AutoModelForCausal... | null |
188,467 | import os
from transformers import GenerationMixin
from transformers.models.llama import modeling_llama
from lade.decoding import greedy_search_proxy, sample_proxy, FUNC_MAP, CONFIG_MAP
from lade.models import modeling_llama as lade_modeling_llama
from transformers import AutoConfig, AutoTokenizer, AutoModelForCausal... | null |
188,468 | import os
from transformers import GenerationMixin
from transformers.models.llama import modeling_llama
from lade.decoding import greedy_search_proxy, sample_proxy, FUNC_MAP, CONFIG_MAP
from lade.models import modeling_llama as lade_modeling_llama
from transformers import AutoConfig, AutoTokenizer, AutoModelForCausal... | null |
188,469 | import os
from transformers import GenerationMixin
from transformers.models.llama import modeling_llama
from lade.decoding import greedy_search_proxy, sample_proxy, FUNC_MAP, CONFIG_MAP
from lade.models import modeling_llama as lade_modeling_llama
from transformers import AutoConfig, AutoTokenizer, AutoModelForCausal... | null |
188,470 | import os
from transformers import GenerationMixin
from transformers.models.llama import modeling_llama
from lade.decoding import greedy_search_proxy, sample_proxy, FUNC_MAP, CONFIG_MAP
from lade.models import modeling_llama as lade_modeling_llama
from transformers import AutoConfig, AutoTokenizer, AutoModelForCausal... | null |
188,471 | import torch
import os
from .decoding import CONFIG_MAP
CONFIG_MAP = {}
def get_device():
if "LOCAL_RANK" not in CONFIG_MAP:
return 0
local_rank = CONFIG_MAP["LOCAL_RANK"]
return local_rank | null |
188,472 | import torch
import os
from .decoding import CONFIG_MAP
CONFIG_MAP = {}
def distributed():
return "DIST_WORKERS" in CONFIG_MAP and CONFIG_MAP["DIST_WORKERS"] > 1 | null |
188,473 | import math
from typing import List, Optional, Tuple, Union
import numpy as np
import einops, warnings
import torch
import torch.nn.functional as F
import torch.utils.checkpoint
from torch import nn
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
from transformers.activations import ACT2FN
from trans... | null |
188,474 | import math
from typing import List, Optional, Tuple, Union
import numpy as np
import einops, warnings
import torch
import torch.nn.functional as F
import torch.utils.checkpoint
from torch import nn
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
from transformers.activations import ACT2FN
from trans... | null |
188,475 | import math
from typing import List, Optional, Tuple, Union
import numpy as np
import einops, warnings
import torch
import torch.nn.functional as F
import torch.utils.checkpoint
from torch import nn
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
from transformers.activations import ACT2FN
from trans... | Make causal mask used for bi-directional self-attention. |
188,476 | import math
from typing import List, Optional, Tuple, Union
import numpy as np
import einops, warnings
import torch
import torch.nn.functional as F
import torch.utils.checkpoint
from torch import nn
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
from transformers.activations import ACT2FN
from trans... | Make causal mask used for bi-directional self-attention. |
188,477 | import math
from typing import List, Optional, Tuple, Union
import numpy as np
import einops, warnings
import torch
import torch.nn.functional as F
import torch.utils.checkpoint
from torch import nn
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
from transformers.activations import ACT2FN
from trans... | Applies Rotary Position Embedding to the query and key tensors. Args: q (`torch.Tensor`): The query tensor. k (`torch.Tensor`): The key tensor. cos (`torch.Tensor`): The cosine part of the rotary embedding. sin (`torch.Tensor`): The sine part of the rotary embedding. position_ids (`torch.Tensor`): The position indices ... |
188,478 | import math
from typing import List, Optional, Tuple, Union
import numpy as np
import einops, warnings
import torch
import torch.nn.functional as F
import torch.utils.checkpoint
from torch import nn
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
from transformers.activations import ACT2FN
from trans... | This is the equivalent of torch.repeat_interleave(x, dim=1, repeats=n_rep). The hidden states go from (batch, num_key_value_heads, seqlen, head_dim) to (batch, num_attention_heads, seqlen, head_dim) |
188,479 | import argparse
import json
import os
import random
import time
import shortuuid
import torch
from tqdm import tqdm
from typing import Dict, List, Optional
from fastchat.llm_judge.common import load_questions, temperature_config
from fastchat.model import get_conversation_template
from fastchat.utils import str_to_torc... | null |
188,480 | import argparse
import json
import os
import random
import time
import shortuuid
import torch
from tqdm import tqdm
from typing import Dict, List, Optional
from fastchat.llm_judge.common import load_questions, temperature_config
from fastchat.model import get_conversation_template
from fastchat.utils import str_to_torc... | Sort by question id and de-duplication |
188,481 | import argparse
import json
import os
import random
import time
import shortuuid
import torch
from tqdm import tqdm
from typing import Dict, List, Optional
from fastchat.llm_judge.common import load_questions, temperature_config
from fastchat.model import get_conversation_template
from fastchat.utils import str_to_torc... | null |
188,482 | import argparse
import json
import os
import random
import time
import shortuuid
import torch
from tqdm import tqdm
from typing import Dict, List, Optional
from fastchat.llm_judge.common import load_questions, temperature_config
from fastchat.model import get_conversation_template
from fastchat.utils import str_to_torc... | Sort by question id and de-duplication |
188,483 | import argparse
import json
import os
import random
import time
import shortuuid
import torch
from tqdm import tqdm
from typing import Dict, List, Optional
from fastchat.llm_judge.common import load_questions, temperature_config
from fastchat.model import get_conversation_template
from fastchat.utils import str_to_torc... | null |
188,485 | import argparse
import json
import os
import random
import time
import shortuuid
import torch
from tqdm import tqdm
from typing import Dict, List, Optional
from fastchat.llm_judge.common import load_questions, temperature_config
from fastchat.model import get_conversation_template
from fastchat.utils import str_to_torc... | null |
188,486 | import argparse
import json
import os
import random
import time
import shortuuid
import torch
from tqdm import tqdm
from typing import Dict, List, Optional
from fastchat.llm_judge.common import load_questions, temperature_config
from fastchat.model import get_conversation_template
from fastchat.utils import str_to_torc... | Sort by question id and de-duplication |
188,487 | import argparse
import json
import os
import random
import time
import shortuuid
import torch
from tqdm import tqdm
from typing import Dict, List, Optional
from fastchat.llm_judge.common import load_questions, temperature_config
from fastchat.model import get_conversation_template
from fastchat.utils import str_to_torc... | null |
188,489 | import base64
import datetime
import json
import os
import sys
import time
from typing import List
import tornado
from cloudcutter.protocol import mqtt
from ..crypto.tuyacipher import TuyaCipher, TuyaCipherKeyChoice
from ..device import DeviceConfig
from ..utils import object_to_json
from .transformers import ResponseT... | null |
188,490 | import base64
import datetime
import json
import os
import sys
import time
from typing import List
import tornado
from cloudcutter.protocol import mqtt
from ..crypto.tuyacipher import TuyaCipher, TuyaCipherKeyChoice
from ..device import DeviceConfig
from ..utils import object_to_json
from .transformers import ResponseT... | null |
188,491 | import json
def object_to_json(obj):
return json.dumps(obj, separators=(',', ':')) | null |
188,492 | import argparse
from datetime import datetime, timedelta
import hmac
import json
import os
import re
import sys
import time
from hashlib import sha256
from traceback import print_exc
import tornado.httpserver
import tornado.ioloop
import tornado.web
from tornado.log import enable_pretty_logging
import tinytuya.tinytuya... | null |
188,493 | import random
import socket
import string
import struct
import time
import zlib
from distutils.command.config import config
from typing import Dict
from .device import DeviceConfig
def encode_json_val(value):
encoded = []
escaped = list(map(ord, '"\\'))
escape_char = ord('\\')
for i in value:
i... | null |
188,494 | import base64
import json
import socket
import ssl
import sys
import time
import os
import tornado.httpserver
import tornado.ioloop
import tornado.web
from pskcontext import PSKContext
from tuyacipher import TuyaCipher, TuyaCipherKeyChoice
import hmac
from hashlib import sha256
def object_to_json(obj):
return json... | null |
188,495 | import base64
import json
import socket
import ssl
import sys
import time
import os
import tornado.httpserver
import tornado.ioloop
import tornado.web
from pskcontext import PSKContext
from tuyacipher import TuyaCipher
def object_to_json(obj):
return json.dumps(obj, separators=(',',':')) | null |
188,496 | import tinytuya
import json
import time
tuyadevices = []
for i in tuyadevices:
item = {}
name = i['name']
(ip, ver) = getIP(devices, i['id'])
item['name'] = name
item['ip'] = ip
item['ver'] = ver
item['id'] = i['id']
item['key'] = i['key']
if (ip == 0):
print(" %s[%s] - %s... | null |
188,497 | import tinytuya
import json
import time
def getIP(d, gwid):
for ip in d:
if (gwid == d[ip]['gwId']):
return (ip, d[ip]['version'])
return (0, 0) | null |
188,498 | import tinytuya
import json
import time
print("%-25s %-24s %-16s %-17s %-5s" % ("Name","ID", "IP","Key","Version"))
for item in data["devices"]:
print("%-25.25s %-24s %-16s %-17s %-5s" % (
item["name"],
item["id"],
item["ip"],
item["key"],
item["ver"]))
for item in data["devi... | null |
188,499 | import tinytuya
import json
import time
print("%-25s %-24s %-16s %-17s %-5s" % ("Name","ID", "IP","Key","Version"))
for item in data["devices"]:
print("%-25.25s %-24s %-16s %-17s %-5s" % (
item["name"],
item["id"],
item["ip"],
item["key"],
item["ver"]))
for item in data["devi... | null |
188,500 | import tinytuya
import colorsys
import time
id = DEVICEID
cmd_code = 'colour_data_v2'
c = tinytuya.Cloud()
def set_color(rgb):
hsv = colorsys.rgb_to_hsv(rgb[0] / 255.0, rgb[1] / 255.0, rgb[2] / 255.0)
commands = {
'commands': [{
'code': cmd_code,
'value': {
"h":... | null |
188,501 | import colorsys
from dataclasses import dataclass
from typing import Tuple, List, Literal
import tinytuya
def tuyahex2hsv(val: str):
return tinytuya.BulbDevice._hexvalue_to_hsv(val, bulb="B") | null |
188,502 | import colorsys
from dataclasses import dataclass
from typing import Tuple, List, Literal
import tinytuya
def hsv2tuyahex(h: float, s: float, v: float):
(r, g, b) = colorsys.hsv_to_rgb(h, s, v)
hexvalue = tinytuya.BulbDevice._rgb_to_hexvalue(
r * 255.0, g * 255.0, b * 255.0, bulb='B'
)
return h... | null |
188,503 | import requests
import time
import hmac
import hashlib
import json
import pprint
import logging
import tinytuya
try:
input = raw_input
except NameError:
pass
def tuyaPlatform(apiRegion, apiKey, apiSecret, uri, token=None, new_sign_algorithm=True, body=None, headers=None):
"""Tuya IoT Platform Data Access
... | TinyTuya Setup Wizard Tuya based WiFi smart devices Parameter: color = True or False, print output in color [Default: True] retries = Number of retries to find IP address of Tuya Devices Description Setup Wizard will prompt user for Tuya IoT Developer credentials and will gather all of the Device IDs and their Local KE... |
188,504 | import json
import sys
from enum import Enum
from glob import glob
from os import listdir, makedirs
from os.path import abspath, basename, isdir, isfile, join
import click
import inquirer
import requests
def ask_options(text, options):
res = inquirer.prompt(
[
inquirer.List(
"res... | null |
188,505 | import json
import sys
from enum import Enum
from glob import glob
from os import listdir, makedirs
from os.path import abspath, basename, isdir, isfile, join
import click
import inquirer
import requests
def cli(ctx, workdir: str, output: click.File):
ctx.ensure_object(dict)
ctx.obj["firmware_dir"] = join(work... | null |
188,506 | import json
import sys
from enum import Enum
from glob import glob
from os import listdir, makedirs
from os.path import abspath, basename, isdir, isfile, join
import click
import inquirer
import requests
def download_profile(device_slug):
def save_profile(profile_dir, device, profile):
def load_profile(profile_dir):
de... | null |
188,507 | import json
import sys
from enum import Enum
from glob import glob
from os import listdir, makedirs
from os.path import abspath, basename, isdir, isfile, join
import click
import inquirer
import requests
def api_get(path):
with requests.get(f"https://tuya-cloudcutter.github.io/api/{path}") as r:
if r.status... | null |
188,508 | import json
import sys
from enum import Enum
from glob import glob
from os import listdir, makedirs
from os.path import abspath, basename, isdir, isfile, join
import click
import inquirer
import requests
class FirmwareType(Enum):
UF2_UG_SUFFIX = "-extracted.ug.bin"
def ask_options(text, options):
def validate_firmware_... | null |
188,509 | import json
import sys
from enum import Enum
from glob import glob
from os import listdir, makedirs
from os.path import abspath, basename, isdir, isfile, join
import click
import inquirer
import requests
class FirmwareType(Enum):
INVALID = 0
IGNORED_HEADER = 1
IGNORED_FILENAME = 2
VALID_UG = 3
VALID... | null |
188,510 | import json
import os.path
import sys
def dump(file):
def run(storage_file: str):
if not storage_file:
print('Usage: python parse_storage.py <storage.json file>')
sys.exit(1)
if os.path.exists(storage_file):
dump(storage_file)
else:
print('[!] Storage file not found')
... | null |
188,511 | import re
import sys
from os.path import basename, dirname, exists
def dump():
global base_name, base_folder
base_name = basename(appcode_path)[:-23]
base_folder = dirname(appcode_path)
sdk_line = ''
if b'< TUYA IOT SDK' in appcode:
sdk_line = read_until_null_or_newline(appcode.index(b'< TUY... | null |
188,512 | import argparse
import os
import os.path
import sys
import bk7231tools
def load_file(filename: str):
def run(full_encrypted_file: str):
if full_encrypted_file is None or full_encrypted_file == '':
print('Usage: python extract.py <full 2M encrypted bin file>')
sys.exit(1)
if not full_encrypted_... | null |
188,513 | import json
import os
import socket
import struct
import sys
import threading
import time
from tuya_api_connection import TuyaAPIConnection
def print_help():
print('Usage: python check_upgrade.py --input <uuid> <auth_key> <dev_id> <sec_key> <token>')
print(' or: python check_upgrade.py --directory <directory... | null |
188,514 | import json
import os
import socket
import struct
import sys
import threading
import time
from tuya_api_connection import TuyaAPIConnection
def run(directory: str, output_file_prefix: str, uuid: str, auth_key: str, dev_id: str, sec_key: str, token: str = None):
if uuid is None or len(uuid) != 16:
print_and_... | null |
188,515 | import json
import os
import socket
import struct
import sys
import threading
import time
from tuya_api_connection import TuyaAPIConnection
def read_single_line_file(path):
with open(path, 'r') as file:
fileContents = file.read()
if fileContents.__contains__('\n'):
return None
re... | null |
188,516 | import json
import os
import os.path
import sys
full_path: str
base_name: str
def assemble():
if os.path.exists(full_path) == False:
print("[!] Unable to find device directory name")
return
# All should have these
manufacturer = base_name.split('_')[0].replace('-', ' ').replace(" ", "-")
... | null |
188,517 | import os.path
import sys
def walk_app_code():
print(f"[+] Searching for known exploit patterns")
if b'TUYA' not in appcode:
raise RuntimeError('[!] App binary does not appear to be correctly decrypted, or has no Tuya references.')
# Older versions of BK7231T, BS version 30.04, SDK 2.0.0
if b'TU... | null |
188,518 | import json
import os
import socket
import struct
import sys
import threading
import time
from tuya_api_connection import TuyaAPIConnection
def print_help():
print('Usage: python pull_schema.py --input <uuid> <auth_key> <product_key or empty string ""> <firmware_key or empty string ""> <software_version> <baseline... | null |
188,519 | import json
import os
import socket
import struct
import sys
import threading
import time
from tuya_api_connection import TuyaAPIConnection
def run(directory: str, output_file_prefix: str, uuid: str, auth_key: str, product_key: str, firmware_key: str, software_version: str, baseline_version: str = '40.00', cad_version:... | null |
188,520 | import json
import os
import socket
import struct
import sys
import threading
import time
from tuya_api_connection import TuyaAPIConnection
def read_single_line_file(path):
with open(path, 'r') as file:
fileContents = file.read()
if fileContents.__contains__('\n'):
return None
re... | null |
188,521 | import os.path
import sys
import extract
import generate_profile_classic
import haxomatic
import process_app
import process_storage
import pull_schema
def print_filename_instructions():
print('Encrypted bin name must be in the pattern of Manufacturer-Name_Model-and-device-description')
print('Use dashes in pla... | null |
188,522 | import struct
import zlib
import socket
MAX_CONFIG_PACKET_PAYLOAD_LEN = 0xE8
def build_network_config_packet(payload):
if len(payload) > MAX_CONFIG_PACKET_PAYLOAD_LEN:
raise ValueError('Payload is too long!')
# NOTE
# fr_num and crc do not seem to be used in the disas
# calculating them anyway... | null |
188,523 | import struct
import zlib
import socket
VICTIM_IP = '192.168.175.1'
VICTIM_PORT = 6669
def send_network_config_datagram(datagram):
client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
client.sendto(datagram, (VICTIM_IP, VICTIM_PORT)) | null |
188,524 | import struct
import zlib
import socket
def encode_json_val(value):
encoded = []
escaped = list(map(ord, '"\\'))
escape_char = ord('\\')
for i in value:
if i in escaped:
encoded.append(escape_char)
encoded.append(i)
return bytes(encoded) | null |
188,525 | import struct
import zlib
import socket
def check_valid_payload(value):
eq_zero = lambda x: x == 0
if any(map(eq_zero, value)):
print('[!] At least one null byte detected in payload. Clobbering will stop before that.')
return value | null |
188,526 | from __future__ import annotations
import rich.repr
from abc import ABC, abstractmethod
from dataclasses import dataclass
import platform
from threading import Event, Lock, Thread
from typing import Callable, TYPE_CHECKING
class WatcherBase(ABC):
"""Watches files for changes."""
def __init__(self) -> None:
... | Return an Watcher appropriate for the OS. |
188,527 | from rich.highlighter import RegexHighlighter
from rich.text import Text
The provided code snippet includes necessary dependencies for implementing the `_combine_regex` function. Write a Python function `def _combine_regex(*regexes: str) -> str` to solve the following problem:
Combine a number of regexes in to a singl... | Combine a number of regexes in to a single regex. Returns: str: New regex with all regexes ORed together. |
188,528 | from __future__ import annotations
from importlib.metadata import version
import os
import sys
import click
from toolong.ui import UI
class UI(App):
"""The top level App object."""
def sort_paths(cls, paths: list[str]) -> list[str]:
return sorted(paths, key=CompareTokens)
def __init__(
se... | View / tail / search log files. |
188,529 | import webbrowser
from importlib.metadata import version
from rich.text import Text
from textual import on
from textual.app import ComposeResult
from textual.containers import Center, VerticalScroll
from textual.screen import ModalScreen
from textual.widgets import Static, Markdown, Footer
TITLE = rf"""
_______ ... | Get the title, with a rainbow effect. |
188,530 | from __future__ import annotations
from datetime import datetime
import re
from typing import Callable, NamedTuple
def parse(line: str) -> tuple[TimestampFormat | None, datetime | None]:
"""Attempt to parse a timestamp."""
for timestamp in TIMESTAMP_FORMATS:
regex, parse_callable = timestamp
mat... | null |
188,531 | import os
from pkg_resources import parse_version
from setuptools import find_packages, setup
pwd = os.path.dirname(__file__)
def readme():
with open(os.path.join(pwd, 'README.md'), encoding='utf-8') as f:
content = f.read()
return content | null |
188,532 | import os
from pkg_resources import parse_version
from setuptools import find_packages, setup
pwd = os.path.dirname(__file__)
version_file = 'mmdeploy/version.py'
def get_version():
with open(os.path.join(pwd, version_file), 'r') as f:
exec(compile(f.read(), version_file, 'exec'))
return locals()['__ve... | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.