Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -70,35 +70,35 @@ def generate_from_prompt(prompt, provider, key_dict):
|
|
| 70 |
|
| 71 |
# --- UI Definitions ---
|
| 72 |
STANDARD_LABELS = [
|
| 73 |
-
"Person", "
|
| 74 |
"Nationality", "Group", "Date", "Event", "Law", "Legal Document",
|
| 75 |
-
"Product", "Facility", "Work
|
| 76 |
"Money", "Currency", "Quantity", "Ordinal Number", "Cardinal Number"
|
| 77 |
]
|
| 78 |
MAX_CATEGORIES = 8
|
| 79 |
|
| 80 |
-
with gr.Blocks(title="Historical Text
|
| 81 |
-
gr.Markdown("# Historical Text
|
| 82 |
gr.Markdown("""
|
| 83 |
-
|
| 84 |
-
### Understanding
|
| 85 |
-
In text analysis, this process is often called
|
| 86 |
-
- An **Entity** is a specific piece of text in your document,
|
| 87 |
-
- A **Label** is the category that entity belongs to (e.g
|
| 88 |
-
This tool helps you define your labels and then automatically finds the corresponding entities in your text.
|
| 89 |
""")
|
| 90 |
|
| 91 |
-
gr.Markdown("--- \n## Step 1: Generate
|
| 92 |
with gr.Row():
|
| 93 |
-
topic = gr.Textbox(label="Enter a Historical Topic", placeholder="e.g
|
| 94 |
-
provider = gr.Dropdown(choices=list(MODEL_OPTIONS.keys()), label="Choose
|
| 95 |
with gr.Row():
|
| 96 |
openai_key = gr.Textbox(label="OpenAI API Key", type="password")
|
| 97 |
anthropic_key = gr.Textbox(label="Anthropic API Key", type="password")
|
| 98 |
google_key = gr.Textbox(label="Google API Key", type="password")
|
| 99 |
-
generate_btn = gr.Button("Generate
|
| 100 |
|
| 101 |
-
gr.Markdown("--- \n## Step 2:
|
| 102 |
gr.Markdown("#### 1. AI-Suggested Labels")
|
| 103 |
dynamic_components = []
|
| 104 |
with gr.Column():
|
|
|
|
| 70 |
|
| 71 |
# --- UI Definitions ---
|
| 72 |
STANDARD_LABELS = [
|
| 73 |
+
"Person", "Organisation", "Location", "Country", "City", "State",
|
| 74 |
"Nationality", "Group", "Date", "Event", "Law", "Legal Document",
|
| 75 |
+
"Product", "Facility", "Work of Art", "Language", "Time", "Percentage",
|
| 76 |
"Money", "Currency", "Quantity", "Ordinal Number", "Cardinal Number"
|
| 77 |
]
|
| 78 |
MAX_CATEGORIES = 8
|
| 79 |
|
| 80 |
+
with gr.Blocks(title="Historical Text Analyser", css=".prose { word-break: break-word; }") as demo:
|
| 81 |
+
gr.Markdown("# Historical Text Analyser")
|
| 82 |
gr.Markdown("""
|
| 83 |
+
First, a **Conceptual AI**, powered by a large language model such as OpenAI's GPT-4, Anthropic's Claude, or Google's Gemini, suggests labels based on your chosen historical topic. These labels are grouped into broader categories (e.g. Economic Policies, Significant Events) to help focus your research. Second, an **Extraction AI**, powered by the GLiNER model, scans your source text to find and highlight matching entities - instances where those labels appear in the document - with high accuracy.
|
| 84 |
+
### Understanding Entities and Labels ###
|
| 85 |
+
In text analysis, this process is often called Named Entity Recognition (NER).
|
| 86 |
+
- An **Entity** is a specific piece of text in your document, such as a name, a place, or a date (e.g. Queen Victoria, 1848).
|
| 87 |
+
- A **Label** is the category that the entity belongs to (e.g. Person, Date, Location).
|
| 88 |
+
This tool helps you to define your labels and then automatically finds the corresponding entities in your text.
|
| 89 |
""")
|
| 90 |
|
| 91 |
+
gr.Markdown("--- \n## Step 1: Generate Labels")
|
| 92 |
with gr.Row():
|
| 93 |
+
topic = gr.Textbox(label="Enter a Historical Topic", placeholder="e.g. Britain during the Second World War")
|
| 94 |
+
provider = gr.Dropdown(choices=list(MODEL_OPTIONS.keys()), label="Choose AI Model")
|
| 95 |
with gr.Row():
|
| 96 |
openai_key = gr.Textbox(label="OpenAI API Key", type="password")
|
| 97 |
anthropic_key = gr.Textbox(label="Anthropic API Key", type="password")
|
| 98 |
google_key = gr.Textbox(label="Google API Key", type="password")
|
| 99 |
+
generate_btn = gr.Button("Generate Labels", variant="primary")
|
| 100 |
|
| 101 |
+
gr.Markdown("--- \n## Step 2: Confirm Labels and Analyse Source Text")
|
| 102 |
gr.Markdown("#### 1. AI-Suggested Labels")
|
| 103 |
dynamic_components = []
|
| 104 |
with gr.Column():
|