Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
!pip install -q gradio
|
2 |
+
!pip install -q openai
|
3 |
+
!pip install -q transformers
|
4 |
+
import gradio
|
5 |
+
from transformers import pipeline
|
6 |
+
|
7 |
+
import openai
|
8 |
+
import gradio
|
9 |
+
|
10 |
+
openai.api_key = "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"
|
11 |
+
|
12 |
+
messages = [{"role": "system", "content": "You are a Indian Lawyer and Gave Advice according to Indian constitution"}]
|
13 |
+
|
14 |
+
def CustomChatGPT(user_input):
|
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["choices"][0]["message"]["content"]
|
21 |
+
messages.append({"role": "assistant", "content": ChatGPT_reply})
|
22 |
+
return ChatGPT_reply
|
23 |
+
|
24 |
+
demo = gradio.Interface(fn=CustomChatGPT, inputs = "text", outputs = "text", title = "AI Chat Bot for Legal Assistance")
|
25 |
+
|
26 |
+
demo.launch(share=True)
|