Introduction
Introduction Statistics Contact Development Disclaimer Help
textsynth-complete - annna - Annna the nice friendly bot.
git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws6…
Log
Files
Refs
Tags
README
---
textsynth-complete (1250B)
---
1 #!/usr/bin/env python
2 # coding=utf-8
3 #
4 # Copy me if you can.
5 # by 20h
6 #
7
8 # Does not work anymore. Mr. Bellard made a company out of it.
9
10 import os
11 import sys
12 import getopt
13 import websocket
14 import time
15
16 def usage(app):
17 app = os.path.basename(app)
18 print("usage: %s [-hr] [-b base] text to complete..." % (app),
19 file=sys.stderr)
20 sys.exit(1)
21
22 def main(args):
23 try:
24 opts, largs = getopt.getopt(args[1:], "hb:r")
25 except getopt.GetoptError as err:
26 print(str(err))
27 usage(args[0])
28
29 onlyresult = False
30
31 baseuri = "wss://bellard.org/textsynth/ws"
32 for o, a in opts:
33 if o == "-h":
34 usage(args[0])
35 elif o == "-r":
36 onlyresult = True
37 else:
38 assert False, "unhandled option"
39
40 if len(largs) < 1:
41 usage(args[0])
42 txtstr = " ".join(largs)
43 timenow = time.time() * 1000
44 timenowint = round(timenow)
45 seed = (timenowint | 0) + (round(timenow / 4294967296) | 0)
46 reqstr = "g,gpt2_1558M,40,0.9,1,%d,%s" % (seed, txtstr)
47
48 try:
49 ws = websocket.WebSocket()
50 ws.connect(baseuri)
51 ws.send(reqstr)
52
53 rstr = ""
54 while 1:
55 r = ws.recv()
56 if onlyresult == False:
57 print(r)
58 if len(r) == 0:
59 break
60 rstr += r
61 except:
62 return 1
63
64 print("%s%s\n" % (txtstr, rstr))
65
66 return 0
67
68 if __name__ == "__main__":
69 sys.exit(main(sys.argv))
70
You are viewing proxied material from bitreich.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.