prompty 0.1.49__py3-none-any.whl → 0.1.50__py3-none-any.whl

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.
prompty/__init__.py CHANGED
@@ -67,7 +67,7 @@ def headless(
67
67
  """
68
68
 
69
69
  # get caller's path (to get relative path for prompty.json)
70
- caller = Path(traceback.extract_stack()[-2].filename)
70
+ caller = Path(traceback.extract_stack()[-3].filename)
71
71
  templateSettings = TemplateSettings(type="NOOP", parser="NOOP")
72
72
  modelSettings = ModelSettings(
73
73
  api=api,
@@ -124,7 +124,7 @@ async def headless_async(
124
124
  """
125
125
 
126
126
  # get caller's path (to get relative path for prompty.json)
127
- caller = Path(traceback.extract_stack()[-2].filename)
127
+ caller = Path(traceback.extract_stack()[-3].filename)
128
128
  templateSettings = TemplateSettings(type="NOOP", parser="NOOP")
129
129
 
130
130
  global_config = await load_global_config_async(caller.parent, connection)
prompty/utils.py CHANGED
@@ -33,21 +33,31 @@ async def load_json_async(file_path, encoding="utf-8"):
33
33
  return json.loads(content)
34
34
 
35
35
 
36
+ def _walk_up_path(path: Path) -> typing.Union[Path, None]:
37
+ """Walk up the path to find a prompty.json file.
38
+
39
+ Args:
40
+ path (Path): The path to start searching from.
41
+ """
42
+ while path != path.parent:
43
+ # Check if the prompty.json file exists in the current directory
44
+ prompty_config = path / "prompty.json"
45
+ if prompty_config.exists():
46
+ return prompty_config
47
+ # Move up to the parent directory
48
+ path = path.parent
49
+ return None
50
+
51
+
36
52
  def _find_global_config(prompty_path: Path = Path.cwd()) -> typing.Union[Path, None]:
37
- prompty_config = list(Path.cwd().glob("**/prompty.json"))
38
-
39
- if len(prompty_config) > 0:
40
- sorted_list = sorted(
41
- [
42
- c
43
- for c in prompty_config
44
- if len(c.parent.parts) <= len(prompty_path.parts)
45
- ],
46
- key=lambda p: len(p.parts),
47
- )
48
- return sorted_list[-1] if len(sorted_list) > 0 else None
53
+ """Find the prompty.json file in the current directory or any parent directory.
54
+ Args:
55
+ prompty_path (Path): The path to start searching from.
56
+ """
57
+ if Path(prompty_path / "prompty.json").exists():
58
+ return Path(prompty_path / "prompty.json")
49
59
  else:
50
- return None
60
+ return _walk_up_path(prompty_path)
51
61
 
52
62
 
53
63
  def load_global_config(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: prompty
3
- Version: 0.1.49
3
+ Version: 0.1.50
4
4
  Summary: Prompty is a new asset class and format for LLM prompts that aims to provide observability, understandability, and portability for developers. It includes spec, tooling, and a runtime. This Prompty runtime supports Python
5
5
  Author-Email: Seth Juarez <seth.juarez@microsoft.com>
6
6
  License: MIT
@@ -1,8 +1,8 @@
1
- prompty-0.1.49.dist-info/METADATA,sha256=me6Z8gphAgWMs0lfuSOjf7E2afCeNCI_y_-5mkxO_9k,9337
2
- prompty-0.1.49.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
3
- prompty-0.1.49.dist-info/entry_points.txt,sha256=a3i7Kvf--3DOkkv9VQpstwaNKgsnXwDGaPL18lPpKeI,60
4
- prompty-0.1.49.dist-info/licenses/LICENSE,sha256=KWSC4z9cfML_t0xThoQYjzTdcZQj86Y_mhXdatzU-KM,1052
5
- prompty/__init__.py,sha256=Nq49LsDwe8smD51MLsjGDlk6soc3knKoXkAmdUJNibA,16937
1
+ prompty-0.1.50.dist-info/METADATA,sha256=uUwJ0AWc1dYLhqViFy69hmlMcFvPTXZEABUzLgaJDnc,9337
2
+ prompty-0.1.50.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
3
+ prompty-0.1.50.dist-info/entry_points.txt,sha256=a3i7Kvf--3DOkkv9VQpstwaNKgsnXwDGaPL18lPpKeI,60
4
+ prompty-0.1.50.dist-info/licenses/LICENSE,sha256=KWSC4z9cfML_t0xThoQYjzTdcZQj86Y_mhXdatzU-KM,1052
5
+ prompty/__init__.py,sha256=uxK7vPvI_ASJoAWwo_P4eHkTV3GttHr4UvHFnyHDdaQ,16937
6
6
  prompty/azure/__init__.py,sha256=zBxzOMQCwtiz2CsI8gNWzr7T2ZJHF3TZNIUtvfuaEQI,309
7
7
  prompty/azure/executor.py,sha256=MWeBwprLY2NmPySoOq-K3qMui5lPlMYMh5ktb3S7mgo,9367
8
8
  prompty/azure/processor.py,sha256=gNmUkPBoSLPE0t7IVJUxGdwZ2otiycDE4Fu6L1vurZI,5330
@@ -22,5 +22,5 @@ prompty/serverless/__init__.py,sha256=ILtbqhy6E-wWodbnq-_aftruTGk1Z0EI9zURFH4FEC
22
22
  prompty/serverless/executor.py,sha256=QZXeFTXv_aT22rbBBgBFLtdAJqGp4W8GS3H3Rtoy8bE,8936
23
23
  prompty/serverless/processor.py,sha256=d42MalWRf8RUpHRiueqAPAj_nGmJSMUE2yL-Tgxrss4,3754
24
24
  prompty/tracer.py,sha256=GYJsFfsF5uexv1RANENX_Xm5sOnIcQHT_LLAtr6JocU,12158
25
- prompty/utils.py,sha256=0EmzWgRWPe6IgHOzoIy0k4_BMDUN4FHo0iITD-g1Ny8,2904
26
- prompty-0.1.49.dist-info/RECORD,,
25
+ prompty/utils.py,sha256=ZhiGY2BKe26LQmzUgeoz5i9s52-tlvOzh61ui3y0tIg,3297
26
+ prompty-0.1.50.dist-info/RECORD,,