Python Integration
This code must be placed before your chat interaction code. You only need to call track_completion once.
Usage
There are two main ways to use the requestyai library, depending on whether or not you want to track the ip_address and user_url:
Basic Usage (without ip_address and user_url): For basic usage, all you need to do is call the track_completion function with your endpoint:
Advanced Usage (with ip_address and user_url): If you want to track the ip_address and user_url, you need to extract these values in your chat function (e.g., chat()) and pass them to track_completion:
This code attempts to extract the Referer and X-Forwarded-For headers from the incoming HTTP request. If these headers aren't available, it uses default values ('N/A' for user_url and the client's IP address for ip_address).
Diagram
The following diagram provides a high-level overview of how the library works:
Please note: This library is designed to work with OpenAI's Python library and it modifies the behavior of openai.Completion.create to capture data. Make sure you import and initialize chatbot_library before you use openai.Completion.create in your code.
Last updated