sabonzo commited on
Commit
69528c1
·
verified ·
1 Parent(s): 5c372df

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -5
app.py CHANGED
@@ -7,7 +7,7 @@ from tools.final_answer import FinalAnswerTool
7
  from Gradio_UI import GradioUI
8
  import os
9
  api_key = os.getenv("OPENAI_API_KEY")
10
-
11
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
12
  @tool
13
  def my_custom_tool(arg1:str, arg2:int)-> str:
@@ -70,11 +70,31 @@ def calculate_expenses(sallery: int) -> str:
70
 
71
  @tool
72
  def encode_text(text: str) -> str:
73
- """A tool that encodes a given text using the sabonzo method.
 
74
  Args:
75
- text: The text to be encoded.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  """
77
- return ''.join(chr(ord(char) + 2) for char in text)
 
 
78
 
79
  @tool
80
  def get_current_time_in_timezone(timezone: str) -> str:
@@ -117,7 +137,7 @@ with open("prompts.yaml", 'r') as stream:
117
 
118
  agent = CodeAgent(
119
  model=model,
120
- tools=[final_answer, calculate_expenses, image_generation_tool, encode_text, get_sura, search_quran],
121
  max_steps=6,
122
  verbosity_level=1,
123
  grammar=None,
 
7
  from Gradio_UI import GradioUI
8
  import os
9
  api_key = os.getenv("OPENAI_API_KEY")
10
+ momo_key = os.getenv("MomoKey")
11
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
12
  @tool
13
  def my_custom_tool(arg1:str, arg2:int)-> str:
 
70
 
71
  @tool
72
  def encode_text(text: str) -> str:
73
+ """Encodes text using XOR with a key and Base64 encoding.
74
+
75
  Args:
76
+ text: The text to encode.
77
+
78
+ Returns:
79
+ Encoded Base64 string.
80
+ """
81
+ key_cycle = (ord(k) for k in momo_key) # Cycle through key chars
82
+ encoded_bytes = bytes([ord(c) ^ next(key_cycle) for c in text]) # XOR each char
83
+ return base64.b64encode(encoded_bytes).decode()
84
+
85
+ @tool
86
+ def decode_text(encoded_text: str) -> str:
87
+ """Decodes a Base64-encoded XOR encrypted text using the given key.
88
+
89
+ Args:
90
+ encoded_text: The encoded Base64 string.
91
+
92
+ Returns:
93
+ Decoded plain text.
94
  """
95
+ key_cycle = (ord(k) for k in momo_key)
96
+ decoded_bytes = base64.b64decode(encoded_text) # Decode Base64
97
+ return ''.join(chr(b ^ next(key_cycle)) for b in decoded_bytes)
98
 
99
  @tool
100
  def get_current_time_in_timezone(timezone: str) -> str:
 
137
 
138
  agent = CodeAgent(
139
  model=model,
140
+ tools=[final_answer, calculate_expenses, image_generation_tool, encode_text, decode_text, get_sura, search_quran],
141
  max_steps=6,
142
  verbosity_level=1,
143
  grammar=None,