Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,29 +3,33 @@ import gradio
|
|
| 3 |
|
| 4 |
openai.api_key = "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"
|
| 5 |
|
| 6 |
-
messages = [{"role": "system", "content": "You are a legal database in the
|
| 7 |
-
|
| 8 |
-
has_asked_question = False
|
| 9 |
|
| 10 |
def CustomChatGPT(user_input):
|
| 11 |
-
global has_asked_question
|
| 12 |
-
if has_asked_question:
|
| 13 |
-
return "Please make an account to ask more."
|
| 14 |
-
has_asked_question = True
|
| 15 |
messages.append({"role": "user", "content": user_input})
|
| 16 |
response = openai.ChatCompletion.create(
|
| 17 |
model = "gpt-3.5-turbo",
|
| 18 |
messages = messages
|
| 19 |
)
|
| 20 |
-
ChatGPT_reply = response
|
| 21 |
messages.append({"role": "assistant", "content": ChatGPT_reply})
|
| 22 |
return ChatGPT_reply
|
| 23 |
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
outputs = "text",
|
| 27 |
-
title = "IkWeetWET",
|
| 28 |
-
examples = [["Mag ik wild plassen?"], ["Vanaf welke leeftijd is ID verplicht?"], ["Ik heb een boete gekregen voor geluidsoverlast, hoe weet ik of het terecht is?"]],
|
| 29 |
-
)
|
| 30 |
|
| 31 |
-
demo.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
openai.api_key = "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"
|
| 5 |
|
| 6 |
+
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."}]
|
|
|
|
|
|
|
| 7 |
|
| 8 |
def CustomChatGPT(user_input):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
messages.append({"role": "user", "content": user_input})
|
| 10 |
response = openai.ChatCompletion.create(
|
| 11 |
model = "gpt-3.5-turbo",
|
| 12 |
messages = messages
|
| 13 |
)
|
| 14 |
+
ChatGPT_reply = response["choices"][0]["message"]["content"]
|
| 15 |
messages.append({"role": "assistant", "content": ChatGPT_reply})
|
| 16 |
return ChatGPT_reply
|
| 17 |
|
| 18 |
+
inputs = gradio.Textbox(label="Ask your question here:")
|
| 19 |
+
outputs = gradio.Textbox(label="Answer here:")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
+
demo = gradio.Interface(
|
| 22 |
+
CustomChatGPT,
|
| 23 |
+
inputs=inputs,
|
| 24 |
+
outputs=outputs,
|
| 25 |
+
title="EU Legal Advice",
|
| 26 |
+
description="You can ask your legal questions about European law here. If an ERROR message appears, please resubmit your question!",
|
| 27 |
+
allow_flagging=True,
|
| 28 |
+
examples=[
|
| 29 |
+
["Is it legal to record a conversation without someone's consent?"],
|
| 30 |
+
["What are the legal consequences of plagiarism?"],
|
| 31 |
+
["What are the legal requirements for renting out a property?"],
|
| 32 |
+
],
|
| 33 |
+
session_cookie=True,
|
| 34 |
+
)
|
| 35 |
+
demo.launch()
|