Update app.py
Browse files
app.py
CHANGED
@@ -34,7 +34,7 @@ def remove_labels_with_regex(text: str):
|
|
34 |
cleaned_text = re.sub(pattern, '', text, flags=re.MULTILINE)
|
35 |
return cleaned_text
|
36 |
|
37 |
-
def exctrator(sentence, phrase
|
38 |
extracted_text = sentence.split(phrase)[1].strip() if phrase in sentence else ""
|
39 |
return extracted_text
|
40 |
|
@@ -42,7 +42,7 @@ def switching(text):
|
|
42 |
result = None
|
43 |
|
44 |
if re.search("show me your image", text.lower(), re.IGNORECASE):
|
45 |
-
prompt = exctrator(text.lower())
|
46 |
# Завантажуємо зображення
|
47 |
uploaded_image = ic.load_image()
|
48 |
|
@@ -56,9 +56,13 @@ def switching(text):
|
|
56 |
components.html(html_content, height=800, scrolling=True)
|
57 |
elif re.search("pay the ghost", text.lower(), re.IGNORECASE):
|
58 |
components.html(html_doge_wallet, height=600, scrolling=False)
|
|
|
|
|
|
|
|
|
59 |
else:
|
60 |
prompt = select_prompt(input_text=text, prompts=prompts, keywords=keywords)
|
61 |
-
result = chat.chatting(prompt=prompt if prompt is not None else text)
|
62 |
|
63 |
print(f"Prompt:\n{prompt}")
|
64 |
return result
|
|
|
34 |
cleaned_text = re.sub(pattern, '', text, flags=re.MULTILINE)
|
35 |
return cleaned_text
|
36 |
|
37 |
+
def exctrator(sentence, phrase):
|
38 |
extracted_text = sentence.split(phrase)[1].strip() if phrase in sentence else ""
|
39 |
return extracted_text
|
40 |
|
|
|
42 |
result = None
|
43 |
|
44 |
if re.search("show me your image", text.lower(), re.IGNORECASE):
|
45 |
+
prompt = exctrator(text.lower(), phrase="show me your image")
|
46 |
# Завантажуємо зображення
|
47 |
uploaded_image = ic.load_image()
|
48 |
|
|
|
56 |
components.html(html_content, height=800, scrolling=True)
|
57 |
elif re.search("pay the ghost", text.lower(), re.IGNORECASE):
|
58 |
components.html(html_doge_wallet, height=600, scrolling=False)
|
59 |
+
elif re.search("long live liberty.", text.lower(), re.IGNORECASE):
|
60 |
+
exctracted_statement = exctrator(text.lower(), phrase="long live liberty")
|
61 |
+
prompt = f"Evaluate how far the statement from libertarian ideology 1 to 10 and why?\n\n{exctracted_statement}"
|
62 |
+
result = chat.chatting(prompt=prompt if prompt is not None else text, is_own_model=True)
|
63 |
else:
|
64 |
prompt = select_prompt(input_text=text, prompts=prompts, keywords=keywords)
|
65 |
+
result = chat.chatting(prompt=prompt if prompt is not None else text, is_own_model=False)
|
66 |
|
67 |
print(f"Prompt:\n{prompt}")
|
68 |
return result
|