from openai import OpenAI
# 创建 OpenAI 客户端
client = OpenAI(
api_key="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",
base_url="https://integrate.api.nvidia.com/v1"
)
# 预定义一组常见问题及其答案
faq = {
"What is the capital of France?": "The capital of France is Paris.",
"What is the largest ocean on Earth?": "The largest ocean is the Pacific Ocean.",
"What is the highest mountain in the world?": "The highest mountain is Mount Everest.",
"Who wrote 'Romeo and Juliet'?": "William Shakespeare wrote 'Romeo and Juliet'.",
}
print("欢迎使用问答系统!你可以询问我一些常见问题。输入 '退出' 来结束对话。")
while True:
user_input = input("请输入你的问题:")
if user_input.lower() == '退出':
print("感谢使用,再见!")
break
# 生成用户问题的嵌入表示
response = c