mk1985 commited on
Commit
502c63f
·
verified ·
1 Parent(s): 27a2304

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -15
app.py CHANGED
@@ -70,35 +70,35 @@ def generate_from_prompt(prompt, provider, key_dict):
70
 
71
  # --- UI Definitions ---
72
  STANDARD_LABELS = [
73
- "Person", "Organization", "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 Analysis Tool", css=".prose { word-break: break-word; }") as demo:
81
- gr.Markdown("# Historical Text Analysis Tool")
82
  gr.Markdown("""
83
- This tool uses two forms of AI to accelerate historical research. First, a **Conceptual AI** generates a research framework with relevant search terms for your topic. Second, an **Extraction AI** scans your source text to find and highlight those terms with high precision.
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, like a name, a place, or a date (e.g., `Queen Victoria`, `1848`, `London`).
87
- - A **Label** is the category that entity belongs to (e.g., `Person`, `Date`, `Location`).
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 a Research Framework")
92
  with gr.Row():
93
- topic = gr.Textbox(label="Enter a Historical Topic", placeholder="e.g., The Chartist Movement")
94
- provider = gr.Dropdown(choices=list(MODEL_OPTIONS.keys()), label="Choose Conceptual 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 Framework", variant="primary")
100
 
101
- gr.Markdown("--- \n## Step 2: Define Labels and Analyze Source Text")
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():