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 Netherlands. 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="Stel hier uw vraag:") | |
| outputs = gradio.Textbox(label="Antwoord hier:") | |
| demo = gradio.Interface( | |
| CustomChatGPT, | |
| inputs=inputs, | |
| outputs=outputs, | |
| title="Nederlands juridisch advies", | |
| description="U kunt hier uw vragen stellen over Nederlands recht. Mocht er een ERROR-melding komen, dien dan uw vraag opnieuw in!", | |
| allow_flagging=True, | |
| examples=[ | |
| ["Is het verboden om te wildplassen?"], | |
| ["Ik ga scheiden. Hoe wordt de verdeling van het gezag over de kinderen geregeld?"], | |
| ["Kan ik een verkeersboete aanvechten als ik de overtreding niet heb begaan?"], | |
| ], | |
| session_cookie=True, | |
| ) | |
| demo.launch() |