prompty 0.1.16__py2.py3-none-any.whl → 0.1.17__py2.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/cli.py CHANGED
@@ -10,8 +10,6 @@ import prompty
10
10
  from prompty.tracer import trace, PromptyTracer, console_tracer, Tracer
11
11
  from dotenv import load_dotenv
12
12
 
13
- load_dotenv()
14
-
15
13
 
16
14
  def normalize_path(p, create_dir=False) -> Path:
17
15
  path = Path(p)
@@ -27,8 +25,16 @@ def normalize_path(p, create_dir=False) -> Path:
27
25
 
28
26
  return path
29
27
 
28
+
30
29
  def dynamic_import(module: str):
31
- t = module if "." in module else f"prompty.{module}"
30
+ # built in modules
31
+ if module == "azure" or module == "azure_openai":
32
+ t = "prompty.azure"
33
+ elif module == "serverless":
34
+ t = "prompty.serverless"
35
+ else:
36
+ t = module
37
+
32
38
  print(f"Loading invokers from {t}")
33
39
  importlib.import_module(t)
34
40
 
@@ -60,7 +66,9 @@ def chat_mode(prompt_path: str):
60
66
  break
61
67
  # reloadable prompty file
62
68
  chat_history.append({"role": "user", "content": user_input})
63
- result = prompty.execute(prompt_path, inputs={"chat_history": chat_history})
69
+ result = prompty.execute(
70
+ prompt_path, inputs={"chat_history": chat_history}
71
+ )
64
72
  print(f"\n{G}Assistant:{W} {result}")
65
73
  chat_history.append({"role": "assistant", "content": result})
66
74
  except Exception as e:
@@ -92,10 +100,16 @@ def execute(prompt_path: str, raw=False):
92
100
 
93
101
  @click.command()
94
102
  @click.option("--source", "-s", required=True)
103
+ @click.option("--env", "-e", required=False)
95
104
  @click.option("--verbose", "-v", is_flag=True)
96
105
  @click.option("--chat", "-c", is_flag=True)
97
106
  @click.version_option()
98
- def run(source, verbose, chat):
107
+ def run(source, env, verbose, chat):
108
+ # load external env file
109
+ if env:
110
+ print(f"Loading environment variables from {env}")
111
+ load_dotenv(env)
112
+
99
113
  prompt_path = normalize_path(source)
100
114
  if not prompt_path.exists():
101
115
  print(f"{str(prompt_path)} does not exist")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: prompty
3
- Version: 0.1.16
3
+ Version: 0.1.17
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
  Requires-Dist: pyyaml>=6.0.1
@@ -1,13 +1,12 @@
1
- prompty-0.1.16.dist-info/METADATA,sha256=GrbCbCC5h_7Jen_jONo7lTvsfMvkvjuodRJDbBKvt4I,8916
2
- prompty-0.1.16.dist-info/WHEEL,sha256=CuZGaXTwoRLAOVv0AcE3bCTxO5ejVuBEJkUBe9C-kvk,94
3
- prompty-0.1.16.dist-info/entry_points.txt,sha256=9y1lKPWUpPWRJzUslcVH-gMwbNoa2PzjyoZsKYLQqyw,45
4
- prompty-0.1.16.dist-info/licenses/LICENSE,sha256=KWSC4z9cfML_t0xThoQYjzTdcZQj86Y_mhXdatzU-KM,1052
1
+ prompty-0.1.17.dist-info/METADATA,sha256=Dxi-bayoYlgrg2ldnCK54K5sDT9KXKctpMDRPJ8_0Bw,8916
2
+ prompty-0.1.17.dist-info/WHEEL,sha256=CuZGaXTwoRLAOVv0AcE3bCTxO5ejVuBEJkUBe9C-kvk,94
3
+ prompty-0.1.17.dist-info/entry_points.txt,sha256=9y1lKPWUpPWRJzUslcVH-gMwbNoa2PzjyoZsKYLQqyw,45
4
+ prompty-0.1.17.dist-info/licenses/LICENSE,sha256=KWSC4z9cfML_t0xThoQYjzTdcZQj86Y_mhXdatzU-KM,1052
5
5
  prompty/__init__.py,sha256=XTUgJ3xT7HYJieuWW5PBItey0BWneg3G7iBBjIeNJZU,11628
6
6
  prompty/azure/__init__.py,sha256=ptGajCh68s_tugPv45Y4GJCyBToNFCExUzUh9yIBIfo,292
7
7
  prompty/azure/executor.py,sha256=x2ng2EbYUxbingjy8w27TFGWezs4QC0LHh_S0F0-E1U,3082
8
8
  prompty/azure/processor.py,sha256=e9CcKG665zvCLPeJfS91FM6c_W_6YY0mVENxinCo19A,2253
9
- prompty/azure_openai/__init__.py,sha256=tjCu2NEF-YV3AZPPZfYjdkCzPtPbc2NfYazPb1Gu4GI,306
10
- prompty/cli.py,sha256=oIJ5aPCjwBl4xA5SWkbQ_Xj0KhzuSJhRnqV95DhfORc,3382
9
+ prompty/cli.py,sha256=k8Rxm41fMFNvmnsX737UiN6v-7756tpoJPN4rPXMNcU,3726
11
10
  prompty/core.py,sha256=O_Kvj7XjaNG50_mWzpxf5xVOEOWGYBkwBXqPA__5kz0,17126
12
11
  prompty/openai/__init__.py,sha256=16LxFrG_qGMg_Nx_BTMkCZupPEADsi8Gj234uFiXoZo,273
13
12
  prompty/openai/executor.py,sha256=5LXME0ACvbX3PSpSfh9ohDGWB50ZYBXLZG238wQiVGc,2212
@@ -18,4 +17,4 @@ prompty/serverless/__init__.py,sha256=NPqoFATEMQ96G8OQkVcGxUWU4llIQCwxfJePPo8YFY
18
17
  prompty/serverless/executor.py,sha256=fYCMV01iLBLpH2SQ9nxmrvY9ijAGpZezwkobZwUjSVQ,2781
19
18
  prompty/serverless/processor.py,sha256=pft1XGbPzo0MzQMbAt1VxsLsvRrjQO3B8MXEE2PfSA0,1982
20
19
  prompty/tracer.py,sha256=dwASxJsVnoUNIKLuBHtZAhD0JctbTCImBP5mjVGCnPo,8809
21
- prompty-0.1.16.dist-info/RECORD,,
20
+ prompty-0.1.17.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- # __init__.py
2
- from prompty.core import InvokerException
3
-
4
- try:
5
- from ..azure.executor import AzureOpenAIExecutor
6
- from ..azure.processor import AzureOpenAIProcessor
7
- except ImportError:
8
- raise InvokerException(
9
- "Error registering AzureOpenAIExecutor and AzureOpenAIProcessor", "azure"
10
- )