id
int64
0
190k
prompt
stringlengths
21
13.4M
docstring
stringlengths
1
12k
8,661
import click from click_default_group import DefaultGroup from dataclasses import asdict import io import json from llm import ( Collection, Conversation, Response, Template, UnknownModelError, encode, get_embedding_models_with_aliases, get_embedding_model_aliases, get_embedding_mode...
Show current status of database logging
8,662
import click from click_default_group import DefaultGroup from dataclasses import asdict import io import json from llm import ( Collection, Conversation, Response, Template, UnknownModelError, encode, get_embedding_models_with_aliases, get_embedding_model_aliases, get_embedding_mode...
Turn on logging for all prompts
8,663
import click from click_default_group import DefaultGroup from dataclasses import asdict import io import json from llm import ( Collection, Conversation, Response, Template, UnknownModelError, encode, get_embedding_models_with_aliases, get_embedding_model_aliases, get_embedding_mode...
Turn off logging for all prompts
8,664
import click from click_default_group import DefaultGroup from dataclasses import asdict import io import json from llm import ( Collection, Conversation, Response, Template, UnknownModelError, encode, get_embedding_models_with_aliases, get_embedding_model_aliases, get_embedding_mode...
Show recent logged prompts and their responses
8,665
import click from click_default_group import DefaultGroup from dataclasses import asdict import io import json from llm import ( Collection, Conversation, Response, Template, UnknownModelError, encode, get_embedding_models_with_aliases, get_embedding_model_aliases, get_embedding_mode...
Manage available models
8,666
import click from click_default_group import DefaultGroup from dataclasses import asdict import io import json from llm import ( Collection, Conversation, Response, Template, UnknownModelError, encode, get_embedding_models_with_aliases, get_embedding_model_aliases, get_embedding_mode...
List available models
8,667
import click from click_default_group import DefaultGroup from dataclasses import asdict import io import json from llm import ( Collection, Conversation, Response, Template, UnknownModelError, encode, get_embedding_models_with_aliases, get_embedding_model_aliases, get_embedding_mode...
Show or set the default model
8,668
import click from click_default_group import DefaultGroup from dataclasses import asdict import io import json from llm import ( Collection, Conversation, Response, Template, UnknownModelError, encode, get_embedding_models_with_aliases, get_embedding_model_aliases, get_embedding_mode...
Manage stored prompt templates
8,669
import click from click_default_group import DefaultGroup from dataclasses import asdict import io import json from llm import ( Collection, Conversation, Response, Template, UnknownModelError, encode, get_embedding_models_with_aliases, get_embedding_model_aliases, get_embedding_mode...
List available prompt templates
8,670
import click from click_default_group import DefaultGroup from dataclasses import asdict import io import json from llm import ( Collection, Conversation, Response, Template, UnknownModelError, encode, get_embedding_models_with_aliases, get_embedding_model_aliases, get_embedding_mode...
List current aliases
8,671
import click from click_default_group import DefaultGroup from dataclasses import asdict import io import json from llm import ( Collection, Conversation, Response, Template, UnknownModelError, encode, get_embedding_models_with_aliases, get_embedding_model_aliases, get_embedding_mode...
Set an alias for a model Example usage: \b $ llm aliases set turbo gpt-3.5-turbo
8,672
import click from click_default_group import DefaultGroup from dataclasses import asdict import io import json from llm import ( Collection, Conversation, Response, Template, UnknownModelError, encode, get_embedding_models_with_aliases, get_embedding_model_aliases, get_embedding_mode...
Remove an alias Example usage: \b $ llm aliases remove turbo
8,673
import click from click_default_group import DefaultGroup from dataclasses import asdict import io import json from llm import ( Collection, Conversation, Response, Template, UnknownModelError, encode, get_embedding_models_with_aliases, get_embedding_model_aliases, get_embedding_mode...
Output the path to the aliases.json file
8,674
import click from click_default_group import DefaultGroup from dataclasses import asdict import io import json from llm import ( Collection, Conversation, Response, Template, UnknownModelError, encode, get_embedding_models_with_aliases, get_embedding_model_aliases, get_embedding_mode...
List installed plugins
8,675
import click from click_default_group import DefaultGroup from dataclasses import asdict import io import json from llm import ( Collection, Conversation, Response, Template, UnknownModelError, encode, get_embedding_models_with_aliases, get_embedding_model_aliases, get_embedding_mode...
Show the specified prompt template
8,676
import click from click_default_group import DefaultGroup from dataclasses import asdict import io import json from llm import ( Collection, Conversation, Response, Template, UnknownModelError, encode, get_embedding_models_with_aliases, get_embedding_model_aliases, get_embedding_mode...
Edit the specified prompt template using the default $EDITOR
8,677
import click from click_default_group import DefaultGroup from dataclasses import asdict import io import json from llm import ( Collection, Conversation, Response, Template, UnknownModelError, encode, get_embedding_models_with_aliases, get_embedding_model_aliases, get_embedding_mode...
Output the path to the templates directory
8,678
import click from click_default_group import DefaultGroup from dataclasses import asdict import io import json from llm import ( Collection, Conversation, Response, Template, UnknownModelError, encode, get_embedding_models_with_aliases, get_embedding_model_aliases, get_embedding_mode...
Install packages from PyPI into the same environment as LLM
8,679
import click from click_default_group import DefaultGroup from dataclasses import asdict import io import json from llm import ( Collection, Conversation, Response, Template, UnknownModelError, encode, get_embedding_models_with_aliases, get_embedding_model_aliases, get_embedding_mode...
Uninstall Python packages from the LLM environment
8,680
import click from click_default_group import DefaultGroup from dataclasses import asdict import io import json from llm import ( Collection, Conversation, Response, Template, UnknownModelError, encode, get_embedding_models_with_aliases, get_embedding_model_aliases, get_embedding_mode...
Embed text and store or return the result
8,681
import click from click_default_group import DefaultGroup from dataclasses import asdict import io import json from llm import ( Collection, Conversation, Response, Template, UnknownModelError, encode, get_embedding_models_with_aliases, get_embedding_model_aliases, get_embedding_mode...
Store embeddings for multiple strings at once Input can be CSV, TSV or a JSON list of objects. The first column is treated as an ID - all other columns are assumed to be text that should be concatenated together in order to calculate the embeddings. Input data can come from one of three sources: \b 1. A CSV, JSON, TSV ...
8,682
import click from click_default_group import DefaultGroup from dataclasses import asdict import io import json from llm import ( Collection, Conversation, Response, Template, UnknownModelError, encode, get_embedding_models_with_aliases, get_embedding_model_aliases, get_embedding_mode...
Return top N similar IDs from a collection Example usage: \b llm similar my-collection -c "I like cats" Or to find content similar to a specific stored ID: \b llm similar my-collection 1234
8,683
import click from click_default_group import DefaultGroup from dataclasses import asdict import io import json from llm import ( Collection, Conversation, Response, Template, UnknownModelError, encode, get_embedding_models_with_aliases, get_embedding_model_aliases, get_embedding_mode...
Manage available embedding models
8,684
import click from click_default_group import DefaultGroup from dataclasses import asdict import io import json from llm import ( Collection, Conversation, Response, Template, UnknownModelError, encode, get_embedding_models_with_aliases, get_embedding_model_aliases, get_embedding_mode...
List available embedding models
8,685
import click from click_default_group import DefaultGroup from dataclasses import asdict import io import json from llm import ( Collection, Conversation, Response, Template, UnknownModelError, encode, get_embedding_models_with_aliases, get_embedding_model_aliases, get_embedding_mode...
Show or set the default embedding model
8,686
import click from click_default_group import DefaultGroup from dataclasses import asdict import io import json from llm import ( Collection, Conversation, Response, Template, UnknownModelError, encode, get_embedding_models_with_aliases, get_embedding_model_aliases, get_embedding_mode...
View and manage collections of embeddings
8,687
import click from click_default_group import DefaultGroup from dataclasses import asdict import io import json from llm import ( Collection, Conversation, Response, Template, UnknownModelError, encode, get_embedding_models_with_aliases, get_embedding_model_aliases, get_embedding_mode...
Output the path to the embeddings database
8,688
import click from click_default_group import DefaultGroup from dataclasses import asdict import io import json from llm import ( Collection, Conversation, Response, Template, UnknownModelError, encode, get_embedding_models_with_aliases, get_embedding_model_aliases, get_embedding_mode...
View a list of collections
8,689
import click from click_default_group import DefaultGroup from dataclasses import asdict import io import json from llm import ( Collection, Conversation, Response, Template, UnknownModelError, encode, get_embedding_models_with_aliases, get_embedding_model_aliases, get_embedding_mode...
Delete the specified collection Example usage: \b llm collections delete my-collection
8,690
import click from click_default_group import DefaultGroup from dataclasses import asdict import io import json from llm import ( Collection, Conversation, Response, Template, UnknownModelError, encode, get_embedding_models_with_aliases, get_embedding_model_aliases, get_embedding_mode...
null
8,691
import click import httpx import json import textwrap from typing import List, Dict The provided code snippet includes necessary dependencies for implementing the `remove_dict_none_values` function. Write a Python function `def remove_dict_none_values(d)` to solve the following problem: Recursively remove keys with va...
Recursively remove keys with value of None or value of a dict that is all values of None
8,692
import click import httpx import json import textwrap from typing import List, Dict class _LogTransport(httpx.BaseTransport): def __init__(self, transport: httpx.BaseTransport): self.transport = transport def handle_request(self, request: httpx.Request) -> httpx.Response: response = self.transpo...
null
8,693
import datetime from typing import Callable, List def m001_initial(db): # Ensure the original table design exists, so other migrations can run if db["log"].exists(): # It needs to have the chat_id column if "chat_id" not in db["log"].columns_dict: db["log"].add_column("chat_id") ...
null
8,694
import datetime from typing import Callable, List def m002_id_primary_key(db): db["log"].transform(pk="id")
null
8,695
import datetime from typing import Callable, List def m003_chat_id_foreign_key(db): db["log"].transform(types={"chat_id": int}) db["log"].add_foreign_key("chat_id", "log", "id")
null
8,696
import datetime from typing import Callable, List def m004_column_order(db): db["log"].transform( column_order=( "id", "model", "timestamp", "prompt", "system", "response", "chat_id", ) )
null
8,697
import datetime from typing import Callable, List def m004_drop_provider(db): db["log"].transform(drop=("provider",))
null
8,698
import datetime from typing import Callable, List def m005_debug(db): db["log"].add_column("debug", str) db["log"].add_column("duration_ms", int)
null
8,699
import datetime from typing import Callable, List def m006_new_logs_table(db): columns = db["log"].columns_dict for column, type in ( ("options_json", str), ("prompt_json", str), ("response_json", str), ("reply_to_id", int), ): # It's possible people running developm...
null
8,700
import datetime from typing import Callable, List def m007_finish_logs_table(db): db["log"].transform( drop={"debug"}, rename={"timestamp_utc": "datetime_utc"}, drop_foreign_keys=("chat_id",), ) with db.conn: db.execute("alter table log rename to logs")
null
8,701
import datetime from typing import Callable, List def m008_reply_to_id_foreign_key(db): db["logs"].add_foreign_key("reply_to_id", "logs", "id")
null
8,702
import datetime from typing import Callable, List def m008_fix_column_order_in_logs(db): # reply_to_id ended up at the end after foreign key added db["logs"].transform( column_order=( "id", "model", "prompt", "system", "prompt_json", ...
null
8,703
import datetime from typing import Callable, List def m009_delete_logs_table_if_empty(db): # We moved to a new table design, but we don't delete the table # if someone has put data in it if not db["logs"].count: db["logs"].drop()
null
8,704
import datetime from typing import Callable, List def m010_create_new_log_tables(db): db["conversations"].create( { "id": str, "name": str, "model": str, }, pk="id", ) db["responses"].create( { "id": str, "model": s...
null
8,705
import datetime from typing import Callable, List def m011_fts_for_responses(db): db["responses"].enable_fts(["prompt", "response"], create_triggers=True)
null
8,706
from dataclasses import dataclass, field import datetime from .errors import NeedsKeyException from itertools import islice import re import time from typing import Any, Dict, Iterable, Iterator, List, Optional, Set, Union from abc import ABC, abstractmethod import json from pydantic import BaseModel from ulid import U...
null
8,707
from pluggy import HookimplMarker from pluggy import HookspecMarker The provided code snippet includes necessary dependencies for implementing the `register_commands` function. Write a Python function `def register_commands(cli)` to solve the following problem: Register additional CLI commands, e.g. 'llm mycommand ......
Register additional CLI commands, e.g. 'llm mycommand ...
8,708
from pluggy import HookimplMarker from pluggy import HookspecMarker The provided code snippet includes necessary dependencies for implementing the `register_models` function. Write a Python function `def register_models(register)` to solve the following problem: Register additional model instances representing LLM mod...
Register additional model instances representing LLM models that can be called
8,709
from pluggy import HookimplMarker from pluggy import HookspecMarker The provided code snippet includes necessary dependencies for implementing the `register_embedding_models` function. Write a Python function `def register_embedding_models(register)` to solve the following problem: Register additional model instances ...
Register additional model instances that can be used for embedding
8,710
from llm import EmbeddingModel, Model, hookimpl import llm from llm.utils import dicts_to_table_string, remove_dict_none_values, logging_client import click import datetime import httpx import openai import os from typing import List, Iterable, Iterator, Optional, Union import json import yaml class Chat(Model): ne...
null
8,711
from llm import EmbeddingModel, Model, hookimpl import llm from llm.utils import dicts_to_table_string, remove_dict_none_values, logging_client import click import datetime import httpx import openai import os from typing import List, Iterable, Iterator, Optional, Union import json import yaml class OpenAIEmbeddingMode...
null
8,712
from llm import EmbeddingModel, Model, hookimpl import llm from llm.utils import dicts_to_table_string, remove_dict_none_values, logging_client import click import datetime import httpx import openai import os from typing import List, Iterable, Iterator, Optional, Union import json import yaml def dicts_to_table_strin...
null
8,713
from llm import EmbeddingModel, Model, hookimpl import llm from llm.utils import dicts_to_table_string, remove_dict_none_values, logging_client import click import datetime import httpx import openai import os from typing import List, Iterable, Iterator, Optional, Union import json import yaml def not_nulls(data) -> d...
null
8,714
from llm import EmbeddingModel, Model, hookimpl import llm from llm.utils import dicts_to_table_string, remove_dict_none_values, logging_client import click import datetime import httpx import openai import os from typing import List, Iterable, Iterator, Optional, Union import json import yaml def combine_chunks(chunk...
null
8,715
import re import json import typing import requests import lxml.html from typing import Any, Sequence, Type from pydantic import BaseModel from .errors import PreprocessorError from .responses import Response, ScrapeResponse from .apicall import OpenAiCall, Postprocessor, RetryRule from .utils import logger, _tokens, _...
Combine (possibly paginated) API responses into a single ScrapeResponse.
8,716
import re import json import typing import requests import lxml.html from typing import Any, Sequence, Type from pydantic import BaseModel from .errors import PreprocessorError from .responses import Response, ScrapeResponse from .apicall import OpenAiCall, Postprocessor, RetryRule from .utils import logger, _tokens, _...
Given URL or HTML, return lxml.html.Element
8,717
import re import json import typing import requests import lxml.html from typing import Any, Sequence, Type from pydantic import BaseModel from .errors import PreprocessorError from .responses import Response, ScrapeResponse from .apicall import OpenAiCall, Postprocessor, RetryRule from .utils import logger, _tokens, _...
Given a list of all matching HTML tags, recombine into HTML chunks that can be passed to API.
8,718
import re import json import typing import requests import lxml.html from typing import Any, Sequence, Type from pydantic import BaseModel from .errors import PreprocessorError from .responses import Response, ScrapeResponse from .apicall import OpenAiCall, Postprocessor, RetryRule from .utils import logger, _tokens, _...
Given a Pydantic model, return a simple schema that can be used by SchemaScraper. We don't use Pydantic's schema() method because the additional complexity of JSON Schema adds a lot of extra tokens and in testing did not work as well as the simplified versions.
8,719
import json import pathlib import logging import structlog import typer from .scrapers import SchemaScraper from .preprocessors import CSS, XPath class SchemaScraper(OpenAiCall): def __init__( self, schema: dict | str | list, extra_preprocessors: list | None = None, ...
null
8,720
import lxml.html import structlog import tiktoken from .models import _model_dict def _tokens(model: str, html: str) -> int: encoding = tiktoken.encoding_for_model(model) return len(encoding.encode(html)) _model_dict = {model.name: model for model in models} The provided code snippet includes necessary depend...
Given HTML, return cost estimate in dollars. This is a very rough estimate and not guaranteed to be accurate.
8,721
from __future__ import annotations from typing import TYPE_CHECKING import json from pydantic import ValidationError from .utils import logger, _tostr from .errors import InvalidJSON, PostprocessingError from .responses import Response, ScrapeResponse class PostprocessingError(ScrapeghostError): pass The provided...
Recursively check response for data that is not in the html.
8,722
import sys import json import lxml.html import requests from scrapeghost import SchemaScraper, CSS def get_urls(): # this page is currently too long for the 8k limit, even with hints html = requests.get("https://www.ilga.gov/senate/default.asp").text doc = lxml.html.fromstring(html) doc.make_links_abso...
null
8,723
import ast import re from setuptools import setup, find_packages with open('pypi_desc.md', 'r', encoding='utf-8') as f: readme = f.read() The provided code snippet includes necessary dependencies for implementing the `get_version_string` function. Write a Python function `def get_version_string()` to solve the fol...
Get the gne version number :return: version number :rtype: str
8,724
import ast import re from setuptools import setup, find_packages with open('pypi_desc.md', 'r', encoding='utf-8') as f: readme = f.read() The provided code snippet includes necessary dependencies for implementing the `get_author_string` function. Write a Python function `def get_author_string()` to solve the follo...
Get the gne author info :return: author name :rtype: str
8,725
import os import re import yaml import unicodedata from lxml.html import fromstring, HtmlElement from lxml.html import etree from urllib.parse import urlparse, urljoin from .defaults import USELESS_TAG, TAGS_CAN_BE_REMOVE_IF_EMPTY, USELESS_ATTR, HIGH_WEIGHT_ARRT_KEYWORD def html2element(html): html = re.sub('</?br...
null
8,726
import os import re import yaml import unicodedata from lxml.html import fromstring, HtmlElement from lxml.html import etree from urllib.parse import urlparse, urljoin from .defaults import USELESS_TAG, TAGS_CAN_BE_REMOVE_IF_EMPTY, USELESS_ATTR, HIGH_WEIGHT_ARRT_KEYWORD def normalize_node(element: HtmlElement): def pr...
null
8,727
import os import re import yaml import unicodedata from lxml.html import fromstring, HtmlElement from lxml.html import etree from urllib.parse import urlparse, urljoin from .defaults import USELESS_TAG, TAGS_CAN_BE_REMOVE_IF_EMPTY, USELESS_ATTR, HIGH_WEIGHT_ARRT_KEYWORD def remove_node(node: HtmlElement): """ t...
null
8,728
import os import re import yaml import unicodedata from lxml.html import fromstring, HtmlElement from lxml.html import etree from urllib.parse import urlparse, urljoin from .defaults import USELESS_TAG, TAGS_CAN_BE_REMOVE_IF_EMPTY, USELESS_ATTR, HIGH_WEIGHT_ARRT_KEYWORD The provided code snippet includes necessary dep...
网站上的图片可能有如下几种格式: 完整的绝对路径:https://xxx.com/1.jpg 完全不含 host 的相对路径: /1.jpg 含 host 但是不含 scheme: xxx.com/1.jpg 或者 ://xxx.com/1.jpg :param host: :param url: :return:
8,729
import os import re import yaml import unicodedata from lxml.html import fromstring, HtmlElement from lxml.html import etree from urllib.parse import urlparse, urljoin from .defaults import USELESS_TAG, TAGS_CAN_BE_REMOVE_IF_EMPTY, USELESS_ATTR, HIGH_WEIGHT_ARRT_KEYWORD config = read_config() def read_config(): if...
null
8,730
import os import re import yaml import unicodedata from lxml.html import fromstring, HtmlElement from lxml.html import etree from urllib.parse import urlparse, urljoin from .defaults import USELESS_TAG, TAGS_CAN_BE_REMOVE_IF_EMPTY, USELESS_ATTR, HIGH_WEIGHT_ARRT_KEYWORD HIGH_WEIGHT_ARRT_KEYWORD = ['content', ...
null
8,731
import os import re import yaml import unicodedata from lxml.html import fromstring, HtmlElement from lxml.html import etree from urllib.parse import urlparse, urljoin from .defaults import USELESS_TAG, TAGS_CAN_BE_REMOVE_IF_EMPTY, USELESS_ATTR, HIGH_WEIGHT_ARRT_KEYWORD The provided code snippet includes necessary dep...
获取两个字符串的最长公共子串。 构造一个矩阵,横向是字符串1,纵向是字符串2,例如: 青南是天才!? 听0 0 0 0 00 0 说0 0 0 0 00 0 青1 0 0 0 00 0 南0 1 0 0 00 0 是0 0 1 0 00 0 天0 0 0 1 00 0 才0 0 0 0 10 0 !0 0 0 0 01 0 显然,只要斜对角线最长的就是最长公共子串 :param str1: :param str2: :return:
8,732
import os import re import yaml import unicodedata from lxml.html import fromstring, HtmlElement from lxml.html import etree from urllib.parse import urlparse, urljoin from .defaults import USELESS_TAG, TAGS_CAN_BE_REMOVE_IF_EMPTY, USELESS_ATTR, HIGH_WEIGHT_ARRT_KEYWORD The provided code snippet includes necessary dep...
使用 NFKC 对网页源代码进行归一化,把特殊符号转换为普通符号 注意,中文标点符号可能会被转换成英文标点符合。 :param html: :return:
8,733
import os import re from setuptools import find_packages, setup deps = {b: a for a, b in (re.findall(r"^(([^!=<>~]+)(?:[!=<>~].*)?$)", x)[0] for x in _deps)} def deps_list(*pkgs): return [deps[pkg] for pkg in pkgs]
null
8,734
import gc from collections import OrderedDict from typing import * import numpy as np import onnx import onnx_graphsurgeon as gs import tensorrt as trt import torch from cuda import cudart from PIL import Image from polygraphy import cuda from polygraphy.backend.common import bytes_from_path from polygraphy.backend.trt...
null
8,735
import gc from collections import OrderedDict from typing import * import numpy as np import onnx import onnx_graphsurgeon as gs import tensorrt as trt import torch from cuda import cudart from PIL import Image from polygraphy import cuda from polygraphy.backend.common import bytes_from_path from polygraphy.backend.trt...
null
8,736
import gc from collections import OrderedDict from typing import * import numpy as np import onnx import onnx_graphsurgeon as gs import tensorrt as trt import torch from cuda import cudart from PIL import Image from polygraphy import cuda from polygraphy.backend.common import bytes_from_path from polygraphy.backend.trt...
null
8,737
import gc from collections import OrderedDict from typing import * import numpy as np import onnx import onnx_graphsurgeon as gs import tensorrt as trt import torch from cuda import cudart from PIL import Image from polygraphy import cuda from polygraphy.backend.common import bytes_from_path from polygraphy.backend.trt...
null
8,738
import gc from collections import OrderedDict from typing import * import numpy as np import onnx import onnx_graphsurgeon as gs import tensorrt as trt import torch from cuda import cudart from PIL import Image from polygraphy import cuda from polygraphy.backend.common import bytes_from_path from polygraphy.backend.trt...
null
8,739
import gc from collections import OrderedDict from typing import * import numpy as np import onnx import onnx_graphsurgeon as gs import tensorrt as trt import torch from cuda import cudart from PIL import Image from polygraphy import cuda from polygraphy.backend.common import bytes_from_path from polygraphy.backend.trt...
null
8,740
import gc from collections import OrderedDict from typing import * import numpy as np import onnx import onnx_graphsurgeon as gs import tensorrt as trt import torch from cuda import cudart from PIL import Image from polygraphy import cuda from polygraphy.backend.common import bytes_from_path from polygraphy.backend.trt...
null
8,741
import gc from collections import OrderedDict from typing import * import numpy as np import onnx import onnx_graphsurgeon as gs import tensorrt as trt import torch from cuda import cudart from PIL import Image from polygraphy import cuda from polygraphy.backend.common import bytes_from_path from polygraphy.backend.trt...
null
8,742
import gc import os from typing import * import torch from .models import BaseModel from .utilities import ( build_engine, export_onnx, optimize_onnx, ) def create_onnx_path(name, onnx_dir, opt=True): return os.path.join(onnx_dir, name + (".opt" if opt else "") + ".onnx")
null
8,743
from typing import Literal, Optional import fire from packaging.version import Version from ..pip_utils import is_installed, run_pip, version import platform def get_cuda_version_from_torch() -> Optional[Literal["11", "12"]]: try: import torch except ImportError: return None return torch.ver...
null
8,744
import os import sys import threading import time import tkinter as tk from multiprocessing import Process, Queue, get_context from typing import List, Literal import fire from PIL import Image, ImageTk from streamdiffusion.image_utils import postprocess_image from utils.wrapper import StreamDiffusionWrapper class Str...
Process for generating images based on a prompt using a specified model. Parameters ---------- queue : Queue The queue to put the generated images in. fps_queue : Queue The queue to put the calculated fps. prompt : str The prompt to generate images from. model_id_or_path : str The name of the model to use for image gen...
8,745
import os import sys import threading import time import tkinter as tk from multiprocessing import Process, Queue, get_context from typing import List, Literal import fire from PIL import Image, ImageTk from streamdiffusion.image_utils import postprocess_image from utils.wrapper import StreamDiffusionWrapper def _recei...
Setup the Tkinter window and start the thread to receive images. Parameters ---------- queue : Queue The queue to receive images from. fps_queue : Queue The queue to put the calculated fps.
8,746
import os import sys import time from multiprocessing import Process, Queue, get_context from typing import Literal import fire from utils.viewer import receive_images from utils.wrapper import StreamDiffusionWrapper class StreamDiffusionWrapper: def __init__( self, model_id_or_path: str, t...
Process for generating images based on a prompt using a specified model. Parameters ---------- queue : Queue The queue to put the generated images in. fps_queue : Queue The queue to put the calculated fps. prompt : str The prompt to generate images from. model_id_or_path : str The name of the model to use for image gen...
8,747
import os import sys import time import threading from multiprocessing import Process, Queue, get_context from multiprocessing.connection import Connection from typing import List, Literal, Dict, Optional import torch import PIL.Image from streamdiffusion.image_utils import pil2tensor import mss import fire import tkin...
null
8,748
import os import sys import time import threading from multiprocessing import Process, Queue, get_context from multiprocessing.connection import Connection from typing import List, Literal, Dict, Optional import torch import PIL.Image from streamdiffusion.image_utils import pil2tensor import mss import fire import tkin...
Process for generating images based on a prompt using a specified model. Parameters ---------- queue : Queue The queue to put the generated images in. fps_queue : Queue The queue to put the calculated fps. model_id_or_path : str The name of the model to use for image generation. lora_dict : Optional[Dict[str, float]], ...
8,749
import io import os import sys import time from multiprocessing import Process, Queue from typing import List, Literal, Optional, Dict import fire import PIL.Image import requests import torch from tqdm import tqdm from streamdiffusion.image_utils import postprocess_image from utils.wrapper import StreamDiffusionWrappe...
Initializes the StreamDiffusionWrapper. Parameters ---------- iterations : int, optional The number of iterations to run, by default 100. model_id_or_path : str The model id or path to load. lora_dict : Optional[Dict[str, float]], optional The lora_dict to load, by default None. Keys are the LoRA names and values are t...
8,750
import io import os import sys from typing import List, Literal, Optional, Dict import fire import PIL.Image import requests import torch from tqdm import tqdm from utils.wrapper import StreamDiffusionWrapper def download_image(url: str): response = requests.get(url) image = PIL.Image.open(io.BytesIO(response.c...
Initializes the StreamDiffusionWrapper. Parameters ---------- iterations : int, optional The number of iterations to run, by default 100. model_id_or_path : str The model id or path to load. lora_dict : Optional[Dict[str, float]], optional The lora_dict to load, by default None. Keys are the LoRA names and values are t...
8,751
from importlib import import_module from types import ModuleType from typing import Dict, Any from pydantic import BaseModel as PydanticBaseModel, Field from PIL import Image import io def get_pipeline_class(pipeline_name: str) -> ModuleType: try: module = import_module(f"pipelines.{pipeline_name}") ex...
null
8,752
from importlib import import_module from types import ModuleType from typing import Dict, Any from pydantic import BaseModel as PydanticBaseModel, Field from PIL import Image import io def bytes_to_pil(image_bytes: bytes) -> Image.Image: image = Image.open(io.BytesIO(image_bytes)) return image
null
8,753
from importlib import import_module from types import ModuleType from typing import Dict, Any from pydantic import BaseModel as PydanticBaseModel, Field from PIL import Image import io def pil_to_frame(image: Image.Image) -> bytes: frame_data = io.BytesIO() image.save(frame_data, format="JPEG") frame_data ...
null
8,754
from importlib import import_module from types import ModuleType from typing import Dict, Any from pydantic import BaseModel as PydanticBaseModel, Field from PIL import Image import io def is_firefox(user_agent: str) -> bool: return "Firefox" in user_agent
null
8,755
import os import sys import threading import time import tkinter as tk from multiprocessing import Queue from typing import List from PIL import Image, ImageTk from streamdiffusion.image_utils import postprocess_image def _receive_images( queue: Queue, fps_queue: Queue, label: tk.Label, fps_label: tk.Label ) -> No...
Setup the Tkinter window and start the thread to receive images. Parameters ---------- queue : Queue The queue to receive images from. fps_queue : Queue The queue to put the calculated fps.
8,756
from __future__ import absolute_import from __future__ import division from __future__ import print_function import json import os import random import time from albert import fine_tuning_utils from albert import modeling from albert import squad_utils import six import tensorflow.compat.v1 as tf from tensorflow.compat...
Validate the input FLAGS or throw an exception.
8,757
from __future__ import absolute_import from __future__ import division from __future__ import print_function import json import os import random import time from albert import fine_tuning_utils from albert import modeling from albert import squad_utils import six import tensorflow.compat.v1 as tf from tensorflow.compat...
Builds a serving input fn for raw input.
8,758
from albert import modeling from albert import tokenization import tensorflow.compat.v1 as tf import tensorflow_hub as hub def _create_model_from_hub(hub_module, is_training, input_ids, input_mask, segment_ids): """Creates an ALBERT model from TF-Hub.""" tags = set() if is_training: ...
Creates an ALBERT, either from TF-Hub or from scratch.
8,759
from albert import modeling from albert import tokenization import tensorflow.compat.v1 as tf import tensorflow_hub as hub The provided code snippet includes necessary dependencies for implementing the `create_vocab` function. Write a Python function `def create_vocab(vocab_file, do_lower_case, spm_model_file, hub_mod...
Creates a vocab, either from vocab file or from a TF-Hub module.
8,760
from __future__ import absolute_import from __future__ import division from __future__ import print_function import collections import random from albert import tokenization import numpy as np import six from six.moves import range from six.moves import zip import tensorflow.compat.v1 as tf FLAGS = flags.FLAGS def crea...
Create TF example files from `TrainingInstance`s.