MCPcopy Create free account
hub / github.com/OpenBitSys/BitDistiller / oa_completion

Function oa_completion

test/general/lm_eval/models/gpt3.py:38–54  ·  view source on GitHub ↗

Query OpenAI API for completion. Retry with back-off until they respond

(**kwargs)

Source from the content-addressed store, hash-verified

36
37
38def oa_completion(**kwargs):
39 """Query OpenAI API for completion.
40
41 Retry with back-off until they respond
42 """
43 import openai
44
45 backoff_time = 3
46 while True:
47 try:
48 return openai.Completion.create(**kwargs)
49 except openai.error.OpenAIError:
50 import traceback
51
52 traceback.print_exc()
53 time.sleep(backoff_time)
54 backoff_time *= 1.5
55
56
57class GPT3LM(BaseLM):

Callers 2

_loglikelihood_tokensMethod · 0.85
greedy_untilMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected