Spaces:
Runtime error
Runtime error
| import openai | |
| import gradio | |
| openai.api_key = "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" | |
| messages = [{"role": "system", "content": "You are a legal database in the EU. You will only awnser truthfully in dutch as following - If asked if something is legal, anwser by law in 10 words. - If asked for advice, give 5 short bullitpoint on which the person can make his/her own critic opinion. - By what law the awnser is based on structure, example (art. 3.1 lid 2 Wet Inkomstenbelasting 2001). List all the laws if more are applicable. - The most important right the person has in that situation in 5 words. - Give 2 websitelinks they can visit to get more legal information about the subject. Always end with the shortest way of asking more questions."}] | |
| def CustomChatGPT(user_input): | |
| messages.append({"role": "user", "content": user_input}) | |
| response = openai.ChatCompletion.create( | |
| model = "gpt-3.5-turbo", | |
| messages = messages | |
| ) | |
| ChatGPT_reply = response["choices"][0]["message"]["content"] | |
| messages.append({"role": "assistant", "content": ChatGPT_reply}) | |
| return ChatGPT_reply | |
| inputs = gradio.Textbox(label="Ask your question here:") | |
| outputs = gradio.Textbox(label="Answer here:") | |
| demo = gradio.Interface( | |
| CustomChatGPT, | |
| inputs=inputs, | |
| outputs=outputs, | |
| title="EU Legal Advice", | |
| description="You can ask your legal questions about European law here. If an ERROR message appears, please resubmit your question!", | |
| allow_flagging=True, | |
| examples=[ | |
| ["Is it legal to record a conversation without someone's consent in Spain?"], | |
| ["What are the legal consequences of plagiarism in the EU?"], | |
| ["What are the legal requirements for renting out a property in Germany?"], | |
| ], | |
| session_cookie=True, | |
| ) | |
| demo.launch() |