DrishtiSharma
commited on
Update interim.py
Browse files- interim.py +35 -2
interim.py
CHANGED
@@ -2,7 +2,6 @@ import os
|
|
2 |
from datetime import datetime
|
3 |
import streamlit as st
|
4 |
from patentwiz import preprocess_data, qa_agent
|
5 |
-
from patentwiz.main import PROMPT
|
6 |
|
7 |
# Check if the API key is loaded
|
8 |
api_key = os.getenv("OPENAI_API_KEY")
|
@@ -10,6 +9,40 @@ if not api_key:
|
|
10 |
st.error("OPENAI_API_KEY not found! Please set it in the environment variables or Hugging Face Secrets.")
|
11 |
st.stop()
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
# Title and description
|
14 |
st.title("Technical Measurements Extractor for Patents")
|
15 |
st.write(
|
@@ -19,7 +52,7 @@ st.write(
|
|
19 |
|
20 |
# User Input Section
|
21 |
st.header("Enter Details for Patent Analysis")
|
22 |
-
user_date_input = st.text_input("Enter a date in the format 'YYYY-MM-DD':",
|
23 |
|
24 |
num_patents_to_analyze = st.number_input(
|
25 |
"Number of patents to analyze:", min_value=1, value=1, step=1, help="Specify how many patents you want to analyze."
|
|
|
2 |
from datetime import datetime
|
3 |
import streamlit as st
|
4 |
from patentwiz import preprocess_data, qa_agent
|
|
|
5 |
|
6 |
# Check if the API key is loaded
|
7 |
api_key = os.getenv("OPENAI_API_KEY")
|
|
|
9 |
st.error("OPENAI_API_KEY not found! Please set it in the environment variables or Hugging Face Secrets.")
|
10 |
st.stop()
|
11 |
|
12 |
+
PROMPT = """
|
13 |
+
Task: Carefully review the given patent text and extract as much physical measurements information such as length/distance, mass/weight, time, temperature, Volume, area, speed, pressure, energy, power, electric current
|
14 |
+
and voltage, frequency, force, acceleration, density, resistivity, magnetic field strength, and luminous intensity as much as possible.
|
15 |
+
We are particularly interested in physical measurements including substance that was measured, Value of the measurement, and Unit of the measurement, and measurement type mentioned in the text.
|
16 |
+
For each measurement, please provide the following details:
|
17 |
+
- The substance that was measured. (substance)
|
18 |
+
- The specific value or range that was measured. (Measured Value)
|
19 |
+
- The unit of the measurement, if provided. (Unit)
|
20 |
+
- The type of measurement being conducted (e.g., diameter, size, etc.)
|
21 |
+
Format your response in a structured JSON-like format, as follows:
|
22 |
+
{"Content": [
|
23 |
+
{
|
24 |
+
"Measurement_substance": "substance",
|
25 |
+
"Measured_value": "value",
|
26 |
+
"Measured_unit": "unit",
|
27 |
+
"measurement_type": "type"
|
28 |
+
},
|
29 |
+
// ... additional measurements, if present
|
30 |
+
]
|
31 |
+
}
|
32 |
+
If multiple measurements are present in the text, each should be listed as a separate object within the "Content" array.
|
33 |
+
Example: If the text includes the sentence, "The resulting BaCO3 had a crystallite size of between about 20 and 40 nm", the output should be:
|
34 |
+
{"Content": [
|
35 |
+
{
|
36 |
+
"Measurement_substance": "BaCO3",
|
37 |
+
"Measured_value": "between about 20 and 40",
|
38 |
+
"Measured_unit": "nm",
|
39 |
+
"measurement_type": "crystallite size"
|
40 |
+
}
|
41 |
+
]
|
42 |
+
}
|
43 |
+
Try to provide as complete and accurate information as possible. Print only the formatted JSON response.
|
44 |
+
"""
|
45 |
+
|
46 |
# Title and description
|
47 |
st.title("Technical Measurements Extractor for Patents")
|
48 |
st.write(
|
|
|
52 |
|
53 |
# User Input Section
|
54 |
st.header("Enter Details for Patent Analysis")
|
55 |
+
user_date_input = st.text_input("Enter a date in the format 'YYYY-MM-DD':", value="2024-06-16")
|
56 |
|
57 |
num_patents_to_analyze = st.number_input(
|
58 |
"Number of patents to analyze:", min_value=1, value=1, step=1, help="Specify how many patents you want to analyze."
|