Underlyging Prompts
The utility to inspect underlying prompts which are actually used for LLM applications.
It is helpful for prompt engineering and records all the OpenAI requests and responses without extra cost. If you want to understand the underlying generated prompts from LLM applications like langchain or openmldb-chatgpt-plugin, you can use underlyging-prompts easily.
Install
pip install underlying-prompts
Usage
Start the server.
underlying-prompts
Set the environment for clients.
export OPENAI_API_BASE=http://127.0.0.1:8888/v1
Run the demo OpenAI client.
./demo/openai_demo.py
Check out the server log or prompts history.
cat ./underlying-prompts.log
Reset
Reset the environment variable if you do not want to record prompts.
unset OPENAI_API_BASE
How It Works
It is the simple HTTP server to redirect requests from openai library. The user's requests will be fully forwards to OpenAI API server and it helps to records the underlying request data and response data.
Here is the sample code of server.py.
headers = {
"Content-Type": request.headers["Content-Type"],
"Authorization": request.headers["Authorization"]
}
json_data = request.get_json()
logger.info(f"OpenAI Request: {json_data}")
url = f"https://api.openai.com/{path}"
response = requests.post(
url,
headers=headers,
json=json_data
)
logger.info(f"OpenAI Response: {response.json()}")
Metadata
Release files for underlying-prompts 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| underlying_prompts-0.1.1-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Release files / underlying_prompts-0.1.1-py2.py3-none-any.whl
| Download URL | underlying_prompts-0.1.1-py2.py3-none-any.whl |
|---|---|
| Size | 7.3 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
534e25bc89118dca0ad03b2efe558b1c0bbf2060061890e5a5eddb4a7a3d73cf
|
|
BLAKE2b-256 checksum How to use checksums |
6439cdedc3cf28606a0e28277c23e14351a1f09d977f4c57ddc9694829611fea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.9.6 requests/2.28.2 setuptools/59.0.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
|
Security for underlying-prompts 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.