jcleee commited on
Commit
ccef1c7
·
verified ·
1 Parent(s): 9fd47eb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -1
app.py CHANGED
@@ -4,6 +4,7 @@ import requests
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
 
7
 
8
  from Gradio_UI import GradioUI
9
 
@@ -34,6 +35,17 @@ def get_current_time_in_timezone(timezone: str) -> str:
34
  except Exception as e:
35
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
36
 
 
 
 
 
 
 
 
 
 
 
 
37
 
38
  final_answer = FinalAnswerTool()
39
 
@@ -56,7 +68,7 @@ with open("prompts.yaml", 'r') as stream:
56
 
57
  agent = CodeAgent(
58
  model=model,
59
- tools=[final_answer, web_search], ## add your tools here (don't remove final answer)
60
  max_steps=6,
61
  verbosity_level=1,
62
  grammar=None,
 
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
7
+ from langchain.text_splitter import CharacterTextSplitter
8
 
9
  from Gradio_UI import GradioUI
10
 
 
35
  except Exception as e:
36
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
37
 
38
+ @tool
39
+ def text_splitter(text: str) -> List[str]:
40
+ c_splitter = CharacterTextSplitter(
41
+ chunk_size=450,
42
+ chunk_overlap=10
43
+ )
44
+ split_text = c_splitter.split_text(text)
45
+ return split_text
46
+ #
47
+
48
+
49
 
50
  final_answer = FinalAnswerTool()
51
 
 
68
 
69
  agent = CodeAgent(
70
  model=model,
71
+ tools=[final_answer, web_search, text_splitter], ## add your tools here (don't remove final answer)
72
  max_steps=6,
73
  verbosity_level=1,
74
  grammar=None,