promptev 0.0.1__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.
promptev-0.0.1/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Promptev SDK License
2
+
3
+ Copyright © 2025 Promptev Inc.
4
+
5
+ This software is proprietary and protected under applicable copyright laws.
6
+ By using this software, you agree to the following:
7
+
8
+ 1. You may use this SDK:
9
+ - Free of charge on the Free Tier of Promptev services
10
+ - For evaluation or development purposes
11
+ - In production only with an active Promptev subscription
12
+
13
+ 2. Restrictions:
14
+ - You may NOT sublicense, distribute, or reverse-engineer this software
15
+ - You may NOT modify or resell this SDK or derivative works
16
+ - You may NOT use this SDK outside the Promptev API without a license
17
+
18
+ 3. The SDK is provided “AS IS” without warranties. Promptev Inc. shall not be held liable for any damages.
19
+
20
+ By using this software, you accept these terms. For licensing inquiries or enterprise use, contact support@promptev.ai.
@@ -0,0 +1,186 @@
1
+ Metadata-Version: 2.4
2
+ Name: promptev
3
+ Version: 0.0.1
4
+ Summary: Promptev SDK for accessing Promptev API
5
+ Author-email: Promptev Inc <support@promptev.ai>
6
+ License: Promptev SDK License
7
+
8
+ Copyright © 2025 Promptev Inc.
9
+
10
+ This software is proprietary and protected under applicable copyright laws.
11
+ By using this software, you agree to the following:
12
+
13
+ 1. You may use this SDK:
14
+ - Free of charge on the Free Tier of Promptev services
15
+ - For evaluation or development purposes
16
+ - In production only with an active Promptev subscription
17
+
18
+ 2. Restrictions:
19
+ - You may NOT sublicense, distribute, or reverse-engineer this software
20
+ - You may NOT modify or resell this SDK or derivative works
21
+ - You may NOT use this SDK outside the Promptev API without a license
22
+
23
+ 3. The SDK is provided “AS IS” without warranties. Promptev Inc. shall not be held liable for any damages.
24
+
25
+ By using this software, you accept these terms. For licensing inquiries or enterprise use, contact support@promptev.ai.
26
+
27
+ Project-URL: Homepage, https://promptev.ai
28
+ Keywords: Promptev,promptev,prompts,api,client,sdk,ai,promptDev,promptdev,promptops,python
29
+ Requires-Python: >=3.7
30
+ Description-Content-Type: text/markdown
31
+ License-File: LICENSE
32
+ Requires-Dist: httpx
33
+ Provides-Extra: cache
34
+ Requires-Dist: cachetools>=5.3.0; extra == "cache"
35
+ Dynamic: license-file
36
+
37
+ # promptev-client
38
+
39
+ A lightweight Python SDK to securely fetch and format prompts from [Promptev.ai](https://promptev.ai) using your project API key.
40
+
41
+ ---
42
+
43
+ ## Installation
44
+
45
+ ```bash
46
+ pip install promptev
47
+ ```
48
+
49
+ > Optional (recommended for production caching and background refresh):
50
+ ```bash
51
+ pip install cachetools
52
+ ```
53
+
54
+ ---
55
+
56
+ ## What is Promptev?
57
+
58
+ [Promptev](https://promptev.ai) helps teams manage, version, and collaborate on AI prompts at scale — with variables, live context packs, histories, cost estimation, and SDK access.
59
+
60
+ ---
61
+
62
+ ## Usage
63
+
64
+ ### 1. Initialize the client
65
+
66
+ ```python
67
+ from promptev import PromptevClient
68
+
69
+ client = PromptevClient(project_key="pv_sk_abc123yourkey")
70
+ ```
71
+
72
+ ---
73
+
74
+ ### 2. Fetch a prompt with variables
75
+
76
+ ```python
77
+ output = client.get_prompt("onboarding-email", {
78
+ "name": "Ava",
79
+ "product": "Promptev"
80
+ })
81
+
82
+ print(output)
83
+ # Output: "Subject: Welcome, Ava! Hey Ava, Thanks for joining Promptev..."
84
+ ```
85
+
86
+ ---
87
+
88
+ ### 3. Fetch a prompt without variables
89
+
90
+ ```python
91
+ output = client.get_prompt("static-welcome")
92
+ print(output)
93
+ # Output: "You are a helpful AI assistant ready to support the user."
94
+ ```
95
+
96
+ > ⚠️ If the prompt has no variables, you can omit the second argument.
97
+
98
+ ---
99
+
100
+ ### 4. Async Usage (e.g. in FastAPI or notebooks)
101
+
102
+ ```python
103
+ import asyncio
104
+
105
+ async def run():
106
+ prompt = await client.aget_prompt("faq-response", {
107
+ "question": "How do I reset my password?"
108
+ })
109
+ print(prompt)
110
+
111
+ asyncio.run(run())
112
+ ```
113
+
114
+ ---
115
+
116
+ ## Example: Use with LLM APIs
117
+
118
+ ### OpenAI
119
+
120
+ ```python
121
+ from openai import OpenAI
122
+
123
+ client = OpenAI(api_key="sk-...")
124
+
125
+ prompt = promptev_client.get_prompt("explain-topic", {
126
+ "topic": "Prompt Engineering"
127
+ })
128
+
129
+ response = client.chat.completions.create(
130
+ model="gpt-4",
131
+ messages=[{"role": "user", "content": prompt}]
132
+ )
133
+
134
+ print(response.choices[0].message.content)
135
+ ```
136
+
137
+ ---
138
+
139
+ ## Features
140
+
141
+ - ✅ Supports prompts with or without variables
142
+ - 🔁 Smart caching (via `dict` or `TTLCache`)
143
+ - 🧠 Built-in variable formatting & validation
144
+ - ⚡ Sync + Async compatible
145
+ - 🔐 Works with any LLM (OpenAI, Claude, Gemini, etc.)
146
+ - 🔌 BYOK + airgapped environment ready
147
+
148
+ ---
149
+
150
+ ## Error Handling
151
+
152
+ ```python
153
+ # ❌ Missing required variable
154
+ client.get_prompt("onboarding-email", { "name": "Leo" })
155
+ # ➜ ValueError: Missing required variables: product
156
+ ```
157
+
158
+ ---
159
+
160
+ ## Prompt Template Example
161
+
162
+ ```text
163
+ Subject: Welcome, {{ name }}!
164
+
165
+ Hey {{ name }},
166
+
167
+ Thanks for joining {{ product }}. We're thrilled to have you on board!
168
+ ```
169
+
170
+ ---
171
+
172
+ ## License
173
+
174
+ This SDK is **commercial software** by Promptev Inc.
175
+
176
+ By using this package, you agree to the terms in [`LICENSE.txt`](./LICENSE.txt).
177
+
178
+ - ✅ Free tier use allowed
179
+ - 🚫 Production usage requires a subscription
180
+
181
+ ---
182
+
183
+ ## Contact
184
+
185
+ - 🌐 [https://promptev.ai](https://promptev.ai)
186
+ - 📧 support@promptev.ai
@@ -0,0 +1,150 @@
1
+ # promptev-client
2
+
3
+ A lightweight Python SDK to securely fetch and format prompts from [Promptev.ai](https://promptev.ai) using your project API key.
4
+
5
+ ---
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ pip install promptev
11
+ ```
12
+
13
+ > Optional (recommended for production caching and background refresh):
14
+ ```bash
15
+ pip install cachetools
16
+ ```
17
+
18
+ ---
19
+
20
+ ## What is Promptev?
21
+
22
+ [Promptev](https://promptev.ai) helps teams manage, version, and collaborate on AI prompts at scale — with variables, live context packs, histories, cost estimation, and SDK access.
23
+
24
+ ---
25
+
26
+ ## Usage
27
+
28
+ ### 1. Initialize the client
29
+
30
+ ```python
31
+ from promptev import PromptevClient
32
+
33
+ client = PromptevClient(project_key="pv_sk_abc123yourkey")
34
+ ```
35
+
36
+ ---
37
+
38
+ ### 2. Fetch a prompt with variables
39
+
40
+ ```python
41
+ output = client.get_prompt("onboarding-email", {
42
+ "name": "Ava",
43
+ "product": "Promptev"
44
+ })
45
+
46
+ print(output)
47
+ # Output: "Subject: Welcome, Ava! Hey Ava, Thanks for joining Promptev..."
48
+ ```
49
+
50
+ ---
51
+
52
+ ### 3. Fetch a prompt without variables
53
+
54
+ ```python
55
+ output = client.get_prompt("static-welcome")
56
+ print(output)
57
+ # Output: "You are a helpful AI assistant ready to support the user."
58
+ ```
59
+
60
+ > ⚠️ If the prompt has no variables, you can omit the second argument.
61
+
62
+ ---
63
+
64
+ ### 4. Async Usage (e.g. in FastAPI or notebooks)
65
+
66
+ ```python
67
+ import asyncio
68
+
69
+ async def run():
70
+ prompt = await client.aget_prompt("faq-response", {
71
+ "question": "How do I reset my password?"
72
+ })
73
+ print(prompt)
74
+
75
+ asyncio.run(run())
76
+ ```
77
+
78
+ ---
79
+
80
+ ## Example: Use with LLM APIs
81
+
82
+ ### OpenAI
83
+
84
+ ```python
85
+ from openai import OpenAI
86
+
87
+ client = OpenAI(api_key="sk-...")
88
+
89
+ prompt = promptev_client.get_prompt("explain-topic", {
90
+ "topic": "Prompt Engineering"
91
+ })
92
+
93
+ response = client.chat.completions.create(
94
+ model="gpt-4",
95
+ messages=[{"role": "user", "content": prompt}]
96
+ )
97
+
98
+ print(response.choices[0].message.content)
99
+ ```
100
+
101
+ ---
102
+
103
+ ## Features
104
+
105
+ - ✅ Supports prompts with or without variables
106
+ - 🔁 Smart caching (via `dict` or `TTLCache`)
107
+ - 🧠 Built-in variable formatting & validation
108
+ - ⚡ Sync + Async compatible
109
+ - 🔐 Works with any LLM (OpenAI, Claude, Gemini, etc.)
110
+ - 🔌 BYOK + airgapped environment ready
111
+
112
+ ---
113
+
114
+ ## Error Handling
115
+
116
+ ```python
117
+ # ❌ Missing required variable
118
+ client.get_prompt("onboarding-email", { "name": "Leo" })
119
+ # ➜ ValueError: Missing required variables: product
120
+ ```
121
+
122
+ ---
123
+
124
+ ## Prompt Template Example
125
+
126
+ ```text
127
+ Subject: Welcome, {{ name }}!
128
+
129
+ Hey {{ name }},
130
+
131
+ Thanks for joining {{ product }}. We're thrilled to have you on board!
132
+ ```
133
+
134
+ ---
135
+
136
+ ## License
137
+
138
+ This SDK is **commercial software** by Promptev Inc.
139
+
140
+ By using this package, you agree to the terms in [`LICENSE.txt`](./LICENSE.txt).
141
+
142
+ - ✅ Free tier use allowed
143
+ - 🚫 Production usage requires a subscription
144
+
145
+ ---
146
+
147
+ ## Contact
148
+
149
+ - 🌐 [https://promptev.ai](https://promptev.ai)
150
+ - 📧 support@promptev.ai
@@ -0,0 +1,43 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "promptev"
7
+ version = "0.0.1"
8
+ description = "Promptev SDK for accessing Promptev API"
9
+ readme = "README.md"
10
+ license = { file = "LICENSE" }
11
+ authors = [
12
+ { name = "Promptev Inc", email = "support@promptev.ai" }
13
+ ]
14
+ "keywords" = [
15
+ "Promptev",
16
+ "promptev",
17
+ "prompts",
18
+ "api",
19
+ "client",
20
+ "sdk",
21
+ "ai",
22
+ "promptDev",
23
+ "promptdev",
24
+ "promptops",
25
+ "python"
26
+ ]
27
+ requires-python = ">=3.7"
28
+
29
+ dependencies = [
30
+ "httpx",
31
+ ]
32
+
33
+ [project.optional-dependencies]
34
+ cache = ["cachetools>=5.3.0"]
35
+
36
+ [project.urls]
37
+ Homepage = "https://promptev.ai"
38
+
39
+ [tool.setuptools]
40
+ package-dir = {"" = "src"}
41
+
42
+ [tool.setuptools.packages.find]
43
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1 @@
1
+ from .client import PromptevClient
@@ -0,0 +1,111 @@
1
+ from typing import Dict, Optional, List
2
+ from dataclasses import dataclass
3
+ import threading
4
+ import time
5
+ import httpx
6
+
7
+ try:
8
+ from cachetools import TTLCache
9
+ except ImportError:
10
+ TTLCache = None
11
+
12
+
13
+ @dataclass
14
+ class Prompt:
15
+ prompt: str
16
+ variables: List[str]
17
+
18
+ def format(self, values: Optional[Dict[str, str]] = None) -> str:
19
+ formatted = self.prompt
20
+ if values is None:
21
+ values = {}
22
+
23
+ required = self.variables or []
24
+ if not required:
25
+ return formatted
26
+
27
+ missing = [v for v in required if v not in values]
28
+ if missing:
29
+ raise ValueError(f"Missing required variables: {', '.join(missing)}")
30
+
31
+ for key, val in values.items():
32
+ formatted = formatted.replace(f"{{{{{key}}}}}", str(val))
33
+
34
+ return formatted
35
+
36
+
37
+ class PromptevClient:
38
+ def __init__(
39
+ self,
40
+ project_key: str,
41
+ base_url: str = "https://api.promptev.ai",
42
+ refresh_interval: int = 30
43
+ ):
44
+ self.project_key = project_key
45
+ self.base_url = base_url.rstrip("/")
46
+ self.refresh_interval = refresh_interval
47
+ self.is_ready = False
48
+ self._stop_event = threading.Event()
49
+ self._thread: Optional[threading.Thread] = None
50
+
51
+ self.prompt_cache: Dict[str, Prompt] = {}
52
+ if TTLCache:
53
+ self.prompt_cache = TTLCache(maxsize=1000, ttl=3600)
54
+
55
+ self._start_background_refresh()
56
+ self.is_ready = True
57
+
58
+ def _start_background_refresh(self):
59
+ def _loop():
60
+ while not self._stop_event.is_set():
61
+ time.sleep(self.refresh_interval)
62
+ # Future: Add cache refresh logic
63
+ self._thread = threading.Thread(target=_loop, daemon=True)
64
+ self._thread.start()
65
+
66
+ def dispose(self):
67
+ self._stop_event.set()
68
+ if self._thread:
69
+ self._thread.join()
70
+ if hasattr(self.prompt_cache, "clear"):
71
+ self.prompt_cache.clear()
72
+
73
+ def _fetch_prompt_sync(self, prompt_key: str) -> Prompt:
74
+ url = f"{self.base_url}/api/sdk/v1/prompt/client/{self.project_key}/{prompt_key}"
75
+ with httpx.Client() as client:
76
+ response = client.get(url)
77
+ response.raise_for_status()
78
+ data = response.json()
79
+
80
+ variables = data.get("variables", [])
81
+ if isinstance(variables, str):
82
+ variables = [v.strip() for v in variables.split(",") if v.strip()]
83
+ return Prompt(prompt=data["prompt"], variables=variables)
84
+
85
+ def get_prompt(self, prompt_key: str, values: Optional[Dict[str, str]] = None) -> str:
86
+ if prompt_key in self.prompt_cache:
87
+ prompt = self.prompt_cache[prompt_key]
88
+ return prompt.format(values) if prompt.variables else prompt.prompt
89
+
90
+ prompt = self._fetch_prompt_sync(prompt_key)
91
+ self.prompt_cache[prompt_key] = prompt
92
+ return prompt.format(values) if prompt.variables else prompt.prompt
93
+
94
+ async def aget_prompt(self, prompt_key: str, values: Optional[Dict[str, str]] = None) -> str:
95
+ if prompt_key in self.prompt_cache:
96
+ prompt = self.prompt_cache[prompt_key]
97
+ return prompt.format(values) if prompt.variables else prompt.prompt
98
+
99
+ url = f"{self.base_url}/api/sdk/v1/prompt/client/{self.project_key}/{prompt_key}"
100
+ async with httpx.AsyncClient() as client:
101
+ response = await client.get(url)
102
+ response.raise_for_status()
103
+ data = response.json()
104
+
105
+ variables = data.get("variables", [])
106
+ if isinstance(variables, str):
107
+ variables = [v.strip() for v in variables.split(",") if v.strip()]
108
+ prompt = Prompt(prompt=data["prompt"], variables=variables)
109
+ self.prompt_cache[prompt_key] = prompt
110
+ return prompt.format(values) if prompt.variables else prompt.prompt
111
+
@@ -0,0 +1,186 @@
1
+ Metadata-Version: 2.4
2
+ Name: promptev
3
+ Version: 0.0.1
4
+ Summary: Promptev SDK for accessing Promptev API
5
+ Author-email: Promptev Inc <support@promptev.ai>
6
+ License: Promptev SDK License
7
+
8
+ Copyright © 2025 Promptev Inc.
9
+
10
+ This software is proprietary and protected under applicable copyright laws.
11
+ By using this software, you agree to the following:
12
+
13
+ 1. You may use this SDK:
14
+ - Free of charge on the Free Tier of Promptev services
15
+ - For evaluation or development purposes
16
+ - In production only with an active Promptev subscription
17
+
18
+ 2. Restrictions:
19
+ - You may NOT sublicense, distribute, or reverse-engineer this software
20
+ - You may NOT modify or resell this SDK or derivative works
21
+ - You may NOT use this SDK outside the Promptev API without a license
22
+
23
+ 3. The SDK is provided “AS IS” without warranties. Promptev Inc. shall not be held liable for any damages.
24
+
25
+ By using this software, you accept these terms. For licensing inquiries or enterprise use, contact support@promptev.ai.
26
+
27
+ Project-URL: Homepage, https://promptev.ai
28
+ Keywords: Promptev,promptev,prompts,api,client,sdk,ai,promptDev,promptdev,promptops,python
29
+ Requires-Python: >=3.7
30
+ Description-Content-Type: text/markdown
31
+ License-File: LICENSE
32
+ Requires-Dist: httpx
33
+ Provides-Extra: cache
34
+ Requires-Dist: cachetools>=5.3.0; extra == "cache"
35
+ Dynamic: license-file
36
+
37
+ # promptev-client
38
+
39
+ A lightweight Python SDK to securely fetch and format prompts from [Promptev.ai](https://promptev.ai) using your project API key.
40
+
41
+ ---
42
+
43
+ ## Installation
44
+
45
+ ```bash
46
+ pip install promptev
47
+ ```
48
+
49
+ > Optional (recommended for production caching and background refresh):
50
+ ```bash
51
+ pip install cachetools
52
+ ```
53
+
54
+ ---
55
+
56
+ ## What is Promptev?
57
+
58
+ [Promptev](https://promptev.ai) helps teams manage, version, and collaborate on AI prompts at scale — with variables, live context packs, histories, cost estimation, and SDK access.
59
+
60
+ ---
61
+
62
+ ## Usage
63
+
64
+ ### 1. Initialize the client
65
+
66
+ ```python
67
+ from promptev import PromptevClient
68
+
69
+ client = PromptevClient(project_key="pv_sk_abc123yourkey")
70
+ ```
71
+
72
+ ---
73
+
74
+ ### 2. Fetch a prompt with variables
75
+
76
+ ```python
77
+ output = client.get_prompt("onboarding-email", {
78
+ "name": "Ava",
79
+ "product": "Promptev"
80
+ })
81
+
82
+ print(output)
83
+ # Output: "Subject: Welcome, Ava! Hey Ava, Thanks for joining Promptev..."
84
+ ```
85
+
86
+ ---
87
+
88
+ ### 3. Fetch a prompt without variables
89
+
90
+ ```python
91
+ output = client.get_prompt("static-welcome")
92
+ print(output)
93
+ # Output: "You are a helpful AI assistant ready to support the user."
94
+ ```
95
+
96
+ > ⚠️ If the prompt has no variables, you can omit the second argument.
97
+
98
+ ---
99
+
100
+ ### 4. Async Usage (e.g. in FastAPI or notebooks)
101
+
102
+ ```python
103
+ import asyncio
104
+
105
+ async def run():
106
+ prompt = await client.aget_prompt("faq-response", {
107
+ "question": "How do I reset my password?"
108
+ })
109
+ print(prompt)
110
+
111
+ asyncio.run(run())
112
+ ```
113
+
114
+ ---
115
+
116
+ ## Example: Use with LLM APIs
117
+
118
+ ### OpenAI
119
+
120
+ ```python
121
+ from openai import OpenAI
122
+
123
+ client = OpenAI(api_key="sk-...")
124
+
125
+ prompt = promptev_client.get_prompt("explain-topic", {
126
+ "topic": "Prompt Engineering"
127
+ })
128
+
129
+ response = client.chat.completions.create(
130
+ model="gpt-4",
131
+ messages=[{"role": "user", "content": prompt}]
132
+ )
133
+
134
+ print(response.choices[0].message.content)
135
+ ```
136
+
137
+ ---
138
+
139
+ ## Features
140
+
141
+ - ✅ Supports prompts with or without variables
142
+ - 🔁 Smart caching (via `dict` or `TTLCache`)
143
+ - 🧠 Built-in variable formatting & validation
144
+ - ⚡ Sync + Async compatible
145
+ - 🔐 Works with any LLM (OpenAI, Claude, Gemini, etc.)
146
+ - 🔌 BYOK + airgapped environment ready
147
+
148
+ ---
149
+
150
+ ## Error Handling
151
+
152
+ ```python
153
+ # ❌ Missing required variable
154
+ client.get_prompt("onboarding-email", { "name": "Leo" })
155
+ # ➜ ValueError: Missing required variables: product
156
+ ```
157
+
158
+ ---
159
+
160
+ ## Prompt Template Example
161
+
162
+ ```text
163
+ Subject: Welcome, {{ name }}!
164
+
165
+ Hey {{ name }},
166
+
167
+ Thanks for joining {{ product }}. We're thrilled to have you on board!
168
+ ```
169
+
170
+ ---
171
+
172
+ ## License
173
+
174
+ This SDK is **commercial software** by Promptev Inc.
175
+
176
+ By using this package, you agree to the terms in [`LICENSE.txt`](./LICENSE.txt).
177
+
178
+ - ✅ Free tier use allowed
179
+ - 🚫 Production usage requires a subscription
180
+
181
+ ---
182
+
183
+ ## Contact
184
+
185
+ - 🌐 [https://promptev.ai](https://promptev.ai)
186
+ - 📧 support@promptev.ai
@@ -0,0 +1,11 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/promptev/__init__.py
5
+ src/promptev/client.py
6
+ src/promptev.egg-info/PKG-INFO
7
+ src/promptev.egg-info/SOURCES.txt
8
+ src/promptev.egg-info/dependency_links.txt
9
+ src/promptev.egg-info/requires.txt
10
+ src/promptev.egg-info/top_level.txt
11
+ test/test_promptev.py
@@ -0,0 +1,4 @@
1
+ httpx
2
+
3
+ [cache]
4
+ cachetools>=5.3.0
@@ -0,0 +1 @@
1
+ promptev
@@ -0,0 +1,17 @@
1
+ from promptev import PromptevClient
2
+
3
+ client = PromptevClient(
4
+ project_key="pl_sk_bkcAkOf4pS_zdCrOeSmz8msunT4IOj_6", # Replace with your real or test key
5
+ base_url="http://localhost:8003", # Pointing to your local server
6
+ refresh_interval=10 # Optional: faster refresh during test
7
+ )
8
+
9
+ # Test a prompt without variables
10
+ # output = client.get_prompt("test-static-prompt")
11
+ # print("Static prompt:", output)
12
+
13
+ # Test a prompt with variables
14
+ output = client.get_prompt("review-user-prompt", {
15
+ "user_prompt_text": "How to improve LLM reasoning?"
16
+ })
17
+ print("Formatted prompt:", output)