Spaces:
Running
Running
suhyun.kang
commited on
Commit
•
73e8b86
1
Parent(s):
93a104a
[#1] Implement side-by-side chatbot interface
Browse filesChanges:
- Added a UI for the side-by-side chatbot using Gradio (https://www.gradio.app/)
- Integrated OpenAI models using FastChat (https://github.com/lm-sys/FastChat)
Screenshot: https://screen.yanolja.in/zWOvXcSVBamqm4sw.png
- .gitignore +1 -0
- .isort.cfg +2 -0
- .pylintrc +401 -0
- .style.yapf +3 -0
- .vscode/extensions.json +7 -0
- .vscode/settings.json +12 -0
- README.md +24 -0
- app.py +105 -0
- requirments.txt +94 -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,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"recommendations": [
|
3 |
+
"ms-python.isort",
|
4 |
+
"ms-python.pylint",
|
5 |
+
"eeyore.yapf"
|
6 |
+
]
|
7 |
+
}
|
.vscode/settings.json
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"[python]": {
|
3 |
+
"editor.defaultFormatter": "eeyore.yapf"
|
4 |
+
},
|
5 |
+
"yapf.args": ["--style", ".style.yapf"],
|
6 |
+
"pylint.args": ["--rcfile", ".pylintrc"],
|
7 |
+
"isort.args": ["--settings-file", ".isort.cfg"],
|
8 |
+
"editor.formatOnSave": true,
|
9 |
+
"editor.codeActionsOnSave": {
|
10 |
+
"source.organizeImports": "explicit"
|
11 |
+
},
|
12 |
+
}
|
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 |
+
OPENAI_API_KEY=<your key> python3 app.py
|
23 |
+
```
|
24 |
+
|
25 |
+
Replace <your key> with your actual OpenAI API key.
|
app.py
ADDED
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from random import sample
|
2 |
+
|
3 |
+
import gradio as gr
|
4 |
+
from fastchat.serve import gradio_web_server
|
5 |
+
from fastchat.serve.gradio_web_server import bot_response
|
6 |
+
|
7 |
+
# TODO(#1): Add more models.
|
8 |
+
SUPPORTED_MODELS = ["gpt-4", "gpt-4-turbo", "gpt-3.5-turbo"]
|
9 |
+
|
10 |
+
|
11 |
+
def user(state_a, state_b, user_message):
|
12 |
+
if state_a is None and state_b is None:
|
13 |
+
model_pair = sample(SUPPORTED_MODELS, 2)
|
14 |
+
state_a = gradio_web_server.State(model_pair[0])
|
15 |
+
state_b = gradio_web_server.State(model_pair[1])
|
16 |
+
|
17 |
+
for state in [state_a, state_b]:
|
18 |
+
state.conv.append_message(state.conv.roles[0], user_message)
|
19 |
+
state.conv.append_message(state.conv.roles[1], None)
|
20 |
+
state.skip_next = False
|
21 |
+
|
22 |
+
empty_prompt = ""
|
23 |
+
|
24 |
+
return [
|
25 |
+
state_a, state_b,
|
26 |
+
state_a.to_gradio_chatbot(),
|
27 |
+
state_b.to_gradio_chatbot(), state_a.model_name, state_b.model_name,
|
28 |
+
empty_prompt
|
29 |
+
]
|
30 |
+
|
31 |
+
|
32 |
+
def bot(state_a, state_b, request: gr.Request):
|
33 |
+
if state_a is None or state_b is None:
|
34 |
+
raise RuntimeError(f"states cannot be None, got [{state_a}, {state_b}]")
|
35 |
+
|
36 |
+
generators = []
|
37 |
+
for state in [state_a, state_b]:
|
38 |
+
try:
|
39 |
+
# TODO(#1): Allow user to set configuration.
|
40 |
+
# bot_response returns a generator yielding states and chatbots.
|
41 |
+
generator = bot_response(state,
|
42 |
+
temperature=0.9,
|
43 |
+
top_p=0.9,
|
44 |
+
max_new_tokens=100,
|
45 |
+
request=request)
|
46 |
+
generators.append(generator)
|
47 |
+
|
48 |
+
# TODO(#1): Narrow down the exception type.
|
49 |
+
except Exception as e: # pylint: disable=broad-except
|
50 |
+
print(f"Error in bot_response: {e}")
|
51 |
+
raise e
|
52 |
+
|
53 |
+
new_chatbots = [None, None]
|
54 |
+
while True:
|
55 |
+
stop = True
|
56 |
+
|
57 |
+
for i in range(2):
|
58 |
+
try:
|
59 |
+
generator = next(generators[i])
|
60 |
+
states[i], new_chatbots[i] = generator[0], generator[1]
|
61 |
+
stop = False
|
62 |
+
except StopIteration:
|
63 |
+
pass
|
64 |
+
|
65 |
+
yield [state_a, state_b] + new_chatbots
|
66 |
+
|
67 |
+
if stop:
|
68 |
+
break
|
69 |
+
|
70 |
+
|
71 |
+
with gr.Blocks() as app:
|
72 |
+
with gr.Row():
|
73 |
+
response_type = gr.Radio(
|
74 |
+
["Summarization", "Translation"],
|
75 |
+
value="Summarization",
|
76 |
+
label="Response type",
|
77 |
+
info="Choose the type of response you want from the model.")
|
78 |
+
language = gr.Dropdown(["Korean", "English"],
|
79 |
+
value="Korean",
|
80 |
+
label="Language",
|
81 |
+
info="Choose the target language.")
|
82 |
+
|
83 |
+
chatbots = [None, None]
|
84 |
+
with gr.Row():
|
85 |
+
chatbots[0] = gr.Chatbot(label="Model A")
|
86 |
+
chatbots[1] = gr.Chatbot(label="Model B")
|
87 |
+
|
88 |
+
model_names = [None, None]
|
89 |
+
with gr.Accordion("Show models", open=False):
|
90 |
+
with gr.Row():
|
91 |
+
model_names[0] = gr.Textbox(label="Model A", interactive=False)
|
92 |
+
model_names[1] = gr.Textbox(label="Model B", interactive=False)
|
93 |
+
|
94 |
+
prompt = gr.Textbox(label="Prompt")
|
95 |
+
|
96 |
+
states = [gr.State(None), gr.State(None)]
|
97 |
+
prompt.submit(user,
|
98 |
+
states + [prompt],
|
99 |
+
states + chatbots + model_names + [prompt],
|
100 |
+
queue=False).then(bot, states, states + chatbots)
|
101 |
+
|
102 |
+
if __name__ == "__main__":
|
103 |
+
# We need to enable queue to use generators.
|
104 |
+
app.queue()
|
105 |
+
app.launch()
|
requirments.txt
ADDED
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
certifi==2023.11.17
|
10 |
+
charset-normalizer==3.3.2
|
11 |
+
click==8.1.7
|
12 |
+
colorama==0.4.6
|
13 |
+
contourpy==1.2.0
|
14 |
+
cycler==0.12.1
|
15 |
+
distro==1.9.0
|
16 |
+
fastapi==0.109.0
|
17 |
+
ffmpy==0.3.1
|
18 |
+
filelock==3.13.1
|
19 |
+
fonttools==4.47.2
|
20 |
+
frozenlist==1.4.1
|
21 |
+
fschat==0.2.35
|
22 |
+
fsspec==2023.12.2
|
23 |
+
gradio==3.50.2
|
24 |
+
gradio_client==0.6.1
|
25 |
+
h11==0.14.0
|
26 |
+
httpcore==1.0.2
|
27 |
+
httpx==0.26.0
|
28 |
+
huggingface-hub==0.20.3
|
29 |
+
idna==3.6
|
30 |
+
importlib-resources==6.1.1
|
31 |
+
Jinja2==3.1.3
|
32 |
+
jsonschema==4.21.1
|
33 |
+
jsonschema-specifications==2023.12.1
|
34 |
+
kiwisolver==1.4.5
|
35 |
+
markdown-it-py==3.0.0
|
36 |
+
markdown2==2.4.12
|
37 |
+
MarkupSafe==2.1.4
|
38 |
+
matplotlib==3.8.2
|
39 |
+
mdurl==0.1.2
|
40 |
+
mpmath==1.3.0
|
41 |
+
multidict==6.0.4
|
42 |
+
networkx==3.2.1
|
43 |
+
nh3==0.2.15
|
44 |
+
numpy==1.26.3
|
45 |
+
openai==1.10.0
|
46 |
+
orjson==3.9.12
|
47 |
+
packaging==23.2
|
48 |
+
pandas==2.2.0
|
49 |
+
peft==0.8.1
|
50 |
+
pillow==10.2.0
|
51 |
+
prompt-toolkit==3.0.43
|
52 |
+
protobuf==4.25.2
|
53 |
+
psutil==5.9.8
|
54 |
+
pydantic==1.10.14
|
55 |
+
pydantic_core==2.16.1
|
56 |
+
pydub==0.25.1
|
57 |
+
Pygments==2.17.2
|
58 |
+
pyparsing==3.1.1
|
59 |
+
python-dateutil==2.8.2
|
60 |
+
python-multipart==0.0.6
|
61 |
+
pytz==2023.4
|
62 |
+
PyYAML==6.0.1
|
63 |
+
referencing==0.33.0
|
64 |
+
regex==2023.12.25
|
65 |
+
requests==2.31.0
|
66 |
+
rich==13.7.0
|
67 |
+
rpds-py==0.17.1
|
68 |
+
ruff==0.1.15
|
69 |
+
safetensors==0.4.2
|
70 |
+
semantic-version==2.10.0
|
71 |
+
sentencepiece==0.1.99
|
72 |
+
shellingham==1.5.4
|
73 |
+
shortuuid==1.0.11
|
74 |
+
six==1.16.0
|
75 |
+
sniffio==1.3.0
|
76 |
+
starlette==0.35.1
|
77 |
+
svgwrite==1.4.3
|
78 |
+
sympy==1.12
|
79 |
+
tiktoken==0.5.2
|
80 |
+
tokenizers==0.15.1
|
81 |
+
tomlkit==0.12.0
|
82 |
+
toolz==0.12.1
|
83 |
+
torch==2.2.0
|
84 |
+
tqdm==4.66.1
|
85 |
+
transformers==4.37.2
|
86 |
+
typer==0.9.0
|
87 |
+
typing_extensions==4.9.0
|
88 |
+
tzdata==2023.4
|
89 |
+
urllib3==2.2.0
|
90 |
+
uvicorn==0.27.0.post1
|
91 |
+
wavedrom==2.0.3.post3
|
92 |
+
wcwidth==0.2.13
|
93 |
+
websockets==11.0.3
|
94 |
+
yarl==1.9.4
|