No project description provided
Project description
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()}")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file underlying_prompts-0.1.1-py2.py3-none-any.whl
.
File metadata
- Download URL: underlying_prompts-0.1.1-py2.py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 2, Python 3
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 534e25bc89118dca0ad03b2efe558b1c0bbf2060061890e5a5eddb4a7a3d73cf |
|
MD5 | 598f6e9445c9afe740aefe8a55c44e5b |
|
BLAKE2b-256 | 6439cdedc3cf28606a0e28277c23e14351a1f09d977f4c57ddc9694829611fea |