Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -22,6 +22,28 @@ from tensorflow.keras.models import load_model
|
|
| 22 |
from Gradio_UI import GradioUI
|
| 23 |
|
| 24 |
# Below is an example of a tool that does nothing. Amaze us with your creativity!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
@tool
|
| 26 |
def my_custom_tool(arg1:str, arg2:int)-> str: # it's important to specify the return type
|
| 27 |
# Keep this format for the tool description / args description but feel free to modify the tool
|
|
|
|
| 22 |
from Gradio_UI import GradioUI
|
| 23 |
|
| 24 |
# Below is an example of a tool that does nothing. Amaze us with your creativity!
|
| 25 |
+
@tool
|
| 26 |
+
def open_file_parts(openfile: int) -> int:
|
| 27 |
+
file = open("book.txt", "r", encoding = "utf8")
|
| 28 |
+
|
| 29 |
+
# store file in list
|
| 30 |
+
lines = []
|
| 31 |
+
for i in file:
|
| 32 |
+
lines.append(i)
|
| 33 |
+
|
| 34 |
+
# Convert list to string
|
| 35 |
+
data = ""
|
| 36 |
+
for i in lines:
|
| 37 |
+
data = ' '. join(lines)
|
| 38 |
+
|
| 39 |
+
#replace unnecessary stuff with space
|
| 40 |
+
data = data.replace('\n', '').replace('\r', '').replace('\ufeff', '').replace('“','').replace('”','') #new line, carriage return, unicode character --> replace by space
|
| 41 |
+
|
| 42 |
+
#remove unnecessary spaces
|
| 43 |
+
data = data.split()
|
| 44 |
+
data = ' '.join(data)
|
| 45 |
+
data[:openfile]
|
| 46 |
+
|
| 47 |
@tool
|
| 48 |
def my_custom_tool(arg1:str, arg2:int)-> str: # it's important to specify the return type
|
| 49 |
# Keep this format for the tool description / args description but feel free to modify the tool
|