id
int64
0
190k
prompt
stringlengths
21
13.4M
docstring
stringlengths
1
12k
17,001
import json from functools import wraps from flask import abort, current_app, request from flask_login import current_user from controllers.console.workspace.error import AccountNotInitializedError from services.feature_service import FeatureService from services.operation_service import OperationService class Feature...
null
17,002
import json from functools import wraps from flask import abort, current_app, request from flask_login import current_user from controllers.console.workspace.error import AccountNotInitializedError from services.feature_service import FeatureService from services.operation_service import OperationService class Feature...
null
17,003
from datetime import datetime import pytz from flask_login import current_user from flask_restful import Resource, marshal_with, reqparse from flask_restful.inputs import int_range from sqlalchemy import func, or_ from sqlalchemy.orm import joinedload from werkzeug.exceptions import NotFound from controllers.console im...
null
17,004
import json import logging from datetime import datetime from flask_login import current_user from flask_restful import Resource, abort, inputs, marshal_with, reqparse from werkzeug.exceptions import Forbidden from constants.languages import demo_model_templates, languages from constants.model_template import model_tem...
null
17,005
from flask_login import current_user from flask_restful import Resource, marshal_with, reqparse from werkzeug.exceptions import Forbidden, NotFound from constants.languages import supported_language from controllers.console import api from controllers.console.app import _get_app from controllers.console.setup import se...
null
17,006
import json import logging from collections.abc import Generator from typing import Union from flask import Response, stream_with_context from flask_login import current_user from flask_restful import Resource, fields, marshal_with, reqparse from flask_restful.inputs import int_range from werkzeug.exceptions import For...
null
17,007
import json import logging from collections.abc import Generator from typing import Union import flask_login from flask import Response, stream_with_context from flask_restful import Resource, reqparse from werkzeug.exceptions import InternalServerError, NotFound import services from controllers.console import api from...
null
17,008
import flask_restful from flask_login import current_user from flask_restful import Resource, fields, marshal_with from werkzeug.exceptions import Forbidden from extensions.ext_database import db from libs.helper import TimestampField from libs.login import login_required from models.dataset import Dataset from models....
null
17,009
import flask_restful from flask import current_app, request from flask_login import current_user from flask_restful import Resource, marshal, marshal_with, reqparse from werkzeug.exceptions import Forbidden, NotFound import services from controllers.console import api from controllers.console.apikey import api_key_fiel...
null
17,010
import flask_restful from flask import current_app, request from flask_login import current_user from flask_restful import Resource, marshal, marshal_with, reqparse from werkzeug.exceptions import Forbidden, NotFound import services from controllers.console import api from controllers.console.apikey import api_key_fiel...
null
17,011
from core.generator.llm_generator import LLMGenerator from events.message_event import message_was_created from extensions.ext_database import db class LLMGenerator: def generate_conversation_name(cls, tenant_id: str, query): prompt = CONVERSATION_TITLE_PROMPT if len(query) > 2000: que...
null
17,012
from events.app_event import app_was_deleted from extensions.ext_database import db from models.model import InstalledApp db = SQLAlchemy() class InstalledApp(db.Model): __tablename__ = 'installed_apps' __table_args__ = ( db.PrimaryKeyConstraint('id', name='installed_app_pkey'), db.Index('inst...
null
17,013
from core.entities.application_entities import ApplicationGenerateEntity from core.entities.provider_entities import QuotaUnit from events.message_event import message_was_created from extensions.ext_database import db from models.provider import Provider, ProviderType class ApplicationGenerateEntity(BaseModel): "...
null
17,014
import datetime import logging import time import click from werkzeug.exceptions import NotFound from core.indexing_runner import DocumentIsPausedException, IndexingRunner from events.event_handlers.document_index_event import document_index_created from extensions.ext_database import db from models.dataset import Docu...
null
17,015
from events.app_event import app_was_created from extensions.ext_database import db from models.model import InstalledApp db = SQLAlchemy() class InstalledApp(db.Model): __tablename__ = 'installed_apps' __table_args__ = ( db.PrimaryKeyConstraint('id', name='installed_app_pkey'), db.Index('inst...
Create an installed app when an app is created.
17,016
from events.app_event import app_model_config_was_updated from extensions.ext_database import db from models.dataset import AppDatasetJoin from models.model import AppModelConfig def get_dataset_ids_from_model_config(app_model_config: AppModelConfig) -> set: dataset_ids = set() if not app_model_config: ...
null
17,017
from events.document_event import document_was_deleted from tasks.clean_document_task import clean_document_task def clean_document_task(document_id: str, dataset_id: str, doc_form: str): """ Clean document when document deleted. :param document_id: document id :param dataset_id: dataset id :param ...
null
17,018
from datetime import datetime from core.entities.application_entities import ApplicationGenerateEntity from events.message_event import message_was_created from extensions.ext_database import db from models.provider import Provider class ApplicationGenerateEntity(BaseModel): """ Application Generate Entity. ...
null
17,019
from events.dataset_event import dataset_was_deleted from tasks.clean_dataset_task import clean_dataset_task def clean_dataset_task(dataset_id: str, tenant_id: str, indexing_technique: str, index_struct: str, collection_binding_id: str, doc_form: str): def handle(sender, **kwargs): dataset ...
null
17,020
import os import dotenv def get_env(key): return os.environ.get(key, DEFAULTS.get(key)) def get_bool_env(key): value = get_env(key) return value.lower() == 'true' if value is not None else False
null
17,021
import os import dotenv def get_env(key): return os.environ.get(key, DEFAULTS.get(key)) def get_cors_allow_origins(env, default): cors_allow_origins = [] if get_env(env): for origin in get_env(env).split(','): cors_allow_origins.append(origin) else: cors_allow_origins = [def...
null
17,022
import datetime import logging import time import click from celery import shared_task from flask import current_app from core.indexing_runner import DocumentIsPausedException, IndexingRunner from extensions.ext_database import db from models.dataset import Dataset, Document from services.feature_service import Feature...
Async process document :param dataset_id: :param document_ids: Usage: document_indexing_task.delay(dataset_id, document_id)
17,023
import logging import time import click from celery import shared_task from core.rag.index_processor.index_processor_factory import IndexProcessorFactory from core.rag.models.document import Document from extensions.ext_database import db from models.dataset import Dataset, DocumentSegment from models.dataset import Do...
Async deal dataset from index :param dataset_id: dataset_id :param action: action Usage: deal_dataset_vector_index_task.delay(dataset_id, action)
17,024
import logging import time import click from celery import shared_task from werkzeug.exceptions import NotFound from core.rag.index_processor.index_processor_factory import IndexProcessorFactory from extensions.ext_database import db from extensions.ext_redis import redis_client from models.dataset import Document, Doc...
Async Remove document from index :param document_id: document id Usage: remove_document_from_index.delay(document_id)
17,025
import logging import time import click from celery import shared_task from core.rag.index_processor.index_processor_factory import IndexProcessorFactory from extensions.ext_database import db from extensions.ext_redis import redis_client from models.dataset import Dataset, Document class IndexProcessorFactory: ""...
Async Remove segment from index :param segment_id: :param index_node_id: :param dataset_id: :param document_id: Usage: delete_segment_from_index_task.delay(segment_id)
17,026
import datetime import logging import time from typing import Optional import click from celery import shared_task from werkzeug.exceptions import NotFound from core.rag.index_processor.index_processor_factory import IndexProcessorFactory from core.rag.models.document import Document from extensions.ext_database import...
Async create segment to index :param segment_id: :param keywords: Usage: create_segment_to_index_task.delay(segment_id)
17,027
import datetime import logging import time import click from celery import shared_task from werkzeug.exceptions import NotFound from core.indexing_runner import DocumentIsPausedException, IndexingRunner from core.rag.index_processor.index_processor_factory import IndexProcessorFactory from extensions.ext_database impor...
Async update document :param dataset_id: :param document_id: Usage: document_indexing_update_task.delay(dataset_id, document_id)
17,028
import datetime import logging import time import click from celery import shared_task from werkzeug.exceptions import NotFound from core.indexing_runner import DocumentIsPausedException, IndexingRunner from core.rag.extractor.notion_extractor import NotionExtractor from core.rag.index_processor.index_processor_factory...
Async update document :param dataset_id: :param document_id: Usage: document_indexing_sync_task.delay(dataset_id, document_id)
17,029
import logging import time import click from celery import shared_task from werkzeug.exceptions import NotFound from core.indexing_runner import DocumentIsPausedException, IndexingRunner from extensions.ext_database import db from models.dataset import Document class IndexingRunner: def __init__(self): se...
Async recover document :param dataset_id: :param document_id: Usage: recover_document_indexing_task.delay(dataset_id, document_id)
17,030
import datetime import logging import time import click from celery import shared_task from werkzeug.exceptions import NotFound from core.rag.index_processor.index_processor_factory import IndexProcessorFactory from core.rag.models.document import Document from extensions.ext_database import db from extensions.ext_redi...
Async Add document to index :param document_id: Usage: add_document_to_index.delay(document_id)
17,031
import logging import time import click from celery import shared_task from core.rag.index_processor.index_processor_factory import IndexProcessorFactory from extensions.ext_database import db from models.dataset import Dataset, Document, DocumentSegment class IndexProcessorFactory: """IndexProcessorInit. """ ...
Clean document when document deleted. :param document_ids: document ids :param dataset_id: dataset id Usage: clean_notion_document_task.delay(document_ids, dataset_id)
17,032
import datetime import logging import time import uuid from typing import cast import click from celery import shared_task from sqlalchemy import func from core.indexing_runner import IndexingRunner from core.model_manager import ModelManager from core.model_runtime.entities.model_entities import ModelType from core.mo...
Async batch create segment to index :param job_id: :param content: :param dataset_id: :param document_id: :param tenant_id: :param user_id: Usage: batch_create_segment_to_index_task.delay(segment_id)
17,033
import logging import time import click from celery import shared_task from flask import current_app, render_template from extensions.ext_mail import mail mail = Mail() The provided code snippet includes necessary dependencies for implementing the `send_invite_member_mail_task` function. Write a Python function `def ...
Async Send invite member mail :param language :param to :param token :param inviter_name :param workspace_name Usage: send_invite_member_mail_task.delay(langauge, to, token, inviter_name, workspace_name)
17,034
import logging import time import click from celery import shared_task from werkzeug.exceptions import NotFound from core.rag.index_processor.index_processor_factory import IndexProcessorFactory from extensions.ext_database import db from extensions.ext_redis import redis_client from models.dataset import DocumentSegme...
Async disable segment from index :param segment_id: Usage: disable_segment_from_index_task.delay(segment_id)
17,035
import datetime import logging import time import click from celery import shared_task from werkzeug.exceptions import NotFound from core.rag.index_processor.index_processor_factory import IndexProcessorFactory from core.rag.models.document import Document from extensions.ext_database import db from extensions.ext_redi...
Async enable segment to index :param segment_id: Usage: enable_segment_to_index_task.delay(segment_id)
17,036
import logging import time import click from celery import shared_task from core.rag.datasource.vdb.vector_factory import Vector from models.dataset import Dataset from services.dataset_service import DatasetCollectionBindingService class Vector: def __init__(self, dataset: Dataset, attributes: list = None): ...
Async delete annotation index task
17,037
import logging import time import click from celery import shared_task from core.rag.datasource.vdb.vector_factory import Vector from core.rag.models.document import Document from models.dataset import Dataset from services.dataset_service import DatasetCollectionBindingService class Vector: def __init__(self, dat...
Add annotation to index. :param annotation_id: annotation id :param question: question :param tenant_id: tenant id :param app_id: app id :param collection_binding_id: embedding binding id Usage: clean_dataset_task.delay(dataset_id, tenant_id, indexing_technique, index_struct)
17,038
import datetime import logging import time import click from celery import shared_task from werkzeug.exceptions import NotFound from core.rag.datasource.vdb.vector_factory import Vector from core.rag.models.document import Document from extensions.ext_database import db from extensions.ext_redis import redis_client fro...
Async enable annotation reply task
17,039
import logging import time import click from celery import shared_task from core.rag.datasource.vdb.vector_factory import Vector from core.rag.models.document import Document from models.dataset import Dataset from services.dataset_service import DatasetCollectionBindingService class Vector: def __init__(self, dat...
Update annotation to index. :param annotation_id: annotation id :param question: question :param tenant_id: tenant id :param app_id: app id :param collection_binding_id: embedding binding id Usage: clean_dataset_task.delay(dataset_id, tenant_id, indexing_technique, index_struct)
17,040
import logging import time import click from celery import shared_task from werkzeug.exceptions import NotFound from core.rag.datasource.vdb.vector_factory import Vector from core.rag.models.document import Document from extensions.ext_database import db from extensions.ext_redis import redis_client from models.dataset...
Add annotation to index. :param job_id: job_id :param content_list: content list :param tenant_id: tenant id :param app_id: app id :param user_id: user_id
17,041
import logging import time import click from celery import shared_task from werkzeug.exceptions import NotFound from core.rag.datasource.vdb.vector_factory import Vector from extensions.ext_database import db from extensions.ext_redis import redis_client from models.dataset import Dataset from models.model import App, ...
Async enable annotation reply task
17,042
import datetime import time import click from flask import current_app from werkzeug.exceptions import NotFound import app from extensions.ext_database import db from models.dataset import Embedding db = SQLAlchemy() class Embedding(db.Model): def set_embedding(self, embedding_data: list[float]): def get_em...
null
17,043
import datetime import time import click from flask import current_app from werkzeug.exceptions import NotFound import app from core.rag.index_processor.index_processor_factory import IndexProcessorFactory from extensions.ext_database import db from models.dataset import Dataset, DatasetQuery, Document class IndexProc...
null
17,044
import nbformat from nbformat import v4 as nbf import ansi2html import os import argparse nb = nbf.new_notebook() def write_to_notebook(): if args.notebook: with open(notebook_path, 'w', encoding='utf-8') as f: nbformat.write(nb, f) def add_code_cell_to_notebook(code): code_cell = nbf.new_c...
null
17,045
import nbformat from nbformat import v4 as nbf import ansi2html import os import argparse nb = nbf.new_notebook() def write_to_notebook(): if args.notebook: with open(notebook_path, 'w', encoding='utf-8') as f: nbformat.write(nb, f) def add_markdown_to_notebook(content, title=None): if titl...
null
17,046
from response_parser import * import copy import json from tqdm import tqdm import logging import argparse import os def initialization(state_dict: Dict) -> None: if not os.path.exists('cache'): os.mkdir('cache') if state_dict["bot_backend"] is None: state_dict["bot_backend"] = BotBackend() ...
null
17,047
from response_parser import * import copy import json from tqdm import tqdm import logging import argparse import os def get_bot_backend(state_dict: Dict) -> BotBackend: def switch_to_gpt4(state_dict: Dict, whether_switch: bool) -> None: bot_backend = get_bot_backend(state_dict) if whether_switch: bot_...
null
17,048
from response_parser import * import copy import json from tqdm import tqdm import logging import argparse import os def get_bot_backend(state_dict: Dict) -> BotBackend: return state_dict["bot_backend"] def add_text(state_dict, history, text): bot_backend = get_bot_backend(state_dict) bot_backend.add_text_...
null
17,049
from response_parser import * import copy import json from tqdm import tqdm import logging import argparse import os def get_bot_backend(state_dict: Dict) -> BotBackend: return state_dict["bot_backend"] def bot(state_dict, history): bot_backend = get_bot_backend(state_dict) while bot_backend.finish_reason ...
null
17,050
import json import copy import shutil from jupyter_backend import * from tools import * from typing import * from notebook_serializer import add_markdown_to_notebook, add_code_cell_to_notebook if not config['API_KEY']: config['API_KEY'] = os.getenv('OPENAI_API_KEY') os.unsetenv('OPENAI_API_KEY') def get_config...
null
17,051
import json import copy import shutil from jupyter_backend import * from tools import * from typing import * from notebook_serializer import add_markdown_to_notebook, add_code_cell_to_notebook def config_openai_api(api_type, api_base, api_version, api_key): openai.api_type = api_type openai.api_base = api_base...
null
17,052
import openai import base64 import os import io import time from PIL import Image from abc import ABCMeta, abstractmethod def create_vision_chat_completion(vision_model, base64_image, prompt): try: response = openai.ChatCompletion.create( model=vision_model, messages=[ ...
null
17,053
import openai import base64 import os import io import time from PIL import Image from abc import ABCMeta, abstractmethod def create_image(prompt): try: response = openai.Image.create( model="dall-e-3", prompt=prompt, response_format="b64_json" ) return re...
null
17,054
import openai import base64 import os import io import time from PIL import Image from abc import ABCMeta, abstractmethod class ImageInquireTool(Tool): def support(self): return self.config['model']['GPT-4V']['available'] def get_tool_data(self): return { "tool_name": "inquire_image"...
null
17,055
from bot_backend import * import base64 import time import tiktoken from notebook_serializer import add_code_cell_error_to_notebook, add_image_to_notebook, add_code_cell_output_to_notebook def get_conversation_slice(conversation, model, encoding_for_which_model, min_output_tokens_count=500): def chat_completion(bot_ba...
null
17,056
from bot_backend import * import base64 import time import tiktoken from notebook_serializer import add_code_cell_error_to_notebook, add_image_to_notebook, add_code_cell_output_to_notebook def get_image_size(image_path): with Image.open(image_path) as img: width, height = img.size return width, height ...
null
17,057
from bot_backend import * import base64 import time import tiktoken from notebook_serializer import add_code_cell_error_to_notebook, add_image_to_notebook, add_code_cell_output_to_notebook def add_function_response_to_bot_history(hypertext_to_display, history): if hypertext_to_display is not None: if histo...
null
17,058
from bot_backend import * import base64 import time import tiktoken from notebook_serializer import add_code_cell_error_to_notebook, add_image_to_notebook, add_code_cell_output_to_notebook The provided code snippet includes necessary dependencies for implementing the `parse_json` function. Write a Python function `def...
GPT may generate non-standard JSON format string, which contains '\n' in string value, leading to error when using `json.loads()`. Here we implement a parser to extract code directly from non-standard JSON string. :return: code string if successfully parsed otherwise None
17,059
def initialization(state_dict: Dict) -> None: if not os.path.exists('cache'): os.mkdir('cache') if state_dict["bot_backend"] is None: state_dict["bot_backend"] = BotBackend() if 'OPENAI_API_KEY' in os.environ: del os.environ['OPENAI_API_KEY']
null
17,060
import gradio as gr from response_parser import * def get_bot_backend(state_dict: Dict) -> BotBackend: return state_dict["bot_backend"] f __name__ == '__main__': config = get_config() with gr.Blocks(theme=gr.themes.Base()) as block: """ Reference: https://www.gradio.app/guides/creating-a-cha...
null
17,061
import gradio as gr from response_parser import * def get_bot_backend(state_dict: Dict) -> BotBackend: return state_dict["bot_backend"] f __name__ == '__main__': config = get_config() with gr.Blocks(theme=gr.themes.Base()) as block: """ Reference: https://www.gradio.app/guides/creating-a-cha...
null
17,062
import gradio as gr from response_parser import * def get_bot_backend(state_dict: Dict) -> BotBackend: return state_dict["bot_backend"] f __name__ == '__main__': config = get_config() with gr.Blocks(theme=gr.themes.Base()) as block: """ Reference: https://www.gradio.app/guides/creating-a-cha...
null
17,063
import gradio as gr from response_parser import * def get_bot_backend(state_dict: Dict) -> BotBackend: f __name__ == '__main__': config = get_config() with gr.Blocks(theme=gr.themes.Base()) as block: """ Reference: https://www.gradio.app/guides/creating-a-chatbot-fast """ # UI co...
null
17,064
import gradio as gr from response_parser import * def get_bot_backend(state_dict: Dict) -> BotBackend: return state_dict["bot_backend"] f __name__ == '__main__': config = get_config() with gr.Blocks(theme=gr.themes.Base()) as block: """ Reference: https://www.gradio.app/guides/creating-a-cha...
null
17,065
import gradio as gr from response_parser import * def get_bot_backend(state_dict: Dict) -> BotBackend: return state_dict["bot_backend"] f __name__ == '__main__': config = get_config() with gr.Blocks(theme=gr.themes.Base()) as block: """ Reference: https://www.gradio.app/guides/creating-a-cha...
null
17,066
def restart_ui(history: List) -> Tuple[List, Dict, Dict, Dict, Dict, Dict, Dict]: history.clear() return ( history, gr.Textbox.update(value="", interactive=False), gr.Button.update(interactive=False), gr.Button.update(interactive=False), gr.Button.update(interactive=Fal...
null
17,067
import gradio as gr from response_parser import * def get_bot_backend(state_dict: Dict) -> BotBackend: f __name__ == '__main__': config = get_config() with gr.Blocks(theme=gr.themes.Base()) as block: """ Reference: https://www.gradio.app/guides/creating-a-chatbot-fast """ # UI co...
null
17,068
import gradio as gr from response_parser import * def get_bot_backend(state_dict: Dict) -> BotBackend: return state_dict["bot_backend"] def stop_generating(state_dict: Dict) -> None: bot_backend = get_bot_backend(state_dict) if bot_backend.code_executing: bot_backend.send_interrupt_signal() else...
null
17,069
import jupyter_client import re def delete_color_control_char(string): ansi_escape = re.compile(r'(\x9B|\x1B\[)[0-?]*[ -\/]*[@-~]') return ansi_escape.sub('', string)
null
17,070
from functional import * class ChoiceHandler: strategies = [ RoleChoiceStrategy, ContentChoiceStrategy, NameFunctionCallChoiceStrategy, ArgumentsFunctionCallChoiceStrategy, FinishReasonChoiceStrategy ] def __init__(self, choice): self.choice = choice def handle(self, bot_backend:...
:return: history, whether_exit
17,071
import argparse import os import torch from pathlib import Path from tqdm import tqdm from transformers import AutoTokenizer, AutoModelForCausalLM import logging from evalplus.data import get_human_eval_plus,get_mbpp_plus, write_jsonl def generate_one(example, lang, tokenizer, model, name, flags): if flags.dataset=...
null
17,072
import argparse import os import torch from pathlib import Path from tqdm import tqdm import logging from evalplus.data import (get_human_eval_plus, write_jsonl, get_human_eval_plus_hash, get_mbpp_plus, get_mbpp_plus_hash, ) from utils import sanitize_solution,check_correctness,get_groundtruth,SUCCESS ...
null
17,073
import argparse import os import torch from pathlib import Path from tqdm import tqdm import json from transformers import AutoTokenizer, AutoModelForCausalLM import logging from evalplus.data import (get_human_eval_plus, write_jsonl, get_human_eval_plus_hash, get_mbpp_plus, get_mbpp_plus_hash, ) from ...
null
17,074
import argparse import os import torch from pathlib import Path from tqdm import tqdm from transformers import AutoTokenizer, AutoModelForCausalLM import logging from evalplus.data import (get_human_eval_plus, write_jsonl, get_human_eval_plus_hash, get_mbpp_plus, get_mbpp_plus_hash, ) from utils import...
null
17,075
import argparse import os import torch from pathlib import Path from tqdm import tqdm import json from transformers import AutoTokenizer, AutoModelForCausalLM import logging from evalplus.data import (get_human_eval_plus, write_jsonl, get_human_eval_plus_hash, get_mbpp_plus, get_mbpp_plus_hash, ) from ...
null
17,076
import os from evalplus.sanitize import sanitize from typing import Any, Dict, List, Optional, Tuple, Union import itertools import multiprocessing import time from multiprocessing import Array, Value from typing import Any, Dict, List, Tuple, Union import numpy as np import pickle from evalplus.data.utils import CACHE...
null
17,077
import os from evalplus.sanitize import sanitize from typing import Any, Dict, List, Optional, Tuple, Union import itertools import multiprocessing import time from multiprocessing import Array, Value from typing import Any, Dict, List, Tuple, Union import numpy as np import pickle from evalplus.data.utils import CACHE...
null
17,078
import json import os from abc import ABC, abstractmethod from typing import List from warnings import warn import openai import torch from transformers import ( AutoModelForCausalLM, AutoModelForSeq2SeqLM, AutoTokenizer, StoppingCriteria, StoppingCriteriaList, ) from vllm import LLM, SamplingParams...
null
17,079
import argparse import os from os import PathLike from model import DecoderBase, make_model from rich.progress import ( BarColumn, MofNCompleteColumn, Progress, TextColumn, TimeElapsedColumn, ) def construct_contract_prompt(prompt: str, contract_type: str, contract: str) -> str: if contract_type...
null
17,080
import json import os import pathlib import shutil from importlib import util from inspect import getmembers, isfunction from typing import Tuple from tempdir import TempDir from evalplus.data.mbpp import get_mbpp, mbpp_serialize_inputs GROUNDTRUTH_MBPP_PATH = pathlib.Path(__file__).parent.parent.parent / "groundtruth/...
null
17,081
import json import os import pathlib import shutil from importlib import util from inspect import getmembers, isfunction from typing import Tuple from tempdir import TempDir from evalplus.data.mbpp import get_mbpp, mbpp_serialize_inputs GROUNDTRUTH_MBPP_PATH = pathlib.Path(__file__).parent.parent.parent / "groundtruth/...
null
17,082
import json import os import pathlib import shutil from importlib import util from inspect import getmembers, isfunction from typing import Tuple from tempdir import TempDir from evalplus.data.mbpp import get_mbpp, mbpp_serialize_inputs def _ret(entry_point) -> str: def instrument_inputs(code, entry_point, test_code) ...
null
17,083
import json import os import pathlib import shutil from importlib import util from inspect import getmembers, isfunction from typing import Tuple from tempdir import TempDir from evalplus.data.mbpp import get_mbpp, mbpp_serialize_inputs def get_atol(task_id: int) -> float: float_ans_list = [ 82, 85...
null
17,084
import ast import inspect import json import multiprocessing import sys from concurrent.futures import ProcessPoolExecutor, as_completed from tqdm import tqdm from evalplus.data.mbpp import ( MBPP_PLUS_VERSION, get_mbpp, get_mbpp_plus, get_mbpp_plus_hash, ) from evalplus.eval import is_floats from evalp...
null
17,085
import ast import inspect import json import multiprocessing import sys from concurrent.futures import ProcessPoolExecutor, as_completed from tqdm import tqdm from evalplus.data.mbpp import ( MBPP_PLUS_VERSION, get_mbpp, get_mbpp_plus, get_mbpp_plus_hash, ) from evalplus.eval import is_floats from evalp...
null
17,086
import os from tqdm import tqdm from evalplus.data import ( get_human_eval_plus, get_mbpp_plus, load_solutions, write_directory, write_jsonl, ) from evalplus.sanitize import sanitize def remove_unindented_lines(code, protect_before, execeptions, trim_tails): lines = code.splitlines() cut_id...
null
17,087
import os from tqdm import tqdm from evalplus.data import ( get_human_eval_plus, get_mbpp_plus, load_solutions, write_directory, write_jsonl, ) from evalplus.sanitize import sanitize def to_four_space_indents(old_code): new_code = "" for line in old_code.splitlines(): lspace = len(l...
null
17,088
import json import os from rich.progress import track from evalplus.data import get_human_eval_plus, get_human_eval_plus_inputs LLM_HOME_PATH = "/JawTitan/EvalPlus/humaneval" model_paths = os.listdir(LLM_HOME_PATH) cover_info = {f"HumanEval_{i}": {} for i in range(164)} def get_cover_info(): for model_path in trac...
null
17,089
def fix(data): # fix 140 https://github.com/evalplus/evalplus/issues/3 assert data[140]["task_id"] == "HumanEval/140" data[140]["canonical_solution"] = data[140]["canonical_solution"].replace( "range(len(text)-1, 2, -1)", "range(len(text), 2, -1)" ) # fix 75 https://github.com/evalplus/ev...
null
17,090
import json import os import pathlib from importlib import import_module from inspect import getsource from typing import Tuple from tempdir import TempDir from evalplus.data.humaneval import get_human_eval def _ret(entry_point) -> str: """This is a hacky function to return some garbages so that we can successf...
null
17,091
import json import os import pathlib from importlib import import_module from inspect import getsource from typing import Tuple from tempdir import TempDir from evalplus.data.humaneval import get_human_eval def get_contract_and_ref(task_id: int, entry_point) -> Tuple[str, str]: mod = import_module(f"groundtruth.hu...
null
17,092
import json import os import pathlib from importlib import import_module from inspect import getsource from typing import Tuple from tempdir import TempDir from evalplus.data.humaneval import get_human_eval def get_atol(task_id: int) -> float: if task_id == 2 or task_id == 4: return 1e-6 elif task_id =...
null
17,093
def check_id(data, task_id): assert data[task_id]["task_id"] == f"HumanEval/{task_id}" def fix(data): # fix 53 https://github.com/evalplus/evalplus/issues/8 check_id(data, 53) data[53]["contract"] = ( '\n assert isinstance(x, int), "invalid inputs" # $_CONTRACT_$' + '\n assert isi...
null
17,094
import math def fix(data): # https://github.com/evalplus/evalplus/issues/29 check_id(data, 35) data[35]["contract"] += ' assert len(l) != 0, "invalid inputs" # $_CONTRACT_$\n' # https://github.com/evalplus/evalplus/issues/28 check_id(data, 2) data[2][ "contract" ] += ' assert n...
null
17,095
import math def check_id(data, task_id): assert data[task_id]["task_id"] == f"HumanEval/{task_id}" def check_valid(xs): if not (isinstance(xs, list) and len(xs) > 0 and len(xs) % 2 == 0): return False if not all(type(x) == int for x in xs): return False dxs = [xs[i] * i for i in range(1,...
null
17,096
import math def check_id(data, task_id): assert data[task_id]["task_id"] == f"HumanEval/{task_id}" def check_valid(s: str): cnt = 0 for ch in s: if ch == "(": cnt += 1 elif ch == ")": cnt -= 1 else: return False if cnt < 0: retu...
null
17,097
import math def fix(data): # https://github.com/evalplus/evalplus/issues/44 check_id(data, 115) data[115]["prompt"] = "import math\n" + data[115]["prompt"].replace( " import math\n", "" ) check_id(data, 114) data[114]["prompt"] = data[114]["prompt"].replace("import math\n", "") # ...
null
17,098
import math def check_id(data, task_id): assert data[task_id]["task_id"] == f"HumanEval/{task_id}" def check_valid(op, num): try: exp = "" for i in range(len(op)): exp += str(num[i]) + str(op[i]) exp += str(num[-1]) exp = str(eval(exp)) except: return Fals...
null
17,099
import ast import inspect import json import multiprocessing import sys from concurrent.futures import ProcessPoolExecutor, as_completed from tqdm import tqdm from evalplus.data.humaneval import ( HUMANEVAL_PLUS_VERSION, get_human_eval_plus, get_human_eval_plus_hash, ) from evalplus.eval import is_floats fr...
null
17,100
import ast import inspect import json import multiprocessing import sys from concurrent.futures import ProcessPoolExecutor, as_completed from tqdm import tqdm from evalplus.data.humaneval import ( HUMANEVAL_PLUS_VERSION, get_human_eval_plus, get_human_eval_plus_hash, ) from evalplus.eval import is_floats fr...
null