llmling 2.0.2__tar.gz → 2.0.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {llmling-2.0.2 → llmling-2.0.4}/PKG-INFO +1 -1
- {llmling-2.0.2 → llmling-2.0.4}/pyproject.toml +1 -1
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/cli/utils.py +1 -19
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/config/manager.py +3 -3
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/config/models.py +7 -6
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/config/runtime.py +13 -10
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/config/store.py +2 -2
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/config/utils.py +11 -8
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/core/log.py +2 -5
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/core/typedefs.py +1 -13
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/prompts/models.py +2 -1
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/resources/loaders/repository.py +2 -3
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/resources/watching/utils.py +3 -2
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/utils/importing.py +1 -3
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/utils/paths.py +2 -3
- {llmling-2.0.2 → llmling-2.0.4}/LICENSE +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/README.md +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/__init__.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/__main__.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/cli/__init__.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/cli/config.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/cli/constants.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/cli/prompts.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/cli/resources.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/cli/tools.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/completions/__init__.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/completions/protocols.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/completions/types.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/config/__init__.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/config/base.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/config/llm_tools.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/config_resources/__init__.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/config_resources/basic.yml +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/config_resources/test.yml +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/config_resources/watch_examples.yml +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/config_resources/web_research.yml +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/core/__init__.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/core/baseregistry.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/core/chain.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/core/descriptors.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/core/exceptions.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/core/utils.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/log.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/processors/__init__.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/processors/base.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/processors/jinjaprocessor.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/processors/registry.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/prompts/__init__.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/prompts/registry.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/prompts/utils.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/py.typed +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/resources/__init__.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/resources/base.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/resources/loaders/__init__.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/resources/loaders/callable.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/resources/loaders/cli.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/resources/loaders/path.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/resources/loaders/registry.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/resources/loaders/source.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/resources/loaders/text.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/resources/models.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/resources/registry.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/resources/watching/__init__.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/resources/watching/watcher.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/testing/__init__.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/testing/processors.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/testing/tools.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/tools/__init__.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/tools/base.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/tools/code.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/tools/entry_points.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/tools/exceptions.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/tools/importing.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/tools/openapi.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/tools/registry.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/tools/toolsets.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/utils/__init__.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/utils/calling.py +0 -0
- {llmling-2.0.2 → llmling-2.0.4}/src/llmling/utils/watcher.py +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
import json
|
|
4
|
-
from typing import
|
|
4
|
+
from typing import Any, Literal
|
|
5
5
|
|
|
6
6
|
from pydantic import BaseModel
|
|
7
7
|
from schemez import OpenAIFunctionTool, Schema
|
|
@@ -9,9 +9,6 @@ from schemez import OpenAIFunctionTool, Schema
|
|
|
9
9
|
from llmling.config.store import config_store
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
if TYPE_CHECKING:
|
|
13
|
-
import os
|
|
14
|
-
|
|
15
12
|
OutputFormat = Literal["text", "json", "yaml"]
|
|
16
13
|
|
|
17
14
|
NO_CONFIG_MESSAGE = """
|
|
@@ -101,21 +98,6 @@ def format_output(
|
|
|
101
98
|
raise ValueError(msg)
|
|
102
99
|
|
|
103
100
|
|
|
104
|
-
def resolve_config_path(config: str | os.PathLike[str] | None) -> str:
|
|
105
|
-
"""Resolve config path from name or direct path."""
|
|
106
|
-
if not config:
|
|
107
|
-
if active := config_store.get_active():
|
|
108
|
-
return active.path
|
|
109
|
-
raise ValueError(NO_CONFIG_MESSAGE)
|
|
110
|
-
|
|
111
|
-
try:
|
|
112
|
-
# First try as stored config name
|
|
113
|
-
return config_store.get_config(str(config))
|
|
114
|
-
except KeyError:
|
|
115
|
-
# If not found, treat as direct path
|
|
116
|
-
return str(config)
|
|
117
|
-
|
|
118
|
-
|
|
119
101
|
def get_command_help(base_help: str) -> str:
|
|
120
102
|
"""Get command help text with active config information."""
|
|
121
103
|
if active := config_store.get_active():
|
|
@@ -180,9 +180,9 @@ class ConfigManager:
|
|
|
180
180
|
]
|
|
181
181
|
|
|
182
182
|
# Validate pip index URL if specified
|
|
183
|
-
if (
|
|
184
|
-
index_url
|
|
185
|
-
)
|
|
183
|
+
if (index_url := config.global_settings.pip_index_url) and not str(
|
|
184
|
+
index_url
|
|
185
|
+
).startswith(("http://", "https://")):
|
|
186
186
|
warnings.append(f"Invalid pip index URL: {index_url}")
|
|
187
187
|
|
|
188
188
|
# Validate extra paths exist
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
from collections.abc import Sequence
|
|
5
|
+
from collections.abc import Sequence
|
|
6
6
|
import inspect
|
|
7
7
|
import os
|
|
8
8
|
from typing import TYPE_CHECKING, Annotated, Any, Literal, Self
|
|
@@ -11,6 +11,7 @@ import warnings
|
|
|
11
11
|
from pydantic import (
|
|
12
12
|
ConfigDict,
|
|
13
13
|
Field,
|
|
14
|
+
HttpUrl, # noqa: TC002
|
|
14
15
|
SecretStr,
|
|
15
16
|
field_validator,
|
|
16
17
|
model_validator,
|
|
@@ -158,16 +159,16 @@ class Jinja2Config(ConfigModel):
|
|
|
158
159
|
class GlobalSettings(ConfigModel):
|
|
159
160
|
"""Global settings that apply to all components."""
|
|
160
161
|
|
|
161
|
-
timeout: int = 30
|
|
162
|
+
timeout: int = Field(default=30, ge=0)
|
|
162
163
|
"""Maximum time in seconds to wait for operations"""
|
|
163
164
|
|
|
164
|
-
max_retries: int = 3
|
|
165
|
+
max_retries: int = Field(default=3, ge=0)
|
|
165
166
|
"""Maximum number of retries for failed operations"""
|
|
166
167
|
|
|
167
168
|
requirements: list[str] = Field(default_factory=list)
|
|
168
169
|
"""List of package requirments for the functions used in this file."""
|
|
169
170
|
|
|
170
|
-
pip_index_url:
|
|
171
|
+
pip_index_url: HttpUrl | None = None
|
|
171
172
|
"""Alternative PyPI index URL for package installation"""
|
|
172
173
|
|
|
173
174
|
extra_paths: list[str] = Field(default_factory=list)
|
|
@@ -347,7 +348,7 @@ class CLIResource(BaseResource):
|
|
|
347
348
|
type: Literal["cli"] = Field(default="cli", init=False)
|
|
348
349
|
"""Discriminator field identifying this as a CLI-based resource."""
|
|
349
350
|
|
|
350
|
-
command: str |
|
|
351
|
+
command: str | Sequence[str]
|
|
351
352
|
"""Command to execute (string or sequence of arguments)."""
|
|
352
353
|
|
|
353
354
|
shell: bool = False
|
|
@@ -356,7 +357,7 @@ class CLIResource(BaseResource):
|
|
|
356
357
|
cwd: str | None = None
|
|
357
358
|
"""Working directory for command execution."""
|
|
358
359
|
|
|
359
|
-
timeout: float | None = None
|
|
360
|
+
timeout: float | None = Field(None, ge=0)
|
|
360
361
|
"""Maximum time in seconds to wait for command completion."""
|
|
361
362
|
|
|
362
363
|
@model_validator(mode="after")
|
|
@@ -11,8 +11,11 @@ import importlib
|
|
|
11
11
|
import os
|
|
12
12
|
from typing import TYPE_CHECKING, Any, Literal, Self
|
|
13
13
|
|
|
14
|
+
import upath
|
|
15
|
+
from upath import UPath
|
|
16
|
+
|
|
14
17
|
from llmling.config.manager import ConfigManager
|
|
15
|
-
from llmling.config.models import PathResource
|
|
18
|
+
from llmling.config.models import Config, PathResource
|
|
16
19
|
from llmling.config.utils import prepare_runtime, toolset_config_to_toolset
|
|
17
20
|
from llmling.core import exceptions
|
|
18
21
|
from llmling.core.chain import ChainTool
|
|
@@ -37,7 +40,7 @@ if TYPE_CHECKING:
|
|
|
37
40
|
|
|
38
41
|
from upath.types import JoinablePathLike
|
|
39
42
|
|
|
40
|
-
from llmling.config.models import BaseResource
|
|
43
|
+
from llmling.config.models import BaseResource
|
|
41
44
|
from llmling.processors.base import ProcessorResult
|
|
42
45
|
from llmling.prompts.models import BasePrompt
|
|
43
46
|
from llmling.resources.models import LoadedResource
|
|
@@ -93,7 +96,7 @@ class RuntimeConfig:
|
|
|
93
96
|
prefer_uv=settings.prefer_uv,
|
|
94
97
|
requirements=settings.requirements,
|
|
95
98
|
extra_paths=settings.extra_paths,
|
|
96
|
-
pip_index_url=settings.pip_index_url,
|
|
99
|
+
pip_index_url=str(settings.pip_index_url) if settings.pip_index_url else None,
|
|
97
100
|
scripts=settings.scripts,
|
|
98
101
|
)
|
|
99
102
|
|
|
@@ -219,7 +222,7 @@ class RuntimeConfig:
|
|
|
219
222
|
@asynccontextmanager
|
|
220
223
|
async def open(
|
|
221
224
|
cls,
|
|
222
|
-
source:
|
|
225
|
+
source: JoinablePathLike | Config,
|
|
223
226
|
*,
|
|
224
227
|
validate: bool = True,
|
|
225
228
|
strict: bool = False,
|
|
@@ -264,7 +267,7 @@ class RuntimeConfig:
|
|
|
264
267
|
@contextmanager
|
|
265
268
|
def open_sync(
|
|
266
269
|
cls,
|
|
267
|
-
source:
|
|
270
|
+
source: JoinablePathLike | Config,
|
|
268
271
|
*,
|
|
269
272
|
validate: bool = True,
|
|
270
273
|
strict: bool = False,
|
|
@@ -319,7 +322,7 @@ class RuntimeConfig:
|
|
|
319
322
|
return cls.from_config(manager.config)
|
|
320
323
|
|
|
321
324
|
@classmethod
|
|
322
|
-
def from_config(cls, config: Config |
|
|
325
|
+
def from_config(cls, config: Config | JoinablePathLike) -> Self:
|
|
323
326
|
"""Create a fully initialized runtime config from static config.
|
|
324
327
|
|
|
325
328
|
Args:
|
|
@@ -328,7 +331,7 @@ class RuntimeConfig:
|
|
|
328
331
|
Returns:
|
|
329
332
|
Initialized runtime configuration
|
|
330
333
|
"""
|
|
331
|
-
if isinstance(config, str | os.PathLike):
|
|
334
|
+
if isinstance(config, str | os.PathLike | UPath):
|
|
332
335
|
config = ConfigManager.load(config).config
|
|
333
336
|
loader_registry = ResourceLoaderRegistry()
|
|
334
337
|
processor_registry = ProcessorRegistry()
|
|
@@ -338,7 +341,7 @@ class RuntimeConfig:
|
|
|
338
341
|
)
|
|
339
342
|
prompt_registry = PromptRegistry()
|
|
340
343
|
tool_registry = ToolRegistry()
|
|
341
|
-
|
|
344
|
+
assert isinstance(config, Config)
|
|
342
345
|
runtime = cls(
|
|
343
346
|
config=config,
|
|
344
347
|
loader_registry=loader_registry,
|
|
@@ -901,7 +904,7 @@ class RuntimeConfig:
|
|
|
901
904
|
def register_file_prompt(
|
|
902
905
|
self,
|
|
903
906
|
name: str,
|
|
904
|
-
path:
|
|
907
|
+
path: JoinablePathLike,
|
|
905
908
|
*,
|
|
906
909
|
description: str,
|
|
907
910
|
output_format: Literal["text", "markdown", "jinja2"] = "text",
|
|
@@ -935,7 +938,7 @@ class RuntimeConfig:
|
|
|
935
938
|
|
|
936
939
|
prompt = FilePrompt(
|
|
937
940
|
name=name,
|
|
938
|
-
path=path,
|
|
941
|
+
path=upath.UPath(path),
|
|
939
942
|
description=description,
|
|
940
943
|
format=output_format,
|
|
941
944
|
watch=watch,
|
|
@@ -9,7 +9,7 @@ from llmling.core.log import get_logger
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
if TYPE_CHECKING:
|
|
12
|
-
import
|
|
12
|
+
from upath.types import JoinablePathLike
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
logger = get_logger(__name__)
|
|
@@ -80,7 +80,7 @@ class ConfigStore:
|
|
|
80
80
|
except Exception:
|
|
81
81
|
logger.exception("Failed to save config mapping")
|
|
82
82
|
|
|
83
|
-
def add_config(self, name: str, path:
|
|
83
|
+
def add_config(self, name: str, path: JoinablePathLike) -> None:
|
|
84
84
|
"""Add a new named config.
|
|
85
85
|
|
|
86
86
|
Args:
|
|
@@ -6,6 +6,7 @@ import os
|
|
|
6
6
|
from typing import TYPE_CHECKING
|
|
7
7
|
|
|
8
8
|
from pydantic import BaseModel
|
|
9
|
+
from upath import UPath
|
|
9
10
|
|
|
10
11
|
from llmling.config.manager import ConfigManager
|
|
11
12
|
from llmling.config.models import (
|
|
@@ -22,6 +23,8 @@ from llmling.utils import importing
|
|
|
22
23
|
|
|
23
24
|
|
|
24
25
|
if TYPE_CHECKING:
|
|
26
|
+
from upath.types import JoinablePathLike
|
|
27
|
+
|
|
25
28
|
from llmling.config.runtime import RuntimeConfig
|
|
26
29
|
from llmling.tools.toolsets import ToolSet
|
|
27
30
|
|
|
@@ -30,12 +33,12 @@ logger = get_logger(__name__)
|
|
|
30
33
|
|
|
31
34
|
def toolset_config_to_toolset(config) -> ToolSet:
|
|
32
35
|
match config:
|
|
33
|
-
case OpenAPIToolsetConfig():
|
|
34
|
-
return OpenAPITools(spec=
|
|
35
|
-
case EntryPointToolsetConfig():
|
|
36
|
-
return EntryPointTools(
|
|
37
|
-
case CustomToolsetConfig():
|
|
38
|
-
toolset_class = importing.import_class(
|
|
36
|
+
case OpenAPIToolsetConfig(spec=spec, base_url=base_url):
|
|
37
|
+
return OpenAPITools(spec=spec, base_url=base_url or "")
|
|
38
|
+
case EntryPointToolsetConfig(module=module):
|
|
39
|
+
return EntryPointTools(module)
|
|
40
|
+
case CustomToolsetConfig(import_path=import_path):
|
|
41
|
+
toolset_class = importing.import_class(import_path)
|
|
39
42
|
return toolset_class()
|
|
40
43
|
case _:
|
|
41
44
|
msg = f"Unknown toolset type: {type(config)}"
|
|
@@ -44,7 +47,7 @@ def toolset_config_to_toolset(config) -> ToolSet:
|
|
|
44
47
|
|
|
45
48
|
def prepare_runtime(
|
|
46
49
|
runtime_cls: type[RuntimeConfig],
|
|
47
|
-
source:
|
|
50
|
+
source: JoinablePathLike | Config,
|
|
48
51
|
*,
|
|
49
52
|
validate: bool = True,
|
|
50
53
|
strict: bool = False,
|
|
@@ -65,7 +68,7 @@ def prepare_runtime(
|
|
|
65
68
|
ConfigError: If validation fails in strict mode
|
|
66
69
|
"""
|
|
67
70
|
match source:
|
|
68
|
-
case str() | os.PathLike():
|
|
71
|
+
case str() | os.PathLike() | UPath():
|
|
69
72
|
manager = ConfigManager.load(source, validate=validate, strict=strict)
|
|
70
73
|
config = manager.config
|
|
71
74
|
case Config():
|
|
@@ -93,11 +93,8 @@ def setup_logging(
|
|
|
93
93
|
|
|
94
94
|
logger.info("Logging initialized")
|
|
95
95
|
if log_to_file:
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
logging.getLevelName(level),
|
|
99
|
-
LOG_FILE,
|
|
100
|
-
)
|
|
96
|
+
msg = "Console logging level: %s, File logging level: DEBUG (%s)"
|
|
97
|
+
logger.debug(msg, logging.getLevelName(level), LOG_FILE)
|
|
101
98
|
|
|
102
99
|
|
|
103
100
|
def get_logger(name: str) -> logging.Logger:
|
|
@@ -38,16 +38,6 @@ class MessageContent(Schema):
|
|
|
38
38
|
|
|
39
39
|
model_config = ConfigDict(frozen=True)
|
|
40
40
|
|
|
41
|
-
@classmethod
|
|
42
|
-
def text(cls, content: str) -> MessageContent:
|
|
43
|
-
"""Create text content."""
|
|
44
|
-
return cls(type="text", content=content)
|
|
45
|
-
|
|
46
|
-
@classmethod
|
|
47
|
-
def resource(cls, uri: str, description: str | None = None) -> MessageContent:
|
|
48
|
-
"""Create resource reference."""
|
|
49
|
-
return cls(type="resource", content=uri, alt_text=description)
|
|
50
|
-
|
|
51
41
|
@classmethod
|
|
52
42
|
def image(
|
|
53
43
|
cls,
|
|
@@ -135,6 +125,4 @@ class Message(Schema):
|
|
|
135
125
|
@property
|
|
136
126
|
def has_images(self) -> bool:
|
|
137
127
|
"""Check if message contains images."""
|
|
138
|
-
return any(
|
|
139
|
-
item.type in ("image_url", "image_base64") for item in self.content_items
|
|
140
|
-
)
|
|
128
|
+
return any(i.type in ("image_url", "image_base64") for i in self.content_items)
|
|
@@ -7,6 +7,7 @@ import os
|
|
|
7
7
|
from typing import TYPE_CHECKING, Annotated, Any, Literal, get_type_hints
|
|
8
8
|
|
|
9
9
|
from pydantic import BaseModel, ConfigDict, Field, ImportString
|
|
10
|
+
import upath
|
|
10
11
|
|
|
11
12
|
from llmling.completions import CompletionFunction # noqa: TC001
|
|
12
13
|
from llmling.core.log import get_logger
|
|
@@ -333,7 +334,7 @@ class FilePrompt(BasePrompt):
|
|
|
333
334
|
and parsed according to the specified format.
|
|
334
335
|
"""
|
|
335
336
|
|
|
336
|
-
path: str | os.PathLike[str]
|
|
337
|
+
path: str | os.PathLike[str] | upath.UPath
|
|
337
338
|
"""Path to the file containing the prompt content."""
|
|
338
339
|
|
|
339
340
|
fmt: Literal["text", "markdown", "jinja2"] = Field("text", alias="format")
|
|
@@ -15,10 +15,9 @@ from llmling.utils.paths import guess_mime_type
|
|
|
15
15
|
|
|
16
16
|
if TYPE_CHECKING:
|
|
17
17
|
from collections.abc import AsyncIterator
|
|
18
|
-
import os
|
|
19
18
|
|
|
20
19
|
from git.repo import Repo
|
|
21
|
-
from upath.types import
|
|
20
|
+
from upath.types import JoinablePathLike
|
|
22
21
|
|
|
23
22
|
from llmling.processors.registry import ProcessorRegistry
|
|
24
23
|
from llmling.resources.base import LoaderContext
|
|
@@ -57,7 +56,7 @@ class RepositoryResourceLoader(ResourceLoader[RepositoryResource]):
|
|
|
57
56
|
|
|
58
57
|
def _create_resource(
|
|
59
58
|
self,
|
|
60
|
-
path:
|
|
59
|
+
path: JoinablePathLike,
|
|
61
60
|
name: str,
|
|
62
61
|
resource: RepositoryResource,
|
|
63
62
|
) -> LoadedResource:
|
|
@@ -9,7 +9,8 @@ from llmling.core.log import get_logger
|
|
|
9
9
|
|
|
10
10
|
if TYPE_CHECKING:
|
|
11
11
|
from collections.abc import Sequence
|
|
12
|
-
|
|
12
|
+
|
|
13
|
+
from upath.types import JoinablePathLike
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
logger = get_logger(__name__)
|
|
@@ -17,7 +18,7 @@ logger = get_logger(__name__)
|
|
|
17
18
|
|
|
18
19
|
def load_patterns(
|
|
19
20
|
patterns: Sequence[str] | None = None,
|
|
20
|
-
ignore_file:
|
|
21
|
+
ignore_file: JoinablePathLike | None = None,
|
|
21
22
|
) -> list[str]:
|
|
22
23
|
"""Load and combine watch patterns.
|
|
23
24
|
|
|
@@ -22,9 +22,7 @@ def get_module_source(
|
|
|
22
22
|
"""Get source code from a module or package."""
|
|
23
23
|
try:
|
|
24
24
|
module = importlib.import_module(import_path)
|
|
25
|
-
sources =
|
|
26
|
-
_get_sources(module, recursive=recursive, include_tests=include_tests)
|
|
27
|
-
)
|
|
25
|
+
sources = _get_sources(module, recursive=recursive, include_tests=include_tests)
|
|
28
26
|
return "\n\n# " + "-" * 40 + "\n\n".join(sources)
|
|
29
27
|
|
|
30
28
|
except ImportError as exc:
|
|
@@ -10,9 +10,8 @@ import urllib.parse
|
|
|
10
10
|
|
|
11
11
|
if TYPE_CHECKING:
|
|
12
12
|
from collections.abc import Sequence
|
|
13
|
-
import os
|
|
14
13
|
|
|
15
|
-
from upath.types import
|
|
14
|
+
from upath.types import JoinablePathLike
|
|
16
15
|
|
|
17
16
|
|
|
18
17
|
INVALID_CHARS_PATTERN = re.compile(r'[\x00-\x1F<>:"|?*\\]')
|
|
@@ -82,7 +81,7 @@ def path_to_uri(path: str) -> str:
|
|
|
82
81
|
return f"file:///{'/'.join(encoded)}"
|
|
83
82
|
|
|
84
83
|
|
|
85
|
-
def guess_mime_type(path:
|
|
84
|
+
def guess_mime_type(path: JoinablePathLike) -> str:
|
|
86
85
|
"""Guess MIME type from file path using stdlib.
|
|
87
86
|
|
|
88
87
|
Args:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|