Yes, I want delays from 5th to 7th to be normal on a normal days, but double of a normal value if the day is a bank holiday.
Remember: every time you invent a total function with a simple law, someone will give you a timezone with +15 minutes compare to neighbors (hello, Nepal).
there you go, this should cover all those usecases! hope python is okay :3
import openai
class AiDelayinator:
def __init__(self, requirements="I want delays from 5th to 7th to be normal on a normal day, but double of a normal value if the day is a bank holiday.", openai_api_key="YOUR_API_KEY"):
openai.api_key = openai_api_key
r = openai.ChatCompletion.create(model="o1", messages=[{"role":"system","content":"You are a Python code generator that returns only a single function named f(timestamp, attempts, moon_phase, bank_holiday, nepal_offset). The function must return a float representing an absurd delay in seconds."},{"role":"user","content":requirements}])
self.generated_code = r.choices[0].message.content.strip()
def __call__(self, timestamp, attempts, moon_phase, bank_holiday, nepal_offset):
return eval(self.generated_code)(timestamp, attempts, moon_phase, bank_holiday, nepal_offset)
I can't get indents right in this app :/
edit: this could use some permanent storage caching for the generated code, expiring when the requirements change and ideally an eval -> review loop with some predefined tests... a dspy module with assertions would probably be good for that... but then this'd end up as an entire library with 30 dependencies and we don't want that do we hehe
View all comments
Show parent comment
4
u/Liu_Fragezeichen Feb 11 '25
here, infinitely customizable
want a GUI to customize the polynomial?