rozek
OpenAIChatCompletion
HTTP
Use Val.Town's Open AI access wherever you need to enter AI Provider Credentials Perhaps, you are going to build an AI application for the public with Val.Town. Personally, you may want to use the Open AI access that comes with Val.Town, but for the entirety of your users the rate limits of that access will be too low. Thus, you may want them to bring their own AI provider with their own server URL and access key. But, wait, how do you than use your own application, still using Val.Town's Open AI access? This is where this val comes in (assuming that you already have a Val.Town account, either a free or a paid one): fork this val use the fork's HTTP endpoint URL (in the form "https://XXX-openaichatcompletion.web.val.run") as AI server URL define an environment variable called "OpenAIChatCompletion" with any kind of content (but without any blanks or control characters, e.g., a UUID ) and use that as your personal access key Now, you can ask everybody to provide their AI credentials and still use the OpenAI access provided by Val.Town for your personal tests. Nota bene: if the environment variable "OpenAIChatCompletion" has not been defined, access to your fork's endpoint is free for everybody! In addition to the described authorization, this val also provides resource "throttling" (using val floatingQuotaTracker in sqlite tables "OpenAIChatCompletion_Info" and "OpenAIChatCompletion_Log") and calculates some access statistics (using val InvocationTracker in sqlite tables "OpenAIChatCompletion_Usage_Info" and "OpenAIChatCompletion_Usage_Log")
0
rozek
floatingQuotaTracker_Test
HTTP
Here are some tests for val floatingQuotaTracker Test Cases Constructor with valid inputs creates a new floatingQuotaTracker instance with valid parameters Constructor with invalid name attempts to create a tracker with an invalid name and checks for error Limit getter and setter verifies initial limit value tests setting a new limit confirms the new limit is set correctly Period getter and setter verifies initial period value tests setting a new period confirms the new period is set correctly Granularity getter and setter verifies initial granularity value tests setting a new granularity confirms the new granularity is set correctly Usage and increment checks initial usage is zero tests increment method verifies usage after increments LimitExceeded checks LimitExceeded is false initially tests LimitExceeded at the threshold verifies LimitExceeded is true when limit is exceeded incrementIfAllowed tests successful increments up to the limit verifies LimitExceeded error is thrown when limit is reached Reset functionality increments usage tests reset method verifies usage is zero after reset TimeToWait checks initial TimeToWait is zero tests TimeToWait after exceeding limit
0
Updated: January 29, 2025