forked from phoenix/litellm-mirror
cleanup
This commit is contained in:
parent
6e05fca714
commit
a4ca26a189
2 changed files with 9 additions and 23 deletions
|
@ -672,29 +672,22 @@ def completion(
|
||||||
litellm.openai_key or
|
litellm.openai_key or
|
||||||
get_secret("DEEPINFRA_API_KEY")
|
get_secret("DEEPINFRA_API_KEY")
|
||||||
)
|
)
|
||||||
openai.api_base = "https://api.deepinfra.com/v1/openai"
|
|
||||||
## LOGGING
|
## LOGGING
|
||||||
logging.pre_call(
|
logging.pre_call(
|
||||||
input=messages,
|
input=messages,
|
||||||
api_key=api_key,
|
api_key=api_key,
|
||||||
)
|
)
|
||||||
## COMPLETION CALL
|
## COMPLETION CALL
|
||||||
openai.api_key = "1LntUh4fmg5z6iEW7UPPRhGdBDNuJx5y"
|
openai.api_key = api_key # set key for deep infra
|
||||||
openai.api_base = "https://api.deepinfra.com/v1/openai"
|
|
||||||
try:
|
try:
|
||||||
chat_completion = openai.ChatCompletion.create(
|
response = openai.ChatCompletion.create(
|
||||||
model="meta-llama/Llama-2-70b-chat-hf",
|
model=model,
|
||||||
messages=[{"role": "user", "content": "Hello world"}]
|
messages=messages,
|
||||||
|
api_base="https://api.deepinfra.com/v1/openai", # use the deepinfra api base
|
||||||
|
api_type="openai",
|
||||||
|
api_version=api_version, # default None
|
||||||
|
**optional_params,
|
||||||
)
|
)
|
||||||
print(f"chat_completion: {chat_completion}")
|
|
||||||
# response = openai.ChatCompletion.create(
|
|
||||||
# model=model,
|
|
||||||
# messages=messages,
|
|
||||||
# api_base="https://api.deepinfra.com/v1/openai", # use the deepinfra api base
|
|
||||||
# api_type="openai",
|
|
||||||
# api_version=api_version, # default None
|
|
||||||
# **optional_params,
|
|
||||||
# )
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
## LOGGING - log the original exception returned
|
## LOGGING - log the original exception returned
|
||||||
logging.post_call(
|
logging.post_call(
|
||||||
|
|
|
@ -52,11 +52,4 @@ def test_completion_with_no_provider():
|
||||||
# except:
|
# except:
|
||||||
# print(f"error occurred: {traceback.format_exc()}")
|
# print(f"error occurred: {traceback.format_exc()}")
|
||||||
# pass
|
# pass
|
||||||
# os.environ["OPENAI_API_KEY"] = str(temp_key) # this passes linting#5
|
# os.environ["OPENAI_API_KEY"] = str(temp_key) # this passes linting#5
|
||||||
|
|
||||||
def logger_fn(model_details):
|
|
||||||
print(model_details)
|
|
||||||
os.environ['OPENAI_API_KEY'] = "1LntUh4fmg5z6iEW7UPPRhGdBDNuJx5y"
|
|
||||||
messages = [{"role":"user","content":"Request boss to grant me 1 day leave"}]
|
|
||||||
litellm.api_base = "https://api.deepinfra.com/v1/"
|
|
||||||
response = litellm.completion(model="meta-llama/Llama-2-70b-chat-hf", messages=messages, custom_llm_provider="openai", logger_fn=logger_fn)
|
|
Loading…
Add table
Add a link
Reference in a new issue