CISCai commited on
Commit
6716ce3
1 Parent(s): 5bf205a

Add support for retrieving changes directly from session.

Browse files

Circumvents issues with too long URI on large changes (typically with complex chat templates).

Files changed (1) hide show
  1. app.py +15 -2
app.py CHANGED
@@ -1025,8 +1025,10 @@ Any framework based on `llama-cpp-python` will let you select which chat templat
1025
  if meta.rem or meta.add:
1026
  link += '&' + urlencode(
1027
  {
1028
- 'rem': meta.rem,
1029
- 'add': [json.dumps([k, *v], ensure_ascii = False, separators = (',', ':')) for k, v in meta.add.items()],
 
 
1030
  },
1031
  doseq = True,
1032
  safe = '[]{}:"\',',
@@ -1431,6 +1433,8 @@ if __name__ == "__main__":
1431
  branch: Annotated[str, Query()] = "main",
1432
  add: Annotated[list[str] | None, Query()] = None,
1433
  rem: Annotated[list[str] | None, Query()] = None,
 
 
1434
  ):
1435
  token = request.session.get('oauth_info', {}).get('access_token')
1436
 
@@ -1440,6 +1444,15 @@ if __name__ == "__main__":
1440
  detail = 'Invalid repository',
1441
  )
1442
 
 
 
 
 
 
 
 
 
 
1443
  stream = stream_repo_file(
1444
  repo_file,
1445
  branch,
 
1025
  if meta.rem or meta.add:
1026
  link += '&' + urlencode(
1027
  {
1028
+ 'session': request.session_hash,
1029
+ 'state': str(meta_state._id),
1030
+ # 'rem': meta.rem,
1031
+ # 'add': [json.dumps([k, *v], ensure_ascii = False, separators = (',', ':')) for k, v in meta.add.items()],
1032
  },
1033
  doseq = True,
1034
  safe = '[]{}:"\',',
 
1433
  branch: Annotated[str, Query()] = "main",
1434
  add: Annotated[list[str] | None, Query()] = None,
1435
  rem: Annotated[list[str] | None, Query()] = None,
1436
+ session: Annotated[str | None, Query()] = None,
1437
+ state: Annotated[int | None, Query()] = None,
1438
  ):
1439
  token = request.session.get('oauth_info', {}).get('access_token')
1440
 
 
1444
  detail = 'Invalid repository',
1445
  )
1446
 
1447
+ if session and state is not None and session in request.app.state_holder and state in request.app.state_holder[session]:
1448
+ meta: MetadataState = request.app.state_holder[session][state]
1449
+
1450
+ if meta.rem:
1451
+ rem = list(meta.rem)
1452
+
1453
+ if meta.add:
1454
+ add = [json.dumps([k, *v], ensure_ascii = False, separators = (',', ':')) for k, v in meta.add.items()]
1455
+
1456
  stream = stream_repo_file(
1457
  repo_file,
1458
  branch,