FeedbackGPT
FeedbackGPT is a simple-to-use mechanism for improving LLM responses based on human feedback. Currently, this library wraps LLMs provided by OpenAI and exposes a chat interface that is almost identical in usage to those provided by OpenAI.
Documentation
Coming soon!
Getting Started
Installation
pip install feedbackgpt
Example Usage
Run Locally
This example stores and retrieves feedback locally. It is for demo/prototyping purposes and any provided feedback will be deleted between runs.
from feedbackgpt import FeedbackGPT
# Insert your own OpenAI Key
OPEN_AI_KEY="YOUR_OPEN_AI_KEY"
# Initialize FeedbackGPT
feedback_gpt = FeedbackGPT(OPEN_AI_KEY)
# Example message that is sent to LLM
messages = [
{
"role": "user",
"content": "17077 is a prime number"
}
]
# Before feedback is added, the model responds incorrectly
response = feedback_gpt.chat(messages, temperature=0)
response_message = response.choices[0].message.content
print(response_message)
# Outputs:
# No, 17077 is not a prime number. It can be divided evenly by 7 and 2441.
# Provide feedback on how FeedbackGPT can better respond next time
feedback = "The correct answer is 17077 IS a prime number. It is NOT divisible by either 7 or 2441."
feedback_gpt.feedback(messages, response_message, feedback)
# After feedback is added, the FeedbackGPT responds to the message correctly
response = feedback_gpt.chat(messages, temperature=0)
response_message = response.choices[0].message.content
print(response_message)
# Outputs:
# Yes, 17077 is a prime number.
Run Persistent Feedback Memory
FeedbackGPT integrates with Pinecone in order to store feedback that persists across sessions. In order to leverage persistent feedback, you'll first need to create a Pinecone account and retrieve your API Key and environment. You can then initialize FeedbackGPT as follows:
from feedbackgpt import FeedbackGPT
# Insert your own OpenAI Key
OPEN_AI_KEY="YOUR_OPEN_AI_KEY"
# Specify Pinecone API Key and Environment
pinecone_options = {
"pineone_key": "YOUR_PINECONE_API_KEY",
"pinecone_environment": "YOUR_PINECONE_ENVIRONMENT"
}
# Initialize FeedbackGPT with Pinecone Options
feedback_gpt = FeedbackGPT(OPEN_AI_KEY, pinecone_options=pinecone_options)
# Example message that is sent to LLM
messages = [
{
"role": "user",
"content": "17077 is a prime number"
}
]
# Before feedback is added, the model responds incorrectly
response = feedback_gpt.chat(messages, temperature=0)
response_message = response.choices[0].message.content
print(response_message)
# Outputs:
# No, 17077 is not a prime number. It can be divided evenly by 7 and 2441.
# Provide feedback on how FeedbackGPT can better respond next time
feedback = "The correct answer is 17077 IS a prime number. It is NOT divisible by either 7 or 2441."
feedback_gpt.feedback(messages, response_message, feedback)
# After feedback is added, the FeedbackGPT responds to the message correctly
# NOTE: The pincone index may take a few seconds to update. So, feedback may not be immediately reflected.
response = feedback_gpt.chat(messages, temperature=0)
response_message = response.choices[0].message.content
print(response_message)
# Outputs:
# Yes, 17077 is a prime number.
Metadata
Release files for feedbackgpt 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| feedbackgpt-0.0.2.tar.gz | 5.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| feedbackgpt-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.0 kB
Release files / feedbackgpt-0.0.2.tar.gz
| Download URL | feedbackgpt-0.0.2.tar.gz |
|---|---|
| Size | 5.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1970ee0052726ad86f89edcda3f9c5f0b9a6162da2dd6c0386656c06fa26efcf
|
|
BLAKE2b-256 checksum How to use checksums |
437131569623cead38103d5156318a394ff270c81b52c76f55f0ff8efe165ee6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.3
|
Release files / feedbackgpt-0.0.2-py3-none-any.whl
| Download URL | feedbackgpt-0.0.2-py3-none-any.whl |
|---|---|
| Size | 6.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
66c0dd2fae363b69e83c28f2b322e01a20a37aeee62731e82271641865956a25
|
|
BLAKE2b-256 checksum How to use checksums |
d96a4ce0c7a0efebc9616b76ca29a1fad0c364137475d77460445699256b24f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.3
|