prompt-caller 0.0.1__py3-none-any.whl → 0.0.2__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.
@@ -0,0 +1,122 @@
1
+ Metadata-Version: 2.1
2
+ Name: prompt_caller
3
+ Version: 0.0.2
4
+ Summary: This package is responsible for calling prompts in a specific format. It uses LangChain and OpenAI API
5
+ Author: Thiago Nepomuceno
6
+ Author-email: thiago@neps.academy
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Operating System :: OS Independent
10
+ Description-Content-Type: text/markdown
11
+ Requires-Dist: pyyaml>=6.0.2
12
+ Requires-Dist: python-dotenv>=1.0.1
13
+ Requires-Dist: Jinja2>=3.1.4
14
+ Requires-Dist: langchain-openai>=0.1.23
15
+
16
+ # PromptCaller
17
+
18
+ **PromptCaller** is a Python package for calling prompts in a specific format, using LangChain and the OpenAI API. It enables users to load prompts from a template, render them with contextual data, and make structured requests to the OpenAI API.
19
+
20
+ ## Features
21
+
22
+ - **Load prompts** from a `.prompt` file containing a YAML configuration and a message template.
23
+ - **Render templates** using context and Jinja2.
24
+ - **Parse prompt messages** written in a JSX-like format (`<system>`, `<user>`, `<assistant>`).
25
+ - **Invoke prompts** using LangChain and OpenAI API, with support for structured output.
26
+ - **Dynamically create Pydantic models** based on the expected structured output.
27
+
28
+ ## Installation
29
+
30
+ To install the package, simply run:
31
+
32
+ ```bash
33
+ pip install prompt-caller
34
+ ```
35
+
36
+ You will also need an `.env` file that contains your OpenAI API key:
37
+
38
+ ```
39
+ OPENAI_API_KEY=your_openai_api_key_here
40
+ ```
41
+
42
+ ## Usage
43
+
44
+ 1. **Define a prompt file:**
45
+
46
+ Create a `.prompt` file in the `prompts` directory, e.g., `prompts/sample.prompt`:
47
+
48
+ ```yaml
49
+ ---
50
+ model: gpt-4o-mini
51
+ temperature: 0.7
52
+ max_tokens: 512
53
+ output:
54
+ result: "Final result of the expression"
55
+ explanation: "Explanation of the calculation"
56
+ ---
57
+ <system>
58
+ You are a helpful assistant.
59
+ </system>
60
+
61
+ <user>
62
+ How much is {{expression}}?
63
+ </user>
64
+ ```
65
+
66
+ This `.prompt` file contains:
67
+
68
+ - A YAML header for configuring the model and parameters.
69
+ - A template body using Jinja2 to inject the context (like `{{ expression }}`).
70
+ - Messages structured in a JSX-like format (`<system>`, `<user>`).
71
+
72
+ 2. **Load and call a prompt:**
73
+
74
+ ```python
75
+ from prompt_caller import PromptCaller
76
+
77
+ ai = PromptCaller()
78
+
79
+ response = ai.call("sample", {"expression": "3+8/9"})
80
+
81
+ print(response)
82
+ ```
83
+
84
+ In this example:
85
+
86
+ - The `expression` value `3+8/9` is injected into the user message.
87
+ - The model will respond with both the result of the expression and an explanation, as specified in the `output` section of the prompt.
88
+
89
+ ## How It Works
90
+
91
+ 1. **\_loadPrompt:** Loads the prompt file, splits the YAML header from the body, and parses them.
92
+ 2. **\_renderTemplate:** Uses the Jinja2 template engine to render the body with the provided context.
93
+ 3. **\_parseJSXBody:** Parses the message body written in JSX-like tags to extract system and user messages.
94
+ 4. **call:** Invokes the OpenAI API with the parsed configuration and messages, and handles structured output via dynamic Pydantic models.
95
+
96
+ ## Build and Upload
97
+
98
+ To build the distribution and upload it to a package repository like PyPI, follow these steps:
99
+
100
+ 1. **Build the distribution:**
101
+
102
+ Run the following command to create both source (`sdist`) and wheel (`bdist_wheel`) distributions:
103
+
104
+ ```bash
105
+ python setup.py sdist bdist_wheel
106
+ ```
107
+
108
+ This will generate the distribution files in the `dist/` directory.
109
+
110
+ 2. **Upload to PyPI using Twine:**
111
+
112
+ Use `twine` to securely upload the distribution to PyPI:
113
+
114
+ ```bash
115
+ twine upload dist/*
116
+ ```
117
+
118
+ Ensure you have configured your PyPI credentials before running this command. You can find more information on configuring credentials in the [Twine documentation](https://twine.readthedocs.io/).
119
+
120
+ ## License
121
+
122
+ This project is licensed under the **Apache License 2.0**. You may use, modify, and distribute this software as long as you provide proper attribution and include the full text of the license in any distributed copies or derivative works.
@@ -1,7 +1,7 @@
1
1
  prompt_caller/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  prompt_caller/__main__.py,sha256=dJ0dYtVmnhZuoV79R6YiAIta1ZkUKb-TEX4VEuYbgk0,139
3
3
  prompt_caller/prompt_caller.py,sha256=VmmMLiOWsTC-545ejXcfOP0neA3k4aDA2SLCYNGD2nI,2824
4
- prompt_caller-0.0.1.dist-info/METADATA,sha256=B8L0iifaUnM3idkMsLV_AE455LVTE51WMFwKKnuhdCI,625
5
- prompt_caller-0.0.1.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
6
- prompt_caller-0.0.1.dist-info/top_level.txt,sha256=iihiDRq-0VrKB8IKjxf7Lrtv-fLMq4tvgM4fH3x0I94,14
7
- prompt_caller-0.0.1.dist-info/RECORD,,
4
+ prompt_caller-0.0.2.dist-info/METADATA,sha256=6uxqVskKCCs2ic4STEFERNGEjjzWPuBPHVBv1-AF5Qs,4040
5
+ prompt_caller-0.0.2.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
6
+ prompt_caller-0.0.2.dist-info/top_level.txt,sha256=iihiDRq-0VrKB8IKjxf7Lrtv-fLMq4tvgM4fH3x0I94,14
7
+ prompt_caller-0.0.2.dist-info/RECORD,,
@@ -1,21 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: prompt_caller
3
- Version: 0.0.1
4
- Summary: This package is responsible for calling prompts in a specific format. It uses LangChain and OpenAI API
5
- Author: Thiago Nepomuceno
6
- Author-email: thiago@neps.academy
7
- Classifier: Programming Language :: Python :: 3
8
- Classifier: License :: OSI Approved :: MIT License
9
- Classifier: Operating System :: OS Independent
10
- Description-Content-Type: text/markdown
11
- Requires-Dist: toml
12
-
13
- # Neps Academy AI
14
-
15
- This package is responsible for all Neps Academy features related to AI
16
-
17
- # Build and Upload
18
-
19
- python setup.py sdist bdist_wheel
20
-
21
- twine upload dist/\*