darshit0503 commited on
Commit
37219a0
·
1 Parent(s): 3b72bfb

Application File

Browse files
Files changed (1) hide show
  1. app.py +60 -0
app.py ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import requests
3
+ import json
4
+
5
+
6
+
7
+ st.set_page_config(page_title="Generate Therapy Answers🤖",
8
+ page_icon='🤖',
9
+ layout='centered',
10
+ initial_sidebar_state='collapsed')
11
+
12
+
13
+ ## Function To get response from LLAma 2 model
14
+
15
+ # def getLLamaresponse(input_text):
16
+
17
+ # ### LLama2 model
18
+ # llm=CTransformers(model='models/openorca_7b_chat_uncensored_FT_GGUF.gguf',
19
+ # model_type='llama',
20
+ # config={'max_new_tokens':256,
21
+ # 'temperature':0.01,
22
+ # 'gpu_layers':25,
23
+ # })
24
+ # ## Prompt Template
25
+
26
+
27
+ url = "http://localhost:11434/api/generate"
28
+
29
+ headers = {
30
+ 'Content-Type': 'application/json',
31
+ }
32
+
33
+
34
+ def generate_text():
35
+ # prompt = f"Please generate a draft for a legal notice in detail. The notice is to be sent on behalf of {client_name}, located at {client_address}, to {recipient_name} regarding {reason_for_notice}. The notice should include a clear statement of the issue, a request for resolution or action, a deadline for response or action, and any legal consequences of non-compliance. Please use formal language and ensure the notice is legally sound.\n\nCrime Type: include any IPC that applies to this perticular case"
36
+ prompt = f"PRovide Response on the below text \n\n{input_text}"
37
+
38
+
39
+ data = {
40
+ "model": "openorca_FT_medical",
41
+ "stream": False,
42
+ "prompt": prompt,
43
+ }
44
+ response = requests.post(url, headers=headers, data=json.dumps(data))
45
+
46
+ if response.status_code == 200:
47
+ response_text = response.text
48
+ data = json.loads(response_text)
49
+ actual_response = data["response"]
50
+ return actual_response
51
+ else:
52
+ st.error(f"Error: {response.status_code}, {response.text}")
53
+
54
+
55
+ st.header("Therapy Provider 🤖")
56
+ input_text=st.text_area("Enter your Problem/Emotions")
57
+
58
+ if st.button("Generate Response"):
59
+ generated_notice = generate_text()
60
+ st.text_area("Generated Legal Notice", generated_notice)