Update ✨Entity Linking Application✨.py
Browse files- ✨Entity Linking Application✨.py +14 -17
✨Entity Linking Application✨.py
CHANGED
@@ -36,22 +36,6 @@ else:
|
|
36 |
|
37 |
model = SentenceTransformer("Lajavaness/bilingual-embedding-large", trust_remote_code=True)
|
38 |
|
39 |
-
|
40 |
-
api_token = st.text_input("Enter your API key from [GitHub](https://github.com/marketplace/models/azure-openai/gpt-4o):", "", type="password")
|
41 |
-
|
42 |
-
|
43 |
-
if api_token:
|
44 |
-
endpoint = "https://models.inference.ai.azure.com"
|
45 |
-
model_name = "gpt-4o"
|
46 |
-
client = OpenAI(
|
47 |
-
base_url=endpoint,
|
48 |
-
api_key=api_token,
|
49 |
-
)
|
50 |
-
st.success("API Token is set for this session.")
|
51 |
-
else:
|
52 |
-
st.warning("Please enter an API token to proceed.")
|
53 |
-
|
54 |
-
|
55 |
async def fetch_json(url, session):
|
56 |
async with session.get(url) as response:
|
57 |
return await response.json()
|
@@ -289,13 +273,26 @@ def main_cli():
|
|
289 |
if "disabled" not in st.session_state:
|
290 |
st.session_state.disabled = False
|
291 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
292 |
input_sentence_user = st.text_input("Enter a sentence:", "", disabled=st.session_state.disabled)
|
293 |
input_mention_user = st.text_input("Enter a textural reference (mention) that is inside the sentence:", "", disabled=st.session_state.disabled)
|
294 |
single = st.selectbox("Search each word individually? (Useful for difficult mentions)", ['Yes', 'No'], index=1, disabled=st.session_state.disabled)
|
295 |
combi = st.selectbox("Make combinations of each word? (Useful for difficult mentions)", ['Yes', 'No'], index=1, disabled=st.session_state.disabled)
|
296 |
disambi = st.selectbox("Run acronym disambiguation? (Enable it if the mention include an acronym or if it is nested)", ['Yes', 'No'], index=0, disabled=st.session_state.disabled)
|
297 |
|
298 |
-
if st.button("Run Entity Linking", key="disabled"):
|
299 |
if input_sentence_user and input_mention_user:
|
300 |
# check if the mention is in the sentence
|
301 |
if input_mention_user in input_sentence_user:
|
|
|
36 |
|
37 |
model = SentenceTransformer("Lajavaness/bilingual-embedding-large", trust_remote_code=True)
|
38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
async def fetch_json(url, session):
|
40 |
async with session.get(url) as response:
|
41 |
return await response.json()
|
|
|
273 |
if "disabled" not in st.session_state:
|
274 |
st.session_state.disabled = False
|
275 |
|
276 |
+
api_token = st.text_input("Enter your API key from [GitHub](https://github.com/marketplace/models/azure-openai/gpt-4o):", "", type="password", disabled=st.session_state.disabled)
|
277 |
+
|
278 |
+
if api_token:
|
279 |
+
endpoint = "https://models.inference.ai.azure.com"
|
280 |
+
model_name = "gpt-4o"
|
281 |
+
client = OpenAI(
|
282 |
+
base_url=endpoint,
|
283 |
+
api_key=api_token,
|
284 |
+
)
|
285 |
+
st.success("API Token is set for this session.")
|
286 |
+
else:
|
287 |
+
st.warning("Please enter an API token to proceed.")
|
288 |
+
|
289 |
input_sentence_user = st.text_input("Enter a sentence:", "", disabled=st.session_state.disabled)
|
290 |
input_mention_user = st.text_input("Enter a textural reference (mention) that is inside the sentence:", "", disabled=st.session_state.disabled)
|
291 |
single = st.selectbox("Search each word individually? (Useful for difficult mentions)", ['Yes', 'No'], index=1, disabled=st.session_state.disabled)
|
292 |
combi = st.selectbox("Make combinations of each word? (Useful for difficult mentions)", ['Yes', 'No'], index=1, disabled=st.session_state.disabled)
|
293 |
disambi = st.selectbox("Run acronym disambiguation? (Enable it if the mention include an acronym or if it is nested)", ['Yes', 'No'], index=0, disabled=st.session_state.disabled)
|
294 |
|
295 |
+
if st.button("Run Entity Linking", key="disabled", disabled=st.session_state.disabled):
|
296 |
if input_sentence_user and input_mention_user:
|
297 |
# check if the mention is in the sentence
|
298 |
if input_mention_user in input_sentence_user:
|