fix: 添加容错代码
Some checks failed
Python application test / build (pull_request) Failing after 12m17s
Some checks failed
Python application test / build (pull_request) Failing after 12m17s
This commit is contained in:
@@ -5,7 +5,10 @@ import openai
|
||||
|
||||
|
||||
def detectGPT(content: str):
|
||||
client = openai.OpenAI(api_key=os.environ.get("OPENAI_API_KEY"))
|
||||
api_key = os.getenv("OPENAI_API_KEY")
|
||||
if api_key is None:
|
||||
raise ValueError("env OPENAI_API_KEY no set")
|
||||
client = openai.OpenAI(api_key=api_key)
|
||||
text = content
|
||||
# client = openai.OpenAI(api_key="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") #测试用key
|
||||
response = client.chat.completions.create(
|
||||
|
||||
Reference in New Issue
Block a user