AyoubChLin commited on
Commit
8a46061
1 Parent(s): 3fe2c6e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -9
app.py CHANGED
@@ -1,4 +1,3 @@
1
-
2
  import gradio as gr
3
  import os
4
  from huggingface_hub import login
@@ -26,19 +25,19 @@ def process_query(query, chat_history):
26
  if len(results)>0:
27
  # Get response from chat manager
28
  response = legal_chat.get_response(results[0]['content'], query=query)
29
- response_final = f"""{response}\n\nsource:[case_id:{results[0]['metadata']['case_id']}]"""
30
  else :
31
- response_final = "No Document match"
32
  # Update chat history
33
  chat_history.append((query, response_final))
34
  return "", chat_history
35
  except Exception as e:
36
- return "", chat_history + [(query, f"Error: {str(e)}")]
37
 
38
  # Create Gradio interface
39
- with gr.Blocks(title="Legal Chat Assistant") as demo:
40
- gr.Markdown("# Legal Chat Assistant")
41
- gr.Markdown("Ask questions about legal cases and get AI-powered responses.")
42
 
43
  chatbot = gr.Chatbot(
44
  [],
@@ -49,11 +48,11 @@ with gr.Blocks(title="Legal Chat Assistant") as demo:
49
 
50
  with gr.Row():
51
  query_input = gr.Textbox(
52
- placeholder="Enter your query here...",
53
  show_label=False,
54
  scale=4
55
  )
56
- submit_btn = gr.Button("Send", scale=1)
57
 
58
 
59
  # Set up event handlers
 
 
1
  import gradio as gr
2
  import os
3
  from huggingface_hub import login
 
25
  if len(results)>0:
26
  # Get response from chat manager
27
  response = legal_chat.get_response(results[0]['content'], query=query)
28
+ response_final = f"""{response}\n\nkilde:[case_id:{results[0]['metadata']['case_id']}]"""
29
  else :
30
+ response_final =" Det ønskede ord blev ikke fundet i nogen sager. Prøv met et andet søgeord"
31
  # Update chat history
32
  chat_history.append((query, response_final))
33
  return "", chat_history
34
  except Exception as e:
35
+ return "", chat_history + [(query, f"Det ønskede ord blev ikke fundet i nogen sager. Prøv met et andet søgeord")]
36
 
37
  # Create Gradio interface
38
+ with gr.Blocks(title="Jurai Insight") as demo:
39
+ gr.Markdown("# Jurai Insight")
40
+ gr.Markdown("Forudsig fremtiden, byg din sag data.")
41
 
42
  chatbot = gr.Chatbot(
43
  [],
 
48
 
49
  with gr.Row():
50
  query_input = gr.Textbox(
51
+ placeholder="Indtast dit spørgsmål her...",
52
  show_label=False,
53
  scale=4
54
  )
55
+ submit_btn = gr.Button("Sende", scale=1)
56
 
57
 
58
  # Set up event handlers