Spaces:
Running
Running
Merge pull request #2 from Y-IAB/1-arena
Browse files[#1] Implement side-by-side chatbot interface
- .gitignore +1 -0
- .isort.cfg +2 -0
- .pylintrc +401 -0
- .style.yapf +3 -0
- .vscode/extensions.json +8 -0
- .vscode/settings.json +15 -0
- README.md +24 -0
- app.py +112 -0
- requirments.txt +113 -0
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
venv
|
.isort.cfg
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
[settings]
|
2 |
+
profile = google
|
.pylintrc
ADDED
@@ -0,0 +1,401 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# This Pylint rcfile contains a best-effort configuration to uphold the
|
2 |
+
# best-practices and style described in the Google Python style guide:
|
3 |
+
# https://google.github.io/styleguide/pyguide.html
|
4 |
+
#
|
5 |
+
# Its canonical open-source location is:
|
6 |
+
# https://google.github.io/styleguide/pylintrc
|
7 |
+
|
8 |
+
[MAIN]
|
9 |
+
|
10 |
+
# Files or directories to be skipped. They should be base names, not paths.
|
11 |
+
ignore=third_party
|
12 |
+
|
13 |
+
# Files or directories matching the regex patterns are skipped. The regex
|
14 |
+
# matches against base names, not paths.
|
15 |
+
ignore-patterns=
|
16 |
+
|
17 |
+
# Pickle collected data for later comparisons.
|
18 |
+
persistent=no
|
19 |
+
|
20 |
+
# List of plugins (as comma separated values of python modules names) to load,
|
21 |
+
# usually to register additional checkers.
|
22 |
+
load-plugins=
|
23 |
+
|
24 |
+
# Use multiple processes to speed up Pylint.
|
25 |
+
jobs=4
|
26 |
+
|
27 |
+
# Allow loading of arbitrary C extensions. Extensions are imported into the
|
28 |
+
# active Python interpreter and may run arbitrary code.
|
29 |
+
unsafe-load-any-extension=no
|
30 |
+
|
31 |
+
|
32 |
+
[MESSAGES CONTROL]
|
33 |
+
|
34 |
+
# Only show warnings with the listed confidence levels. Leave empty to show
|
35 |
+
# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED
|
36 |
+
confidence=
|
37 |
+
|
38 |
+
# Enable the message, report, category or checker with the given id(s). You can
|
39 |
+
# either give multiple identifier separated by comma (,) or put this option
|
40 |
+
# multiple time (only on the command line, not in the configuration file where
|
41 |
+
# it should appear only once). See also the "--disable" option for examples.
|
42 |
+
#enable=
|
43 |
+
|
44 |
+
# Disable the message, report, category or checker with the given id(s). You
|
45 |
+
# can either give multiple identifiers separated by comma (,) or put this
|
46 |
+
# option multiple times (only on the command line, not in the configuration
|
47 |
+
# file where it should appear only once).You can also use "--disable=all" to
|
48 |
+
# disable everything first and then reenable specific checks. For example, if
|
49 |
+
# you want to run only the similarities checker, you can use "--disable=all
|
50 |
+
# --enable=similarities". If you want to run only the classes checker, but have
|
51 |
+
# no Warning level messages displayed, use"--disable=all --enable=classes
|
52 |
+
# --disable=W"
|
53 |
+
disable=R,
|
54 |
+
abstract-method,
|
55 |
+
apply-builtin,
|
56 |
+
arguments-differ,
|
57 |
+
attribute-defined-outside-init,
|
58 |
+
backtick,
|
59 |
+
bad-option-value,
|
60 |
+
basestring-builtin,
|
61 |
+
buffer-builtin,
|
62 |
+
c-extension-no-member,
|
63 |
+
consider-using-enumerate,
|
64 |
+
cmp-builtin,
|
65 |
+
cmp-method,
|
66 |
+
coerce-builtin,
|
67 |
+
coerce-method,
|
68 |
+
delslice-method,
|
69 |
+
div-method,
|
70 |
+
eq-without-hash,
|
71 |
+
execfile-builtin,
|
72 |
+
file-builtin,
|
73 |
+
filter-builtin-not-iterating,
|
74 |
+
fixme,
|
75 |
+
getslice-method,
|
76 |
+
global-statement,
|
77 |
+
hex-method,
|
78 |
+
idiv-method,
|
79 |
+
implicit-str-concat,
|
80 |
+
import-error,
|
81 |
+
import-self,
|
82 |
+
import-star-module-level,
|
83 |
+
input-builtin,
|
84 |
+
intern-builtin,
|
85 |
+
invalid-str-codec,
|
86 |
+
locally-disabled,
|
87 |
+
long-builtin,
|
88 |
+
long-suffix,
|
89 |
+
map-builtin-not-iterating,
|
90 |
+
misplaced-comparison-constant,
|
91 |
+
missing-function-docstring,
|
92 |
+
metaclass-assignment,
|
93 |
+
next-method-called,
|
94 |
+
next-method-defined,
|
95 |
+
no-absolute-import,
|
96 |
+
no-init,
|
97 |
+
no-member,
|
98 |
+
no-name-in-module,
|
99 |
+
no-self-use,
|
100 |
+
nonzero-method,
|
101 |
+
oct-method,
|
102 |
+
old-division,
|
103 |
+
old-ne-operator,
|
104 |
+
old-octal-literal,
|
105 |
+
old-raise-syntax,
|
106 |
+
parameter-unpacking,
|
107 |
+
print-statement,
|
108 |
+
raising-string,
|
109 |
+
range-builtin-not-iterating,
|
110 |
+
raw_input-builtin,
|
111 |
+
rdiv-method,
|
112 |
+
reduce-builtin,
|
113 |
+
relative-import,
|
114 |
+
reload-builtin,
|
115 |
+
round-builtin,
|
116 |
+
setslice-method,
|
117 |
+
signature-differs,
|
118 |
+
standarderror-builtin,
|
119 |
+
suppressed-message,
|
120 |
+
sys-max-int,
|
121 |
+
trailing-newlines,
|
122 |
+
unichr-builtin,
|
123 |
+
unicode-builtin,
|
124 |
+
unnecessary-pass,
|
125 |
+
unpacking-in-except,
|
126 |
+
useless-else-on-loop,
|
127 |
+
useless-suppression,
|
128 |
+
using-cmp-argument,
|
129 |
+
wrong-import-order,
|
130 |
+
xrange-builtin,
|
131 |
+
zip-builtin-not-iterating,
|
132 |
+
# added rules
|
133 |
+
missing-class-docstring,
|
134 |
+
|
135 |
+
|
136 |
+
[REPORTS]
|
137 |
+
|
138 |
+
# Set the output format. Available formats are text, parseable, colorized, msvs
|
139 |
+
# (visual studio) and html. You can also give a reporter class, eg
|
140 |
+
# mypackage.mymodule.MyReporterClass.
|
141 |
+
output-format=text
|
142 |
+
|
143 |
+
# Tells whether to display a full report or only the messages
|
144 |
+
reports=no
|
145 |
+
|
146 |
+
# Python expression which should return a note less than 10 (10 is the highest
|
147 |
+
# note). You have access to the variables errors warning, statement which
|
148 |
+
# respectively contain the number of errors / warnings messages and the total
|
149 |
+
# number of statements analyzed. This is used by the global evaluation report
|
150 |
+
# (RP0004).
|
151 |
+
evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
|
152 |
+
|
153 |
+
# Template used to display messages. This is a python new-style format string
|
154 |
+
# used to format the message information. See doc for all details
|
155 |
+
#msg-template=
|
156 |
+
|
157 |
+
|
158 |
+
[BASIC]
|
159 |
+
|
160 |
+
# Good variable names which should always be accepted, separated by a comma
|
161 |
+
good-names=main,_
|
162 |
+
|
163 |
+
# Bad variable names which should always be refused, separated by a comma
|
164 |
+
bad-names=
|
165 |
+
|
166 |
+
# Colon-delimited sets of names that determine each other's naming style when
|
167 |
+
# the name regexes allow several styles.
|
168 |
+
name-group=
|
169 |
+
|
170 |
+
# Include a hint for the correct naming format with invalid-name
|
171 |
+
include-naming-hint=no
|
172 |
+
|
173 |
+
# List of decorators that produce properties, such as abc.abstractproperty. Add
|
174 |
+
# to this list to register other decorators that produce valid properties.
|
175 |
+
property-classes=abc.abstractproperty,cached_property.cached_property,cached_property.threaded_cached_property,cached_property.cached_property_with_ttl,cached_property.threaded_cached_property_with_ttl
|
176 |
+
|
177 |
+
# Regular expression matching correct function names
|
178 |
+
function-rgx=^(?:(?P<exempt>setUp|tearDown|setUpModule|tearDownModule)|(?P<camel_case>_?[A-Z][a-zA-Z0-9]*)|(?P<snake_case>_?[a-z][a-z0-9_]*))$
|
179 |
+
|
180 |
+
# Regular expression matching correct variable names
|
181 |
+
variable-rgx=^[a-z][a-z0-9_]*$
|
182 |
+
|
183 |
+
# Regular expression matching correct constant names
|
184 |
+
const-rgx=^(_?[A-Z][A-Z0-9_]*|__[a-z0-9_]+__|_?[a-z][a-z0-9_]*)$
|
185 |
+
|
186 |
+
# Regular expression matching correct attribute names
|
187 |
+
attr-rgx=^_{0,2}[a-z][a-z0-9_]*$
|
188 |
+
|
189 |
+
# Regular expression matching correct argument names
|
190 |
+
argument-rgx=^[a-z][a-z0-9_]*$
|
191 |
+
|
192 |
+
# Regular expression matching correct class attribute names
|
193 |
+
class-attribute-rgx=^(_?[A-Z][A-Z0-9_]*|__[a-z0-9_]+__|_?[a-z][a-z0-9_]*)$
|
194 |
+
|
195 |
+
# Regular expression matching correct inline iteration names
|
196 |
+
inlinevar-rgx=^[a-z][a-z0-9_]*$
|
197 |
+
|
198 |
+
# Regular expression matching correct class names
|
199 |
+
class-rgx=^_?[A-Z][a-zA-Z0-9]*$
|
200 |
+
|
201 |
+
# Regular expression matching correct module names
|
202 |
+
module-rgx=^(_?[a-z][a-z0-9_]*|__init__)$
|
203 |
+
|
204 |
+
# Regular expression matching correct method names
|
205 |
+
method-rgx=(?x)^(?:(?P<exempt>_[a-z0-9_]+__|runTest|setUp|tearDown|setUpTestCase|tearDownTestCase|setupSelf|tearDownClass|setUpClass|(test|assert)_*[A-Z0-9][a-zA-Z0-9_]*|next)|(?P<camel_case>_{0,2}[A-Z][a-zA-Z0-9_]*)|(?P<snake_case>_{0,2}[a-z][a-z0-9_]*))$
|
206 |
+
|
207 |
+
# Regular expression which should only match function or class names that do
|
208 |
+
# not require a docstring.
|
209 |
+
no-docstring-rgx=(__.*__|main|test.*|.*test|.*Test)$
|
210 |
+
|
211 |
+
# Minimum line length for functions/classes that require docstrings, shorter
|
212 |
+
# ones are exempt.
|
213 |
+
docstring-min-length=12
|
214 |
+
|
215 |
+
|
216 |
+
[TYPECHECK]
|
217 |
+
|
218 |
+
# List of decorators that produce context managers, such as
|
219 |
+
# contextlib.contextmanager. Add to this list to register other decorators that
|
220 |
+
# produce valid context managers.
|
221 |
+
contextmanager-decorators=contextlib.contextmanager,contextlib2.contextmanager
|
222 |
+
|
223 |
+
# List of module names for which member attributes should not be checked
|
224 |
+
# (useful for modules/projects where namespaces are manipulated during runtime
|
225 |
+
# and thus existing member attributes cannot be deduced by static analysis. It
|
226 |
+
# supports qualified module names, as well as Unix pattern matching.
|
227 |
+
ignored-modules=
|
228 |
+
|
229 |
+
# List of class names for which member attributes should not be checked (useful
|
230 |
+
# for classes with dynamically set attributes). This supports the use of
|
231 |
+
# qualified names.
|
232 |
+
ignored-classes=optparse.Values,thread._local,_thread._local
|
233 |
+
|
234 |
+
# List of members which are set dynamically and missed by pylint inference
|
235 |
+
# system, and so shouldn't trigger E1101 when accessed. Python regular
|
236 |
+
# expressions are accepted.
|
237 |
+
generated-members=
|
238 |
+
|
239 |
+
|
240 |
+
[FORMAT]
|
241 |
+
|
242 |
+
# Maximum number of characters on a single line.
|
243 |
+
max-line-length=80
|
244 |
+
|
245 |
+
# TODO(https://github.com/pylint-dev/pylint/issues/3352): Direct pylint to exempt
|
246 |
+
# lines made too long by directives to pytype.
|
247 |
+
|
248 |
+
# Regexp for a line that is allowed to be longer than the limit.
|
249 |
+
ignore-long-lines=(?x)(
|
250 |
+
^\s*(\#\ )?<?https?://\S+>?$|
|
251 |
+
^\s*(from\s+\S+\s+)?import\s+.+$)
|
252 |
+
|
253 |
+
# Allow the body of an if to be on the same line as the test if there is no
|
254 |
+
# else.
|
255 |
+
single-line-if-stmt=yes
|
256 |
+
|
257 |
+
# Maximum number of lines in a module
|
258 |
+
max-module-lines=99999
|
259 |
+
|
260 |
+
# String used as indentation unit. The internal Google style guide mandates 2
|
261 |
+
# spaces. Google's externaly-published style guide says 4, consistent with
|
262 |
+
# PEP 8. Here, we use 2 spaces, for conformity with many open-sourced Google
|
263 |
+
# projects (like TensorFlow).
|
264 |
+
indent-string=' '
|
265 |
+
|
266 |
+
# Number of spaces of indent required inside a hanging or continued line.
|
267 |
+
indent-after-paren=4
|
268 |
+
|
269 |
+
# Expected format of line ending, e.g. empty (any line ending), LF or CRLF.
|
270 |
+
expected-line-ending-format=
|
271 |
+
|
272 |
+
|
273 |
+
[MISCELLANEOUS]
|
274 |
+
|
275 |
+
# List of note tags to take in consideration, separated by a comma.
|
276 |
+
notes=TODO
|
277 |
+
|
278 |
+
|
279 |
+
[STRING]
|
280 |
+
|
281 |
+
# This flag controls whether inconsistent-quotes generates a warning when the
|
282 |
+
# character used as a quote delimiter is used inconsistently within a module.
|
283 |
+
check-quote-consistency=yes
|
284 |
+
|
285 |
+
|
286 |
+
[VARIABLES]
|
287 |
+
|
288 |
+
# Tells whether we should check for unused import in __init__ files.
|
289 |
+
init-import=no
|
290 |
+
|
291 |
+
# A regular expression matching the name of dummy variables (i.e. expectedly
|
292 |
+
# not used).
|
293 |
+
dummy-variables-rgx=^\*{0,2}(_$|unused_|dummy_)
|
294 |
+
|
295 |
+
# List of additional names supposed to be defined in builtins. Remember that
|
296 |
+
# you should avoid to define new builtins when possible.
|
297 |
+
additional-builtins=
|
298 |
+
|
299 |
+
# List of strings which can identify a callback function by name. A callback
|
300 |
+
# name must start or end with one of those strings.
|
301 |
+
callbacks=cb_,_cb
|
302 |
+
|
303 |
+
# List of qualified module names which can have objects that can redefine
|
304 |
+
# builtins.
|
305 |
+
redefining-builtins-modules=six,six.moves,past.builtins,future.builtins,functools
|
306 |
+
|
307 |
+
|
308 |
+
[LOGGING]
|
309 |
+
|
310 |
+
# Logging modules to check that the string format arguments are in logging
|
311 |
+
# function parameter format
|
312 |
+
logging-modules=logging,absl.logging,tensorflow.io.logging
|
313 |
+
|
314 |
+
|
315 |
+
[SIMILARITIES]
|
316 |
+
|
317 |
+
# Minimum lines number of a similarity.
|
318 |
+
min-similarity-lines=4
|
319 |
+
|
320 |
+
# Ignore comments when computing similarities.
|
321 |
+
ignore-comments=yes
|
322 |
+
|
323 |
+
# Ignore docstrings when computing similarities.
|
324 |
+
ignore-docstrings=yes
|
325 |
+
|
326 |
+
# Ignore imports when computing similarities.
|
327 |
+
ignore-imports=no
|
328 |
+
|
329 |
+
|
330 |
+
[SPELLING]
|
331 |
+
|
332 |
+
# Spelling dictionary name. Available dictionaries: none. To make it working
|
333 |
+
# install python-enchant package.
|
334 |
+
spelling-dict=
|
335 |
+
|
336 |
+
# List of comma separated words that should not be checked.
|
337 |
+
spelling-ignore-words=
|
338 |
+
|
339 |
+
# A path to a file that contains private dictionary; one word per line.
|
340 |
+
spelling-private-dict-file=
|
341 |
+
|
342 |
+
# Tells whether to store unknown words to indicated private dictionary in
|
343 |
+
# --spelling-private-dict-file option instead of raising a message.
|
344 |
+
spelling-store-unknown-words=no
|
345 |
+
|
346 |
+
|
347 |
+
[IMPORTS]
|
348 |
+
|
349 |
+
# Deprecated modules which should not be used, separated by a comma
|
350 |
+
deprecated-modules=regsub,
|
351 |
+
TERMIOS,
|
352 |
+
Bastion,
|
353 |
+
rexec,
|
354 |
+
sets
|
355 |
+
|
356 |
+
# Create a graph of every (i.e. internal and external) dependencies in the
|
357 |
+
# given file (report RP0402 must not be disabled)
|
358 |
+
import-graph=
|
359 |
+
|
360 |
+
# Create a graph of external dependencies in the given file (report RP0402 must
|
361 |
+
# not be disabled)
|
362 |
+
ext-import-graph=
|
363 |
+
|
364 |
+
# Create a graph of internal dependencies in the given file (report RP0402 must
|
365 |
+
# not be disabled)
|
366 |
+
int-import-graph=
|
367 |
+
|
368 |
+
# Force import order to recognize a module as part of the standard
|
369 |
+
# compatibility libraries.
|
370 |
+
known-standard-library=
|
371 |
+
|
372 |
+
# Force import order to recognize a module as part of a third party library.
|
373 |
+
known-third-party=enchant, absl
|
374 |
+
|
375 |
+
# Analyse import fallback blocks. This can be used to support both Python 2 and
|
376 |
+
# 3 compatible code, which means that the block might have code that exists
|
377 |
+
# only in one or another interpreter, leading to false positives when analysed.
|
378 |
+
analyse-fallback-blocks=no
|
379 |
+
|
380 |
+
|
381 |
+
[CLASSES]
|
382 |
+
|
383 |
+
# List of method names used to declare (i.e. assign) instance attributes.
|
384 |
+
defining-attr-methods=__init__,
|
385 |
+
__new__,
|
386 |
+
setUp
|
387 |
+
|
388 |
+
# List of member names, which should be excluded from the protected access
|
389 |
+
# warning.
|
390 |
+
exclude-protected=_asdict,
|
391 |
+
_fields,
|
392 |
+
_replace,
|
393 |
+
_source,
|
394 |
+
_make
|
395 |
+
|
396 |
+
# List of valid names for the first argument in a class method.
|
397 |
+
valid-classmethod-first-arg=cls,
|
398 |
+
class_
|
399 |
+
|
400 |
+
# List of valid names for the first argument in a metaclass class method.
|
401 |
+
valid-metaclass-classmethod-first-arg=mcs
|
.style.yapf
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
[style]
|
2 |
+
based_on_style = google
|
3 |
+
indent_width = 2
|
.vscode/extensions.json
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"recommendations": [
|
3 |
+
"ms-python.isort",
|
4 |
+
"ms-python.pylint",
|
5 |
+
"eeyore.yapf",
|
6 |
+
"esbenp.prettier-vscode"
|
7 |
+
]
|
8 |
+
}
|
.vscode/settings.json
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"[json]": {
|
3 |
+
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
4 |
+
},
|
5 |
+
"[python]": {
|
6 |
+
"editor.defaultFormatter": "eeyore.yapf"
|
7 |
+
},
|
8 |
+
"yapf.args": ["--style", ".style.yapf"],
|
9 |
+
"pylint.args": ["--rcfile", ".pylintrc"],
|
10 |
+
"isort.args": ["--settings-file", ".isort.cfg"],
|
11 |
+
"editor.formatOnSave": true,
|
12 |
+
"editor.codeActionsOnSave": {
|
13 |
+
"source.organizeImports": "explicit"
|
14 |
+
}
|
15 |
+
}
|
README.md
CHANGED
@@ -1 +1,25 @@
|
|
1 |
# Arena
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
# Arena
|
2 |
+
|
3 |
+
## How to run locally
|
4 |
+
|
5 |
+
1. **Set up a virtual environment**
|
6 |
+
|
7 |
+
Before installing dependencies, it's recommended to create a virtual environment.
|
8 |
+
|
9 |
+
1. **Install dependencies**
|
10 |
+
|
11 |
+
With the virtual environment activated, install the project dependencies:
|
12 |
+
|
13 |
+
```shell
|
14 |
+
pip install -r requirements.txt
|
15 |
+
```
|
16 |
+
|
17 |
+
1. **Run the app**
|
18 |
+
|
19 |
+
Set your OpenAI API key as an environment variable and start the application:
|
20 |
+
|
21 |
+
```shell
|
22 |
+
GCP_PROJECT_ID=<your project id> OPENAI_API_KEY=<your key> python3 app.py
|
23 |
+
```
|
24 |
+
|
25 |
+
Replace <your project id> and <your key> with your GCP project ID and OpenAI API key respectively.
|
app.py
ADDED
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
It provides a platform for comparing the responses of two LLMs.
|
3 |
+
"""
|
4 |
+
|
5 |
+
from random import sample
|
6 |
+
|
7 |
+
from fastchat.serve import gradio_web_server
|
8 |
+
from fastchat.serve.gradio_web_server import bot_response
|
9 |
+
import gradio as gr
|
10 |
+
|
11 |
+
# TODO(#1): Add more models.
|
12 |
+
SUPPORTED_MODELS = ["gpt-4", "gpt-4-turbo", "gpt-3.5-turbo", "gemini-pro"]
|
13 |
+
|
14 |
+
|
15 |
+
def user(user_prompt):
|
16 |
+
model_pair = sample(SUPPORTED_MODELS, 2)
|
17 |
+
new_state_a = gradio_web_server.State(model_pair[0])
|
18 |
+
new_state_b = gradio_web_server.State(model_pair[1])
|
19 |
+
|
20 |
+
for state in [new_state_a, new_state_b]:
|
21 |
+
state.conv.append_message(state.conv.roles[0], user_prompt)
|
22 |
+
state.conv.append_message(state.conv.roles[1], None)
|
23 |
+
state.skip_next = False
|
24 |
+
|
25 |
+
return [
|
26 |
+
new_state_a, new_state_b, new_state_a.model_name, new_state_b.model_name
|
27 |
+
]
|
28 |
+
|
29 |
+
|
30 |
+
def bot(state_a, state_b, request: gr.Request):
|
31 |
+
new_states = [state_a, state_b]
|
32 |
+
|
33 |
+
generators = []
|
34 |
+
for state in new_states:
|
35 |
+
try:
|
36 |
+
# TODO(#1): Allow user to set configuration.
|
37 |
+
# bot_response returns a generator yielding states.
|
38 |
+
generator = bot_response(state,
|
39 |
+
temperature=0.9,
|
40 |
+
top_p=0.9,
|
41 |
+
max_new_tokens=100,
|
42 |
+
request=request)
|
43 |
+
generators.append(generator)
|
44 |
+
|
45 |
+
# TODO(#1): Narrow down the exception type.
|
46 |
+
except Exception as e: # pylint: disable=broad-except
|
47 |
+
print(f"Error in bot_response: {e}")
|
48 |
+
raise e
|
49 |
+
|
50 |
+
new_responses = [None, None]
|
51 |
+
|
52 |
+
# It simulates concurrent response generation from two models.
|
53 |
+
while True:
|
54 |
+
stop = True
|
55 |
+
|
56 |
+
for i in range(len(generators)):
|
57 |
+
try:
|
58 |
+
yielded = next(generators[i])
|
59 |
+
|
60 |
+
# The generator yields a tuple, with the new state as the first item.
|
61 |
+
new_state = yielded[0]
|
62 |
+
new_states[i] = new_state
|
63 |
+
|
64 |
+
# The last item from 'messages' represents the response to the prompt.
|
65 |
+
bot_message = new_state.conv.messages[-1]
|
66 |
+
|
67 |
+
# Each message in conv.messages is structured as [role, message],
|
68 |
+
# so we extract the last message component.
|
69 |
+
new_responses[i] = bot_message[-1]
|
70 |
+
|
71 |
+
stop = False
|
72 |
+
|
73 |
+
except StopIteration:
|
74 |
+
pass
|
75 |
+
|
76 |
+
# TODO(#1): Narrow down the exception type.
|
77 |
+
except Exception as e: # pylint: disable=broad-except
|
78 |
+
print(f"Error in generator: {e}")
|
79 |
+
raise e
|
80 |
+
|
81 |
+
yield new_states + new_responses
|
82 |
+
|
83 |
+
if stop:
|
84 |
+
break
|
85 |
+
|
86 |
+
|
87 |
+
with gr.Blocks() as app:
|
88 |
+
model_names = [gr.State(None), gr.State(None)]
|
89 |
+
responses = [gr.State(None), gr.State(None)]
|
90 |
+
|
91 |
+
# states stores FastChat-specific conversation states.
|
92 |
+
states = [gr.State(None), gr.State(None)]
|
93 |
+
|
94 |
+
prompt = gr.TextArea(label="Prompt", lines=4)
|
95 |
+
submit = gr.Button()
|
96 |
+
|
97 |
+
with gr.Row():
|
98 |
+
responses[0] = gr.Textbox(label="Model A", interactive=False)
|
99 |
+
responses[1] = gr.Textbox(label="Model B", interactive=False)
|
100 |
+
|
101 |
+
with gr.Accordion("Show models", open=False):
|
102 |
+
with gr.Row():
|
103 |
+
model_names[0] = gr.Textbox(label="Model A", interactive=False)
|
104 |
+
model_names[1] = gr.Textbox(label="Model B", interactive=False)
|
105 |
+
|
106 |
+
submit.click(user, prompt, states + model_names,
|
107 |
+
queue=False).then(bot, states, states + responses)
|
108 |
+
|
109 |
+
if __name__ == "__main__":
|
110 |
+
# We need to enable queue to use generators.
|
111 |
+
app.queue()
|
112 |
+
app.launch(debug=True)
|
requirments.txt
ADDED
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
accelerate==0.26.1
|
2 |
+
aiofiles==23.2.1
|
3 |
+
aiohttp==3.9.3
|
4 |
+
aiosignal==1.3.1
|
5 |
+
altair==5.2.0
|
6 |
+
annotated-types==0.6.0
|
7 |
+
anyio==4.2.0
|
8 |
+
attrs==23.2.0
|
9 |
+
cachetools==5.3.2
|
10 |
+
certifi==2023.11.17
|
11 |
+
charset-normalizer==3.3.2
|
12 |
+
click==8.1.7
|
13 |
+
colorama==0.4.6
|
14 |
+
contourpy==1.2.0
|
15 |
+
cycler==0.12.1
|
16 |
+
distro==1.9.0
|
17 |
+
fastapi==0.109.0
|
18 |
+
ffmpy==0.3.1
|
19 |
+
filelock==3.13.1
|
20 |
+
fonttools==4.47.2
|
21 |
+
frozenlist==1.4.1
|
22 |
+
fschat==0.2.35
|
23 |
+
fsspec==2023.12.2
|
24 |
+
google-api-core==2.16.1
|
25 |
+
google-auth==2.27.0
|
26 |
+
google-cloud-aiplatform==1.40.0
|
27 |
+
google-cloud-bigquery==3.17.1
|
28 |
+
google-cloud-core==2.4.1
|
29 |
+
google-cloud-resource-manager==1.11.0
|
30 |
+
google-cloud-storage==2.14.0
|
31 |
+
google-crc32c==1.5.0
|
32 |
+
google-resumable-media==2.7.0
|
33 |
+
googleapis-common-protos==1.62.0
|
34 |
+
gradio==3.50.2
|
35 |
+
gradio_client==0.6.1
|
36 |
+
grpc-google-iam-v1==0.13.0
|
37 |
+
grpcio==1.60.0
|
38 |
+
grpcio-status==1.60.0
|
39 |
+
h11==0.14.0
|
40 |
+
httpcore==1.0.2
|
41 |
+
httpx==0.26.0
|
42 |
+
huggingface-hub==0.20.3
|
43 |
+
idna==3.6
|
44 |
+
importlib-resources==6.1.1
|
45 |
+
Jinja2==3.1.3
|
46 |
+
jsonschema==4.21.1
|
47 |
+
jsonschema-specifications==2023.12.1
|
48 |
+
kiwisolver==1.4.5
|
49 |
+
markdown-it-py==3.0.0
|
50 |
+
markdown2==2.4.12
|
51 |
+
MarkupSafe==2.1.4
|
52 |
+
matplotlib==3.8.2
|
53 |
+
mdurl==0.1.2
|
54 |
+
mpmath==1.3.0
|
55 |
+
multidict==6.0.4
|
56 |
+
networkx==3.2.1
|
57 |
+
nh3==0.2.15
|
58 |
+
numpy==1.26.3
|
59 |
+
openai==0.28.0
|
60 |
+
orjson==3.9.12
|
61 |
+
packaging==23.2
|
62 |
+
pandas==2.2.0
|
63 |
+
peft==0.8.1
|
64 |
+
pillow==10.2.0
|
65 |
+
prompt-toolkit==3.0.43
|
66 |
+
proto-plus==1.23.0
|
67 |
+
protobuf==4.25.2
|
68 |
+
psutil==5.9.8
|
69 |
+
pyasn1==0.5.1
|
70 |
+
pyasn1-modules==0.3.0
|
71 |
+
pydantic==1.10.14
|
72 |
+
pydantic_core==2.16.1
|
73 |
+
pydub==0.25.1
|
74 |
+
Pygments==2.17.2
|
75 |
+
pyparsing==3.1.1
|
76 |
+
python-dateutil==2.8.2
|
77 |
+
python-multipart==0.0.6
|
78 |
+
pytz==2023.4
|
79 |
+
PyYAML==6.0.1
|
80 |
+
referencing==0.33.0
|
81 |
+
regex==2023.12.25
|
82 |
+
requests==2.31.0
|
83 |
+
rich==13.7.0
|
84 |
+
rpds-py==0.17.1
|
85 |
+
rsa==4.9
|
86 |
+
ruff==0.1.15
|
87 |
+
safetensors==0.4.2
|
88 |
+
semantic-version==2.10.0
|
89 |
+
sentencepiece==0.1.99
|
90 |
+
shapely==2.0.2
|
91 |
+
shellingham==1.5.4
|
92 |
+
shortuuid==1.0.11
|
93 |
+
six==1.16.0
|
94 |
+
sniffio==1.3.0
|
95 |
+
starlette==0.35.1
|
96 |
+
svgwrite==1.4.3
|
97 |
+
sympy==1.12
|
98 |
+
tiktoken==0.5.2
|
99 |
+
tokenizers==0.15.1
|
100 |
+
tomlkit==0.12.0
|
101 |
+
toolz==0.12.1
|
102 |
+
torch==2.2.0
|
103 |
+
tqdm==4.66.1
|
104 |
+
transformers==4.37.2
|
105 |
+
typer==0.9.0
|
106 |
+
typing_extensions==4.9.0
|
107 |
+
tzdata==2023.4
|
108 |
+
urllib3==2.2.0
|
109 |
+
uvicorn==0.27.0.post1
|
110 |
+
wavedrom==2.0.3.post3
|
111 |
+
wcwidth==0.2.13
|
112 |
+
websockets==11.0.3
|
113 |
+
yarl==1.9.4
|