CoolFace
Apppublic

singhhhhh30/digital_library

sourceHugging Faceupdated 3y agoView on Hugging Face
0likes
app.py21 linesDownload Raw Back to root
1import openai2import gradio3 4openai.api_key = "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"5 6messages = [{"role": "system", "content": "You are a librarian which suggests books for a course."}]7 8def CustomChatGPT(user_input):9    messages.append({"role": "user", "content": user_input})10    response = openai.ChatCompletion.create(11        model = "gpt-3.5-turbo",12        messages = messages13    )14    ChatGPT_reply = response["choices"][0]["message"]["content"]15    messages.append({"role": "assistant", "content": ChatGPT_reply})16    return ChatGPT_reply17 18demo = gradio.Interface(fn=CustomChatGPT, inputs = "text", outputs = "text", title = "Study Resource Advisor")19 20demo.launch()21