Spaces:
Runtime error
Runtime error
jerome-white
commited on
Commit
·
53ebd47
1
Parent(s):
8d48750
Allow config to be read in all scopes
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import os
|
2 |
import json
|
|
|
3 |
import collections as cl
|
4 |
from pathlib import Path
|
5 |
|
@@ -18,12 +19,16 @@ from mylib import (
|
|
18 |
#
|
19 |
ChatState = cl.namedtuple('ChatState', 'database, messenger, chat')
|
20 |
|
|
|
|
|
|
|
|
|
|
|
21 |
#
|
22 |
#
|
23 |
#
|
24 |
def load():
|
25 |
-
|
26 |
-
config = json.load(fp)
|
27 |
(_openai, _chat) = map(config.get, ('openai', 'chat'))
|
28 |
client = OpenAI(api_key=_openai['api_key'])
|
29 |
|
@@ -105,5 +110,5 @@ with gr.Blocks() as demo:
|
|
105 |
)
|
106 |
|
107 |
if __name__ == '__main__':
|
108 |
-
|
109 |
-
demo.queue().launch(server_name='0.0.0.0')
|
|
|
1 |
import os
|
2 |
import json
|
3 |
+
import functools as ft
|
4 |
import collections as cl
|
5 |
from pathlib import Path
|
6 |
|
|
|
19 |
#
|
20 |
ChatState = cl.namedtuple('ChatState', 'database, messenger, chat')
|
21 |
|
22 |
+
@ft.cache
|
23 |
+
def scancfg():
|
24 |
+
with open(os.getenv('FILE_CHAT_CONFIG')) as fp:
|
25 |
+
return json.load(fp)
|
26 |
+
|
27 |
#
|
28 |
#
|
29 |
#
|
30 |
def load():
|
31 |
+
config = scancfg()
|
|
|
32 |
(_openai, _chat) = map(config.get, ('openai', 'chat'))
|
33 |
client = OpenAI(api_key=_openai['api_key'])
|
34 |
|
|
|
110 |
)
|
111 |
|
112 |
if __name__ == '__main__':
|
113 |
+
kwargs = scancfg().get('gradio')
|
114 |
+
demo.queue().launch(server_name='0.0.0.0', **kwargs)
|