Deadmon commited on
Commit
085bc4b
·
verified ·
1 Parent(s): f22fda0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +59 -49
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 conversation_chunks table")
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
- "name": "cut_text",
191
- "description": "Cut text from a conversation chunk.",
192
- "parameters": {
193
- "type": "object",
194
- "properties": {
195
- "chunk_id": {"type": "string", "description": "ID of the conversation chunk"},
196
- "start": {"type": "integer", "description": "Start index"},
197
- "end": {"type": "integer", "description": "End index"}
198
- },
199
- "required": ["chunk_id", "start", "end"]
 
 
200
  }
201
  },
202
  {
203
  "type": "function",
204
- "name": "copy_text",
205
- "description": "Copy text from a conversation chunk to clipboard.",
206
- "parameters": {
207
- "type": "object",
208
- "properties": {
209
- "chunk_id": {"type": "string", "description": "ID of the conversation chunk"},
210
- "start": {"type": "integer", "description": "Start index"},
211
- "end": {"type": "integer", "description": "End index"}
212
- },
213
- "required": ["chunk_id", "start", "end"]
 
 
214
  }
215
  },
216
  {
217
  "type": "function",
218
- "name": "paste_text",
219
- "description": "Paste clipboard content into a conversation chunk.",
220
- "parameters": {
221
- "type": "object",
222
- "properties": {
223
- "chunk_id": {"type": "string", "description": "ID of the conversation chunk"},
224
- "position": {"type": "integer", "description": "Position to paste"}
225
- },
226
- "required": ["chunk_id", "position"]
 
 
227
  }
228
  },
229
  {
230
  "type": "function",
231
- "name": "add_prefix",
232
- "description": "Add a prefix to a conversation chunk.",
233
- "parameters": {
234
- "type": "object",
235
- "properties": {
236
- "chunk_id": {"type": "string", "description": "ID of the conversation chunk"},
237
- "prefix": {"type": "string", "description": "Prefix to add"}
238
- },
239
- "required": ["chunk_id", "prefix"]
 
 
240
  }
241
  },
242
  {
243
  "type": "function",
244
- "name": "add_suffix",
245
- "description": "Add a suffix to a conversation chunk.",
246
- "parameters": {
247
- "type": "object",
248
- "properties": {
249
- "chunk_id": {"type": "string", "description": "ID of the conversation chunk"},
250
- "suffix": {"type": "string", "description": "Suffix to add"}
251
- },
252
- "required": ["chunk_id", "suffix"]
 
 
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
  ]