from langchain.llms import OpenAI | |
def oai_key_isvalid(api_key): | |
"""Check if a given OpenAI key is valid""" | |
try: | |
llm = OpenAI(openai_api_key = api_key) | |
out = llm("This is a test") | |
print(out) | |
return True | |
except: | |
return False | |
from langchain.llms import OpenAI | |
def oai_key_isvalid(api_key): | |
"""Check if a given OpenAI key is valid""" | |
try: | |
llm = OpenAI(openai_api_key = api_key) | |
out = llm("This is a test") | |
print(out) | |
return True | |
except: | |
return False | |