new_logic
Browse files- app.py +2 -2
- search_errors_logic.py +9 -1
app.py
CHANGED
@@ -2,7 +2,7 @@ import language_tool_python
|
|
2 |
import openai
|
3 |
import streamlit as st
|
4 |
import subprocess
|
5 |
-
from search_errors_logic import check_text
|
6 |
import html
|
7 |
import docx
|
8 |
from io import BytesIO
|
@@ -136,7 +136,7 @@ def main():
|
|
136 |
if not text.strip():
|
137 |
st.warning("Введите текст для проверки")
|
138 |
else:
|
139 |
-
text, errors =
|
140 |
if not errors:
|
141 |
st.success("Ошибок не найдено! 👍")
|
142 |
else:
|
|
|
2 |
import openai
|
3 |
import streamlit as st
|
4 |
import subprocess
|
5 |
+
from search_errors_logic import check_text
|
6 |
import html
|
7 |
import docx
|
8 |
from io import BytesIO
|
|
|
136 |
if not text.strip():
|
137 |
st.warning("Введите текст для проверки")
|
138 |
else:
|
139 |
+
text, errors = check_text(text, tool, mode="chat_gpt")
|
140 |
if not errors:
|
141 |
st.success("Ошибок не найдено! 👍")
|
142 |
else:
|
search_errors_logic.py
CHANGED
@@ -174,6 +174,13 @@ def add_comments_to_text(text, errors):
|
|
174 |
return text.replace("\n", " ")
|
175 |
|
176 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
def check_text_chat_gpt(text, *args, **kwargs):
|
178 |
fixed_text = get_gpt_response(prompt_fix_text_gpt.format(text), "vsegpt")
|
179 |
changes = find_corrected_positions(text, fixed_text)
|
@@ -191,7 +198,8 @@ def check_text_chat_gpt(text, *args, **kwargs):
|
|
191 |
text_with_comments = add_comments_to_text(text, errors)
|
192 |
return text_with_comments, errors
|
193 |
|
194 |
-
|
|
|
195 |
matches = tool.check(text)
|
196 |
errors = []
|
197 |
for match in matches:
|
|
|
174 |
return text.replace("\n", " ")
|
175 |
|
176 |
|
177 |
+
def check_text(text, tool, mode):
|
178 |
+
if mode == "tool":
|
179 |
+
return check_text_with_tool(text, tool)
|
180 |
+
else:
|
181 |
+
return check_text_chat_gpt(text)
|
182 |
+
|
183 |
+
|
184 |
def check_text_chat_gpt(text, *args, **kwargs):
|
185 |
fixed_text = get_gpt_response(prompt_fix_text_gpt.format(text), "vsegpt")
|
186 |
changes = find_corrected_positions(text, fixed_text)
|
|
|
198 |
text_with_comments = add_comments_to_text(text, errors)
|
199 |
return text_with_comments, errors
|
200 |
|
201 |
+
|
202 |
+
def check_text_with_tool(text, tool):
|
203 |
matches = tool.check(text)
|
204 |
errors = []
|
205 |
for match in matches:
|