regraded01 commited on
Commit
f15fdf1
1 Parent(s): eb7d3d8

refactor: use config yaml

Browse files
Files changed (2) hide show
  1. app.py +8 -9
  2. config/model_config.yml +2 -0
app.py CHANGED
@@ -1,21 +1,20 @@
1
  import streamlit as st
 
2
  import requests
3
  import re
4
  from pdfParser import get_pdf_text
5
 
 
6
  try:
7
  api_key = st.secrets.hf_credentials.hf_api
8
  except:
9
  api_key = st.secrets.hf_api
10
- model_id = "meta-llama/Llama-2-70b-chat-hf"
11
- system_message = """
12
- Your role is to take PDF documents and extract their raw text into a JSON format that can be uploaded into a database.
13
- Return the JSON only.
14
- For example if you need to extract information about a report written on 2nd February 2011 with an author called Jane Mary then return this only:
15
- {'report_written_date': '02/02/2011', 'author_name': 'Jane Mary'}
16
- Another example would be a clinical exam passed by a student on the 3rd of July 2022 would return this only:
17
- {'result' : 'pass', 'date_of_exam' : '03/07/2022'}
18
- """
19
 
20
 
21
  def query(payload, model_id):
 
1
  import streamlit as st
2
+ import yaml
3
  import requests
4
  import re
5
  from pdfParser import get_pdf_text
6
 
7
+
8
  try:
9
  api_key = st.secrets.hf_credentials.hf_api
10
  except:
11
  api_key = st.secrets.hf_api
12
+
13
+ with open("config/model_config.yml", "r") as file:
14
+ model_config = yaml.safe_load(file)
15
+
16
+ system_message = model_config["system_message"]
17
+ model_id = model_config["model_id"]
 
 
 
18
 
19
 
20
  def query(payload, model_id):
config/model_config.yml ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ system_message: "Your role is to take PDF documents and extract their raw text into a JSON format that can be uploaded into a database. Return the JSON only. For example if you need to extract information about a report written on 2nd February 2011 with an author called Jane Mary then return this only: {'report_written_date': '02/02/2011', 'author_name': 'Jane Mary'} Another example would be a clinical exam passed by a student on the 3rd of July 2022 would return this only: {'result' : 'pass', 'date_of_exam' : '03/07/2022'}"
2
+ model_id: meta-llama/Llama-2-70b-chat-hf