code cleanup

This commit is contained in:
Krrish Dholakia 2023-08-01 12:24:21 -07:00
parent 7b2901be9e
commit 2d75db70ad

View file

@ -1,6 +1,5 @@
import os, openai, cohere, replicate, sys import os, openai, cohere, replicate, sys
from typing import Any from typing import Any
from func_timeout import func_set_timeout, FunctionTimedOut
from anthropic import Anthropic, HUMAN_PROMPT, AI_PROMPT from anthropic import Anthropic, HUMAN_PROMPT, AI_PROMPT
import traceback import traceback
import dotenv import dotenv
@ -58,7 +57,7 @@ def get_optional_params(
####### COMPLETION ENDPOINTS ################ ####### COMPLETION ENDPOINTS ################
############################################# #############################################
@client @client
@timeout(60) ## set timeouts, in case calls hang (e.g. Azure) @timeout(60) ## set timeouts, in case calls hang (e.g. Azure) - default is 60s, override with `force_timeout`
def completion( def completion(
model, messages, # required params model, messages, # required params
# Optional OpenAI params: see https://platform.openai.com/docs/api-reference/chat/create # Optional OpenAI params: see https://platform.openai.com/docs/api-reference/chat/create
@ -253,8 +252,8 @@ def completion(
### EMBEDDING ENDPOINTS #################### ### EMBEDDING ENDPOINTS ####################
@client @client
@func_set_timeout(60, allowOverride=True) ## https://pypi.org/project/func-timeout/ @timeout(60) ## set timeouts, in case calls hang (e.g. Azure) - default is 60s, override with `force_timeout`
def embedding(model, input=[], azure=False, forceTimeout=60, logger_fn=None): def embedding(model, input=[], azure=False, force_timeout=60, logger_fn=None):
response = None response = None
if azure == True: if azure == True:
# azure configs # azure configs