Update app.py
Browse files
app.py
CHANGED
@@ -22,7 +22,7 @@ logging.basicConfig(
|
|
22 |
logging.StreamHandler()
|
23 |
]
|
24 |
)
|
25 |
-
logger = logging.getLogger(__name__)
|
26 |
|
27 |
# Clear proxy environment variables to avoid interference
|
28 |
os.environ.pop("HTTP_PROXY", None)
|
@@ -49,7 +49,7 @@ class ConversationMemory:
|
|
49 |
)
|
50 |
""")
|
51 |
self.conn.commit()
|
52 |
-
logger.info("Created
|
53 |
|
54 |
def add_chunk(self, text, role, intent="general"):
|
55 |
chunk_id = str(uuid.uuid4())
|
@@ -187,69 +187,79 @@ class OpenAIApi:
|
|
187 |
self.functions = [
|
188 |
{
|
189 |
"type": "function",
|
190 |
-
"
|
191 |
-
|
192 |
-
|
193 |
-
"
|
194 |
-
|
195 |
-
"
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
|
|
|
|
200 |
}
|
201 |
},
|
202 |
{
|
203 |
"type": "function",
|
204 |
-
"
|
205 |
-
|
206 |
-
|
207 |
-
"
|
208 |
-
|
209 |
-
"
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
|
|
|
|
214 |
}
|
215 |
},
|
216 |
{
|
217 |
"type": "function",
|
218 |
-
"
|
219 |
-
|
220 |
-
|
221 |
-
"
|
222 |
-
|
223 |
-
"
|
224 |
-
|
225 |
-
|
226 |
-
|
|
|
|
|
227 |
}
|
228 |
},
|
229 |
{
|
230 |
"type": "function",
|
231 |
-
"
|
232 |
-
|
233 |
-
|
234 |
-
"
|
235 |
-
|
236 |
-
"
|
237 |
-
|
238 |
-
|
239 |
-
|
|
|
|
|
240 |
}
|
241 |
},
|
242 |
{
|
243 |
"type": "function",
|
244 |
-
"
|
245 |
-
|
246 |
-
|
247 |
-
"
|
248 |
-
|
249 |
-
"
|
250 |
-
|
251 |
-
|
252 |
-
|
|
|
|
|
253 |
}
|
254 |
}
|
255 |
]
|
|
|
22 |
logging.StreamHandler()
|
23 |
]
|
24 |
)
|
25 |
+
logger = logging.getLogger(__name__')
|
26 |
|
27 |
# Clear proxy environment variables to avoid interference
|
28 |
os.environ.pop("HTTP_PROXY", None)
|
|
|
49 |
)
|
50 |
""")
|
51 |
self.conn.commit()
|
52 |
+
logger.info("Created conversation table")
|
53 |
|
54 |
def add_chunk(self, text, role, intent="general"):
|
55 |
chunk_id = str(uuid.uuid4())
|
|
|
187 |
self.functions = [
|
188 |
{
|
189 |
"type": "function",
|
190 |
+
"function": {
|
191 |
+
"name": "cut_text",
|
192 |
+
"description": "Cut text from a conversation chunk.",
|
193 |
+
"parameters": {
|
194 |
+
"type": "object",
|
195 |
+
"properties": {
|
196 |
+
"chunk_id": {"type": "string", "description": "ID of the conversation chunk"},
|
197 |
+
"start": {"type": "integer", "description": "Start index"},
|
198 |
+
"end": {"type": "integer", "description": "End index"}
|
199 |
+
},
|
200 |
+
"required": ["chunk_id", "start", "end"]
|
201 |
+
}
|
202 |
}
|
203 |
},
|
204 |
{
|
205 |
"type": "function",
|
206 |
+
"function": {
|
207 |
+
"name": "copy_text",
|
208 |
+
"description": "Copy text from a conversation chunk to clipboard.",
|
209 |
+
"parameters": {
|
210 |
+
"type": "object",
|
211 |
+
"properties": {
|
212 |
+
"chunk_id": {"type": "string", "description": "ID of the conversation chunk"},
|
213 |
+
"start": {"type": "integer", "description": "Start index"},
|
214 |
+
"end": {"type": "integer", "description": "End index"}
|
215 |
+
},
|
216 |
+
"required": ["chunk_id", "start", "end"]
|
217 |
+
}
|
218 |
}
|
219 |
},
|
220 |
{
|
221 |
"type": "function",
|
222 |
+
"function": {
|
223 |
+
"name": "paste_text",
|
224 |
+
"description": "Paste clipboard content into a conversation chunk.",
|
225 |
+
"parameters": {
|
226 |
+
"type": "object",
|
227 |
+
"properties": {
|
228 |
+
"chunk_id": {"type": "string", "description": "ID of the conversation chunk"},
|
229 |
+
"position": {"type": "integer", "description": "Position to paste"}
|
230 |
+
},
|
231 |
+
"required": ["chunk_id", "position"]
|
232 |
+
}
|
233 |
}
|
234 |
},
|
235 |
{
|
236 |
"type": "function",
|
237 |
+
"function": {
|
238 |
+
"name": "add_prefix",
|
239 |
+
"description": "Add a prefix to a conversation chunk.",
|
240 |
+
"parameters": {
|
241 |
+
"type": "object",
|
242 |
+
"properties": {
|
243 |
+
"chunk_id": {"type": "string", "description": "ID of the conversation chunk"},
|
244 |
+
"prefix": {"type": "string", "description": "Prefix to add"}
|
245 |
+
},
|
246 |
+
"required": ["chunk_id", "prefix"]
|
247 |
+
}
|
248 |
}
|
249 |
},
|
250 |
{
|
251 |
"type": "function",
|
252 |
+
"function": {
|
253 |
+
"name": "add_suffix",
|
254 |
+
"description": "Add a suffix to a conversation chunk.",
|
255 |
+
"parameters": {
|
256 |
+
"type": "object",
|
257 |
+
"properties": {
|
258 |
+
"chunk_id": {"type": "string", "description": "ID of the conversation chunk"},
|
259 |
+
"suffix": {"type": "string", "description": "Suffix to add"}
|
260 |
+
},
|
261 |
+
"required": ["chunk_id", "suffix"]
|
262 |
+
}
|
263 |
}
|
264 |
}
|
265 |
]
|