Skip to main content

A GPT wrapper that learns from user feedback

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

feedbackgpt-0.0.2.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

feedbackgpt-0.0.2-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file feedbackgpt-0.0.2.tar.gz.

File metadata

  • Download URL: feedbackgpt-0.0.2.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for feedbackgpt-0.0.2.tar.gz
Algorithm Hash digest
SHA256 1970ee0052726ad86f89edcda3f9c5f0b9a6162da2dd6c0386656c06fa26efcf
MD5 85553e1f59326e5f899ffddbc48f19bd
BLAKE2b-256 437131569623cead38103d5156318a394ff270c81b52c76f55f0ff8efe165ee6

See more details on using hashes here.

File details

Details for the file feedbackgpt-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: feedbackgpt-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for feedbackgpt-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 66c0dd2fae363b69e83c28f2b322e01a20a37aeee62731e82271641865956a25
MD5 55b41e636c075c927f674d13ebac8e5c
BLAKE2b-256 d96a4ce0c7a0efebc9616b76ca29a1fad0c364137475d77460445699256b24f2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page