text stringlengths 14 100k | source stringclasses 1
value | repo stringclasses 810
values | language stringclasses 13
values |
|---|---|---|---|
<|fim_suffix|>cific language governing permissions and
* limitations under the License.
*/
package com.google.zxing.web.generator.client;
final class TimeZoneInfo {
private final String abbreviation;
private final String longName;
private final String gmtRelative;
private final long gmtDiff;
TimeZoneInf... | fim | zxing/zxing | java |
<|fim_prefix|>/*
* Copyright (C) 2008 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applica... | fim | zxing/zxing | java |
<|fim_suffix|>}
@Override
public String getText() throws GeneratorException {
return getUrlField();
}
private String getUrlField() throws GeneratorException {
String input = url.getText();
Validators.validateUrl(input);
return input;
}
@Override
public void validate(Widget widget) thr... | fim | zxing/zxing | java |
<|fim_suffix|>mail addresses, and URL. Other
* general purpose check methods should go here as well.
*
* @author Yohann Coppel
*/
final class Validators {
private Validators() {
}
static String filterNumber(String number) {
return number.replaceAll("[ .,\\-()]", "");
}
static void validateNumber... | fim | zxing/zxing | java |
<|fim_suffix|> encryption", "nopass");
TextBox[] widgets = {ssid, password};
for (TextBox w: widgets) {
w.addChangeHandler(handler);
w.addKeyPressHandler(keyListener);
}
}
@Override
public String getName() {
return "Wifi network";
}
@Override
public String getText() throws Gene... | fim | zxing/zxing | java |
<|fim_suffix|>e "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an... | fim | zxing/zxing | java |
<|fim_prefix|>/*
* Copyright 2019 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with t<|fim_suffix|>se.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by appli... | fim | zxing/zxing | java |
<|fim_suffix|>t request, HttpServletResponse response, boolean isPost)
throws IOException {
ChartServletRequestParameters parameters;
try {
parameters = doParseParameters(request, isPost);
} catch (IllegalArgumentException | NullPointerException e) {
response.sendError(HttpServletResponse... | fim | zxing/zxing | java |
/*
* Copyright 2013 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed ... | fim | zxing/zxing | java |
<|fim_suffix|>ilter(urlPatterns = {"/w/decode"}, initParams = {
@WebInitParam(name = "maxAccessPerTime", value = "60"),
@WebInitParam(name = "accessTimeSec", value = "60"),
@WebInitParam(name = "maxEntries", value = "100000"),
@WebInitParam(name = "maxLoad", value = "0.9")
})
public final class DecodeDoSFilter ... | fim | zxing/zxing | java |
<|fim_prefix|>/*
* Copyright 2008 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable ... | fim | zxing/zxing | java |
<|fim_suffix|> timer.cancel();
}
}
}
<|fim_prefix|>/*
* Copyright 2015 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses... | fim | zxing/zxing | java |
<|fim_prefix|>/*
* Copyright 2017 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable ... | fim | zxing/zxing | java |
<|fim_prefix|>/*
* Copyright 2017 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable ... | fim | zxing/zxing | java |
<|fim_suffix|> this.maxSize = maxSize;
}
@Override
protected boolean removeEldestEntry(Map.Entry<K,V> eldest) {
return size() > maxSize;
}
}
<|fim_prefix|>/*
* Copyright 2017 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compli... | fim | zxing/zxing | java |
<|fim_suffix|> }
public static String arrayToString(byte[] bytes) {
StringBuilder result = new StringBuilder(bytes.length * 4);
int i = 0;
while (i < bytes.length) {
int value = bytes[i] & 0xFF;
result.append(hexChar(value / 16));
result.append(hexChar(value % 16));
i++;
if... | fim | zxing/zxing | java |
<|fim_prefix|>/*
* Copyright 2008 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable ... | fim | zxing/zxing | java |
<|fim_suffix|>tterns = {"/w/decode"}, initParams = {
@WebInitParam(name = "timeoutSec", value = "10"),
})
public final class TimeoutFilter implements Filter {
private ExecutorService executorService;
private TimeLimiter timeLimiter;
private int timeoutSec;
@Override
public void init(FilterConfig filterCon... | fim | zxing/zxing | java |
<|fim_prefix|>/*
* Copyright 2014 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable ... | fim | zxing/zxing | java |
<|fim_prefix|>/*
* Copyright 2018 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable ... | fim | zxing/zxing | java |
<|fim_suffix|>SIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.zxing.web;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.mock.web.... | fim | zxing/zxing | java |
<|fim_prefix|>/*
* Copyright 2020 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable ... | fim | zxing/zxing | java |
<|fim_prefix|>/*
* Copyright 2018 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/license<|fim_suffix|>blic final class DoSFilterTestCase e... | fim | zxing/zxing | java |
<|fim_suffix|>rtFalse(tracker.isBanned("D"));
assertFalse(tracker.isBanned("A"));
// After building up a ban again, and letting plenty of time elapse, should un-ban
assertFalse(tracker.isBanned("A"));
assertTrue(tracker.isBanned("A"));
Thread.sleep(timerTimeMS * 3);
assertFalse(tracker.isBanned... | fim | zxing/zxing | java |
<|fim_prefix|>/*
* Copyright 2018 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
<|fim_suffix|>sponse.getStatus());
}
@Test
public void testRedirect() throws Ex... | fim | zxing/zxing | java |
<|fim_suffix|>als("bar", map.get("foo"));
assertEquals("baz", map.get("bar"));
map.put("baz", "bing");
assertEquals("bing", map.get("baz"));
assertNull(map.get("foo"));
}
}
<|fim_prefix|>/*
* Copyright 2018 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you ma... | fim | zxing/zxing | java |
<|fim_suffix|>nds Assert {
@Test
public void testOutput() {
byte[] array = { 0, 1, -1, 127, -128, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
assertEquals(
"00 01 ff 7f 80 02 03 04 05 06 07 08 09 0a 0b 0c\n",
OutputUtils.arrayToString(array));
}
}
<|fim_prefix|>/*
* Copyright 2017 ZXin... | fim | zxing/zxing | java |
/*
* Copyright 2020 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed ... | fim | zxing/zxing | java |
<|fim_suffix|>esponse.getStatus());
}
}
<|fim_prefix|>/*
* Copyright 2022 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the Licens<|fim_middle|>e.
* You may obtain a copy of the License at
*
* http://www.apache.org/... | fim | zxing/zxing | java |
<|fim_suffix|>ck.web.MockHttpServletResponse;
import jakarta.servlet.FilterChain;
import jakarta.servlet.http.HttpServletResponse;
/**
* Tests {@link WelcomeFilter}.
*/
public final class WelcomeFilterTestCase extends Assert {
@Test
public void testRedirect() {
MockHttpServletRequest request = new MockHttp... | fim | zxing/zxing | java |
<|fim_prefix|>"""private-gpt."""
import logging
import os
import warnings
from pydantic import PydanticDeprecatedSince20
from private_gpt.constants import PGPT_HOME
# Set to 'DEBUG' to have extensive logging turned on, even for libraries
ROOT_LOG_LEVEL = os.environ.get("PGPT_LOG_LEVEL", "INFO").upper()
PRETTY_LOG_... | fim | zylon-ai/private-gpt | python |
<|fim_prefix|>from private_gpt.cli.main import ma<|fim_suffix|>name__ == "__main__":
main()
<|fim_middle|>in
if __<|endoftext|> | fim | zylon-ai/private-gpt | python |
from private_gpt.celery.error import CeleryError
class InvalidFileError(CeleryError):
pass
class NotControlledArtifactError(RuntimeError):
pass
class ModelNotAvailableError(RuntimeError):
pass
<|endoftext|> | fim | zylon-ai/private-gpt | python |
<|fim_suffix|>ex_id,
)
async with _progress_lock:
_completed_batches += 1
current_percentage = (_completed_batches / total_batches) * 100
logger.info(
"Progress: %d/%d batches completed (%.2f%%)",
... | fim | zylon-ai/private-gpt | python |
<|fim_prefix|>import logging
from collections.abc import Callable
from pathlib import Path
from typing import Any
from llama_index.core import (
StorageContext,
VectorStoreIndex,
load_index_from_storage,
)
from llama_index.core.data_structs import IndexDict
from llama_index.core.indices.base import BaseInd... | fim | zylon-ai/private-gpt | python |
<|fim_prefix|>from collections.abc import Callable
from typing import Any
from pydantic import BaseModel, Field
from private_gpt.paths import local_data_path
from private_gpt.settings.settings import settings
celery_settings = settings().ce<|fim_suffix|>def _local_backend() -> BackendConfig:
local_data_path.mkdi... | fim | zylon-ai/private-gpt | python |
<|fim_suffix|>od is None:
raise NotImplementedError("Subclass must implement 'run' method")
# Inject injector
get_global_injector(allow_to_generate_new_injectors=True)
if asyncio.iscoroutinefunction(run_method):
result = await run_method(*args, **kwargs)
else:
... | fim | zylon-ai/private-gpt | python |
<|fim_suffix|>ady event."""
READINESS_FILE.touch()
@worker_shutdown.connect
def handle_worker_shutdown(**kwargs: dict[str, Any]) -> None:
"""Signal handler for worker shutdown event."""
READINESS_FILE.unlink(missing_ok=True)
HEARTBEAT_FILE.unlink(missing_ok=True)
<|fim_prefix|>from pathlib import Path... | fim | zylon-ai/private-gpt | python |
<|fim_prefix|>from collections.abc import Callable
from typing import Any
from pydantic import BaseModel, Field
from private_gpt.paths import local<|fim_suffix|> str, provider: BrokerConfigProvider) -> None:
_PROVIDERS[mode] = provider
def get_broker_config() -> BrokerConfig:
provider = _PROVIDERS.get(celer... | fim | zylon-ai/private-gpt | python |
<|fim_suffix|>c_response,
final=final,
)
def task_after_return(
task: Any,
state: str,
result: BaseModel,
_task_id: str,
args: Any,
_kwargs: dict[str, Any],
_none: Any,
) -> None:
"""Callback After any task is completed.
Every task will produce a message back to the br... | fim | zylon-ai/private-gpt | python |
<|fim_prefix|>from collections.abc import Callable, Sequence
from typing import Any
from celery import Celery
from private_gpt.celery.bootsteps import LivenessProbe
from private_gpt.celery.config import CeleryConfig, backend_config, broker_config
from private_gpt.celery.task_registry import get_task_packages
from pri... | fim | zylon-ai/private-gpt | python |
<|fim_suffix|> # Each worker process handles one task to prevent memory leaks.
)
<|fim_prefix|>from typing import Any, ClassVar
from private_gpt.celery.backend_config import BackendConfig, get_backend_config
from private_gpt.celery.broker_config import BrokerConfig, get_broker_config
from private_gpt.settings.sett... | fim | zylon-ai/private-gpt | python |
<|fim_suffix|> = None
):
self.details = CeleryErrorDetails(errors=errors, warnings=warnings)
def dict(self) -> CeleryErrorDetails:
return self.details
def __str__(self) -> str:
return f"{self.__class__.__name__}(errors={self.details.errors}, warnings={self.details.warnings})"
<|fim... | fim | zylon-ai/private-gpt | python |
<|fim_prefix|>import logging
import os
import time
from typing import Any
import requests
from fastapi import FastAPI, HTTPException
from private_gpt.celery.bootsteps import HEARTBEAT_FILE, READINESS_FILE
HEALTHCHECK_TIMEOUT = 10
def check_flower() -> bool:
try:
flower_port = os.getenv("PGPT_FLOWER_POR... | fim | zylon-ai/private-gpt | python |
<|fim_prefix|>from typing import Generic
from celery import Celery
from celery.result import AsyncResult
from pydantic import BaseModel, Field
from private_gpt.utils.custom_typing import T
class Task(BaseModel):
"""Represents an asynchronous task that has been queued."""
task_id: str = Field(
...,
... | fim | zylon-ai/private-gpt | python |
<|fim_prefix|>import enum
import math
from abc import ABC
from collections.abc import Callable, Generator
from contextlib import contextmanager
from threading import Event, Thread
from typing import Any, ClassVar, Protocol
from pydantic import BaseModel
class ProgressStep(enum.StrEnum):
pass
class ProgressStat... | fim | zylon-ai/private-gpt | python |
<|fim_suffix|>ginal states by adding custom ones
PROGRESS = "PROGRESS"
<|fim_prefix|># Extend th<|fim_middle|>e ori<|endoftext|> | fim | zylon-ai/private-gpt | python |
<|fim_suffix|>sted_task"):
if not task.args or not isinstance(
task.args[0], DeleteIngestedDocumentAsyncBody
):
continue
task_body: DeleteIngestedDocumentAsyncBody = task.args[0]
if (
task_body.delete_body.collection == col... | fim | zylon-ai/private-gpt | python |
<|fim_suffix|>es)
<|fim_prefix|>BASE_TASK_PACKAGES = ("private_gpt.celery.tasks",)
_EXTERNAL_TASK_PACKAGES: list[str] = []
def register_task_packages(*task_packages: str) -> None:
for task_package in task_packages:
if task_package not in _EXTERNAL_TASK_PACKAGES:
_EXTERNAL_TASK_PACKAGES.append... | fim | zylon-ai/private-gpt | python |
<|fim_prefix|>from p<|fim_suffix|>__.extend(ingestion_all)
<|fim_middle|>rivate_gpt.celery.tasks.ingestion import __all__ as ingestion_all
__all__ = []
__all<|endoftext|> | fim | zylon-ai/private-gpt | python |
<|fim_suffix|>k",
"vector_index_task",
]
<|fim_prefix|>from private_gpt.celery.tasks.ingestion.delete_tasks import delete_ingested_task
from private_gpt.cele<|fim_middle|>ry.tasks.ingestion.extraction_tasks import vector_index_task
__all__ = [
"delete_ingested_tas<|endoftext|> | fim | zylon-ai/private-gpt | python |
import logging
from typing import TYPE_CHECKING
from private_gpt.artifact_index.base_artifact_index import IndexNotReadyException
from private_gpt.celery.base import AsyncBackgroundTask
from private_gpt.celery.celery import celery_app
from private_gpt.celery.task_helper import IngestionTaskHelper
from private_gpt.di i... | fim | zylon-ai/private-gpt | python |
import logging
from collections.abc import Callable
from functools import wraps
from typing import Any, TypeVar
from private_gpt.artifact_index.base_artifact_index import IndexNotReadyException
from private_gpt.celery import states as custom_states
from private_gpt.celery.base import AsyncBackgroundTask
from private_g... | fim | zylon-ai/private-gpt | python |
<|fim_prefix|><|fim_suffix|>OpenAI compatibility utilities."""
<|fim_middle|>"""<|endoftext|> | fim | zylon-ai/private-gpt | python |
<|fim_prefix|>"""OpenAI API ext<|fim_suffix|>"""
<|fim_middle|>ensions.<|endoftext|> | fim | zylon-ai/private-gpt | python |
<|fim_suffix|>ocument from which the citation is derived",
)
@classmethod
def from_citation(cls, citation: Citation) -> "ZylonCitation":
return cls(
id=citation.doc_id,
index=citation.value.get("index") if citation.value else None,
artifact_id=citation.value.get(... | fim | zylon-ai/private-gpt | python |
<|fim_prefix|>from typing import Any
from pydantic import BaseModel, Field
class ContextFilter(BaseModel):
"""Filter by collection, artifacts and metadata in the ingested context.
The main filter is the collection the context is part of.
All artifacts ids are ensured to be part of the context. If any o... | fim | zylon-ai/private-gpt | python |
<|fim_prefix|>import enum
import warnings
from collections.abc import Callable, Sequence
from datetime import datetime
from itertools import groupby
from typing import Annotated, Any, Literal
from annotated_types import Ge, Le
from llama_index.core.base.llms.types import (
AudioBlock as LIAudioBlock,
)
from llama_... | fim | zylon-ai/private-gpt | python |
<|fim_suffix|>#/$defs/{model}",
schema_generator: Any = None,
mode: str = "validation",
) -> dict[str, Any]:
"""Return the original schema, not Pydantic's generated schema."""
return schema
model_config = ConfigDict(populate_by_name=True, use_attribute_do... | fim | zylon-ai/private-gpt | python |
<|fim_suffix|>"Run in background, return run ID"
),
session: str
| None = typer.Option(None, "--session", help="Resume a previous app session"),
model: str | None = typer.Option(None, "--model", help="Model name to use"),
auto_approve: bool = typer.Option(
False, "--auto-approve", help="Skip... | fim | zylon-ai/private-gpt | python |
<|fim_suffix|>host,
port=resolved_port,
reload=reload,
log_level=log_level,
log_config=None,
loop="asyncio",
)
finally:
if pid_file and pid_file.exists():
pid_file.unlink(missing_ok=True)
<|fim_prefix|>import logging
import os
i... | fim | zylon-ai/private-gpt | python |
<|fim_prefix|>import os
import signal
import subprocess
import sys
import typer
def _build_flower_args(mode: str) -> list[str]:
args: list[str] = []
url_prefix = os.environ.get("PGPT_FLOWER_URL_PREFIX", "")
port = os.environ.get("PGPT_FLOWER_PORT", "5555")
password = os.environ.get("PGPT_FLOWER_PASSW... | fim | zylon-ai/private-gpt | python |
<|fim_prefix|>import difflib
import sys
import typer
from private_gpt.cli.commands.run import run_command
from private_gpt.cli.commands.serve import serve_command
try:
import celery as _celery # noqa: F401
from private_gpt.cli.commands.worker import worker_command
_CELERY_AVAILABLE = True
except Impor... | fim | zylon-ai/private-gpt | python |
<|fim_suffix|>ob(NamedTuple):
exchange: str
routing_key: str
body: bytes
class BlockingPublisher(threading.Thread):
"""Simple publisher that will keep the connection alive on its own thread."""
exchange: str
parameters: URLParameters
_connection: BlockingConnection | None
_channel: B... | fim | zylon-ai/private-gpt | python |
<|fim_suffix|>change}/{routing_key}, {len(body)} bytes")
def join(self) -> None:
"""Drain all queued messages without stopping the publisher thread."""
if self.blocking_publisher is not None:
logger.debug("Draining blocking publisher")
self.blocking_publisher.drain()
de... | fim | zylon-ai/private-gpt | python |
<|fim_suffix|>ts."""
<|fim_prefix|>"""Chat <|fim_middle|>domain componen<|endoftext|> | fim | zylon-ai/private-gpt | python |
<|fim_suffix|>at shared models."""
<|fim_prefix|>""<|fim_middle|>"Ch<|endoftext|> | fim | zylon-ai/private-gpt | python |
<|fim_prefix|>from llama_index.core.agent import ToolCallResult
from llama_index.core.agent.workflow import (
AgentStream as LIAge<|fim_suffix|>tBlockType | None] | None = None
class ToolResultOrNothing(Event):
tool: BaseTool
result: ToolCallResult | None = None
executed: bool = False
<|fim_middle|>nt... | fim | zylon-ai/private-gpt | python |
import builtins
import inspect
import re
from collections.abc import Awaitable, Callable
from typing import Any, Literal
from llama_index.core.base.llms.types import ChatMessage, MessageRole, TextBlock
from llama_index.core.llms import LLM
from llama_index.core.tools import BaseTool, FunctionTool
from llama_index.core... | fim | zylon-ai/private-gpt | python |
<|fim_suffix|>
<|fim_prefix|>"""Cha<|fim_middle|>t processors."""<|endoftext|> | fim | zylon-ai/private-gpt | python |
<|fim_suffix|>ontent
):
last_user_message.blocks = [
LITextBlock(text=f"{last_user_message.content}. {suffix}")
]
if deduplicate_documents and chat_history:
# Deduplicate documents in the chat history to avoid sending the
# same document multiple time... | fim | zylon-ai/private-gpt | python |
import abc
import enum
from collections.abc import Callable
from typing import Any
from injector import Injector
from llama_index.core.base.llms.types import ChatMessage
from private_gpt.components.llm.llm_component import LLMComponent
from private_gpt.components.prompts.prompt_builder import PromptBuilderService
fro... | fim | zylon-ai/private-gpt | python |
<|fim_suffix|> current_left),
asyncio.to_thread(
repair_with_tools, [last_user_message, *current_right], strict=False
),
)
current_history = [*current_left, *current_right]
current_tokens = await self._get_messages_tokens(
current_history, tok... | fim | zylon-ai/private-gpt | python |
import asyncio
import logging
from collections.abc import AsyncGenerator
from typing import Any
from injector import Injector
from llama_index.core.base.llms.types import ChatMessage
from pydantic import BaseModel
from private_gpt.components.chat.processors.chat_history.memory.strategies.base_strategy import (
Ba... | fim | zylon-ai/private-gpt | python |
<|fim_prefix|>from llama_index.core.base.llms.types import ChatMessage, MessageRole
def _is_left_tldr(msg: ChatMessage) -> bool:
return msg.additional_kwargs.get("tldr") == "left"
def _is_right_tldr(msg: ChatMessage) -> bool:
return msg.additional_kwargs.get("tldr") == "right"
def _trim_right_tldrs(messag... | fim | zylon-ai/private-gpt | python |
<|fim_suffix|>ole.USER:
last_user_message = msg
break
if not last_user_message:
raise ValueError("No user message found in conversation history.")
def is_truncated(msg: ChatMessage) -> bool:
if not msg.additional_kwargs:
return False
if "tldr" not in... | fim | zylon-ai/private-gpt | python |
<|fim_prefix|>import json
from collections.abc import Sequence
from typing import Any, cast
from llama_index.core.base.llms.types import ChatMessage
from pydantic import BaseModel
from private_gpt.components.engines.citations.format import format_context
from private_gpt.components.engines.citations.types import Docu... | fim | zylon-ai/private-gpt | python |
<|fim_prefix|>from llama_index.core.base.llms.types import ChatMessage, MessageRole
from private_gpt.components.chat.processors.chat_history.memory.utils.splitting import (
get_system_and_conversation_messages,
get_user_blocks,
)
def _guarantee_valid_user_block_sequence(
messages: list[ChatMessage],
... | fim | zylon-ai/private-gpt | python |
<|fim_suffix|> merged_history.append(last_message)
last_message = message
if last_message:
merged_history.append(last_message)
return merged_history
<|fim_prefix|>from llama_index.core.base.llms.types import ChatMessage
def merge_adjacent_messages(
chat_history: list[ChatMessa... | fim | zylon-ai/private-gpt | python |
from llama_index.core.base.llms.types import ChatMessage
from private_gpt.components.chat.processors.chat_history.memory.utils.format import (
guarantee_valid_message_sequence,
)
from private_gpt.components.chat.processors.chat_history.memory.utils.merge import (
merge_adjacent_messages,
)
from private_gpt.com... | fim | zylon-ai/private-gpt | python |
<|fim_suffix|>sage]] = []
current_block: list[ChatMessage] = []
for msg in chat_history.copy():
if msg.role == "user" and current_block:
blocks.append(current_block)
current_block = [msg]
else:
current_block.append(msg)
if current_block:
blocks.a... | fim | zylon-ai/private-gpt | python |
<|fim_prefix|>from collections.abc import AsyncIterator
from typing import Any
from llama_index.core.base.llms.types import TextBlock as LITextBlock
from llama_index.core.llms import LLM, ChatMessage
from pydantic import BaseM<|fim_suffix|>se ValueError("Failed to describe audio in the message.")
event = even... | fim | zylon-ai/private-gpt | python |
<|fim_prefix|>from collections.abc import AsyncIterator
from typing import Any
from llama_index.core.base.llms.types import TextBlock as LITextBlock
from llama_index.core.llms import LLM, ChatMessage
from pydantic import BaseModel
from private_gpt.components.chat.processors.chat_history.multimodality.models import (
... | fim | zylon-ai/private-gpt | python |
<|fim_prefix|>from typing import Literal
from llama_index.core.base.llms.types import ChatMessage
from pydantic import BaseModel
class MultimodalProcessingStatus(BaseModel):
status: Literal["processing", "completed", "failed"]
type: Literal["image", "audio", "video", "other"]
message: ChatMessage | None ... | fim | zylon-ai/private-gpt | python |
<|fim_suffix|>inal_audio_message:
final_blocks.extend(audio_response.message.blocks)
if final_blocks:
final_message.blocks = final_blocks
yield MultimodalProcessingResponse(modified_message=final_message)
async def preprocess_multimodal_history(
main_llm: LLM,
chat_histor... | fim | zylon-ai/private-gpt | python |
<|fim_suffix|>f not isinstance(block, ImageBlock | AudioBlock)
]
return ChatMessage(
role=message.role,
content=message.content,
blocks=filtered_blocks,
)
<|fim_prefix|>from llama_index.core.base.llms.types import AudioBlock, ImageBlock
from llama_index.core.llms import LLM, ChatMes... | fim | zylon-ai/private-gpt | python |
<|fim_prefix|>from<|fim_suffix|>hatMessage]:
last_user_message = next(
(msg for msg in reversed(chat_history) if msg.role == MessageRole.USER),
None,
)
last_message = chat_history[-1]
if not last_user_message or last_user_message.content != last_message.content:
return chat_hist... | fim | zylon-ai/private-gpt | python |
<|fim_suffix|>ockStartEvent):
send_text = ""
send_citations = []
current_text = ""
elif isinstance(event, RawContentBlockDeltaEvent) and event.delta:
if isinstance(event.delta, TextDelta):
delta_text = event.delta.text or ""
curren... | fim | zylon-ai/private-gpt | python |
<|fim_prefix|>import uuid
from typing import Any, Literal
from llama_index.core.schema import NodeWithScore
from pydantic import BaseModel, Field
from private_gpt.components.ingest.metadata_helper import (
MetadataChunk,
MetadataDocument,
MetadataKeys,
)
from private_gpt.components.readers.nodes import Tr... | fim | zylon-ai/private-gpt | python |
<|fim_prefix|>from abc import ABC, abstractmethod
from collections.abc import Callable
from pydantic import BaseModel, ConfigDict
from private_gpt.settings.settings import Settings
class BashExecutionResult(BaseModel):
model_config = ConfigDict(frozen=True)
success: bool
stdout: str = ""
stderr: st... | fim | zylon-ai/private-gpt | python |
<|fim_prefix|>import threading
from injector import inject, singleton
from private_gpt.components.code_execution.base import (
CodeExecutionProvider,
CodeExecutionSession,
)
from private_gpt.components.code_execution.registry import CodeExecutionProviderRegistry
from private_gpt.settings.settings i<|fim_suffi... | fim | zylon-ai/private-gpt | python |
<|fim_prefix|>import shutil
from pathlib import Path
import anyio
from private_gpt.components.code_execution.base import (
BashExecutionResult,
CodeExecutionProvider,
CodeExecutionSession,
FileOperationResult,
)
from private_gpt.components.sandbox.base import SandboxExecOptions
from private_gpt.compon... | fim | zylon-ai/private-gpt | python |
<|fim_suffix|> self._providers: dict[str, CodeExecutionProvider] = {}
def get_provider(self, name: str) -> CodeExecutionProvider:
provider = self._providers.get(name)
if provider is not None:
return provider
provider_factory = _PROVIDERS.get(name)
if provider_fac... | fim | zylon-ai/private-gpt | python |
<|fim_suffix|> future: asyncio.Future[Any] = asyncio.Future()
self._tasks[request_id] = (task_func, kwargs, future)
self._counter += 1
# Lower value == higher priority
self._queue.put_nowait((priority, self._counter, request_id))
logger.debug("Enqueued local task %s (priori... | fim | zylon-ai/private-gpt | python |
<|fim_prefix|>"""Async priority queue with distributed concurrency control using Redis."""
import asyncio
impor<|fim_suffix|>tems[1])
return {items[1], items[2]}
"""
result = await redis.eval(script, 1, self.queue_key) # type: ignore
if not result:
return None
pay... | fim | zylon-ai/private-gpt | python |
<|fim_prefix|>from __future__ import annotations
import logging
from collections.abc import Callable
from private_gpt.components.concurrency.semaphore_manager import SemaphoreManager
from private_gpt.di import get_global_injector
from private_gpt.settings.settings import Settings
from private_gpt.utils.dependencies i... | fim | zylon-ai/private-gpt | python |
"""Semaphore manager abstraction."""
from __future__ import annotations
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING, Any
if TYPE_CHECKING:
from collections.abc import Awaitable, Callable
class QueueShutdownError(Exception):
pass
class SemaphoreManager(ABC):
"""Abstract semaph... | fim | zylon-ai/private-gpt | python |
"""Define typed errors for context assembly validation."""
from enum import StrEnum
class ContextErrorCode(StrEnum):
"""Define stable error codes for context module failures."""
TOOL_NAME_CONFLICT = "TOOL_NAME_CONFLICT"
class ContextDomainError(Exception):
"""Represent a typed context domain error wit... | fim | zylon-ai/private-gpt | python |
<|fim_suffix|> f' <skill name="{entry.name}" description="{entry.description}" />'
for entry in self.entries
]
return "<available_skills>\n" + "\n".join(lines) + "\n</available_skills>"
class SkillBodyLayer(BaseContextLayer):
"""Full instructions for one activated skill."""
... | fim | zylon-ai/private-gpt | python |
<|fim_suffix|>layer for layer in self.layers if layer.type is not layer_type]
)
def remove_layers_of_source(self, source: str) -> "ContextStack":
"""Return a new stack with all layers of *source* removed."""
return ContextStack(
layers=[layer for layer in self.layers if layer.so... | fim | zylon-ai/private-gpt | python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.