File size: 1,867 Bytes
4687e99
 
 
 
 
be114a4
4687e99
 
 
 
 
 
 
be114a4
4687e99
 
 
be114a4
 
4687e99
be114a4
 
 
 
 
 
 
 
026ca66
 
 
be114a4
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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()