Spaces:
Runtime error

Adxhug commited on
Commit
a453298
·
verified ·
1 Parent(s): bf579b0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +56 -18
app.py CHANGED
@@ -1,34 +1,72 @@
1
  import os
2
  import gradio
3
  from groq import Groq
4
- client = Groq(api_key="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",)
 
 
 
 
5
  def initialize_messages():
6
- return [{"role": "system",
7
- "content": '''You are a skilled criminal lawyer with a
8
- successful track record in numerous cases. Your role is to
9
- assist people by providing guidance on Indian laws and
10
- offering answers in a professional legal manner.'''}]
11
- messages_prmt = initialize_messages()
 
 
 
 
 
 
 
 
 
 
 
12
  def customLLMBot(user_input, history):
13
  global messages_prmt
14
 
15
- messages_prmt.append({"role": "user", "content": user_input})
 
 
 
 
 
16
 
17
  response = client.chat.completions.create(
18
  messages=messages_prmt,
19
  model="llama-3.3-70b-versatile",
20
  )
 
21
  print(response)
 
22
  LLM_reply = response.choices[0].message.content
23
- messages_prmt.append({"role": "assistant", "content": LLM_reply})
 
 
 
 
 
 
24
 
25
  return LLM_reply
26
- iface = gradio.ChatInterface(customLLMBot,
27
- chatbot=gradio.Chatbot(height=300),
28
- textbox=gradio.Textbox(placeholder="Ask me a question related to law"),
29
- title="Lawyer ChatBot",
30
- description="Chat bot for law assistance",
31
- theme="soft",
32
- examples=["hi","What is IPC sessions", "how to get a bail"]
33
- )
34
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
1
  import os
2
  import gradio
3
  from groq import Groq
4
+
5
+ client = Groq(
6
+ api_key="YOUR_API_KEY",
7
+ )
8
+
9
  def initialize_messages():
10
+ return [
11
+ {
12
+ "role": "system",
13
+ "content": (
14
+ "You are a skilled criminal lawyer with a "
15
+ "successful track record in numerous cases. "
16
+ "Your role is to assist people by providing "
17
+ "guidance on Indian laws and offering answers "
18
+ "in a professional legal manner."
19
+ ),
20
+ }
21
+ ]
22
+
23
+
24
+ messages_prmt = initialize_messages()
25
+
26
+
27
  def customLLMBot(user_input, history):
28
  global messages_prmt
29
 
30
+ messages_prmt.append(
31
+ {
32
+ "role": "user",
33
+ "content": user_input,
34
+ }
35
+ )
36
 
37
  response = client.chat.completions.create(
38
  messages=messages_prmt,
39
  model="llama-3.3-70b-versatile",
40
  )
41
+
42
  print(response)
43
+
44
  LLM_reply = response.choices[0].message.content
45
+
46
+ messages_prmt.append(
47
+ {
48
+ "role": "assistant",
49
+ "content": LLM_reply,
50
+ }
51
+ )
52
 
53
  return LLM_reply
54
+
55
+
56
+ iface = gradio.ChatInterface(
57
+ customLLMBot,
58
+ chatbot=gradio.Chatbot(height=300),
59
+ textbox=gradio.Textbox(
60
+ placeholder="Ask me a question related to law"
61
+ ),
62
+ title="Lawyer ChatBot",
63
+ description="Chat bot for law assistance",
64
+ theme="soft",
65
+ examples=[
66
+ "hi",
67
+ "What is IPC sections",
68
+ "how to get a bail",
69
+ ],
70
+ )
71
+
72
+ iface.launch()