Spaces:
Sleeping
Sleeping
Upload 3 files
Browse files- app.py +13 -2
- bot_backend.py +8 -7
- github-log.png +0 -0
app.py
CHANGED
|
@@ -131,7 +131,6 @@ if __name__ == '__main__':
|
|
| 131 |
)
|
| 132 |
with gr.Column(scale=0.15, min_width=0):
|
| 133 |
file_upload_button = gr.UploadButton("📁", file_types=['file'])
|
| 134 |
-
|
| 135 |
with gr.Row(equal_height=True):
|
| 136 |
with gr.Column(scale=0.7):
|
| 137 |
check_box = gr.Checkbox(label="Use GPT-4", interactive=config['model']['GPT-4']['available'])
|
|
@@ -142,6 +141,18 @@ if __name__ == '__main__':
|
|
| 142 |
undo_file_button = gr.Button(value="↩️Undo upload file", interactive=False)
|
| 143 |
with gr.Tab("Files"):
|
| 144 |
file_output = gr.Files()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
|
| 146 |
# Components function binding
|
| 147 |
txt_msg = text_box.submit(add_text, [state, chatbot, text_box], [chatbot, text_box], queue=False).then(
|
|
@@ -181,4 +192,4 @@ if __name__ == '__main__':
|
|
| 181 |
block.load(fn=initialization, inputs=[state])
|
| 182 |
|
| 183 |
block.queue()
|
| 184 |
-
block.launch(inbrowser=True)
|
|
|
|
| 131 |
)
|
| 132 |
with gr.Column(scale=0.15, min_width=0):
|
| 133 |
file_upload_button = gr.UploadButton("📁", file_types=['file'])
|
|
|
|
| 134 |
with gr.Row(equal_height=True):
|
| 135 |
with gr.Column(scale=0.7):
|
| 136 |
check_box = gr.Checkbox(label="Use GPT-4", interactive=config['model']['GPT-4']['available'])
|
|
|
|
| 141 |
undo_file_button = gr.Button(value="↩️Undo upload file", interactive=False)
|
| 142 |
with gr.Tab("Files"):
|
| 143 |
file_output = gr.Files()
|
| 144 |
+
gr.Markdown(
|
| 145 |
+
'''
|
| 146 |
+
<center>
|
| 147 |
+
<a href="https://github.com/MrGreyfun/Local-Code-Interpreter">
|
| 148 |
+
<img src="file=github-log.png" width="2.5%">
|
| 149 |
+
<br>
|
| 150 |
+
Open source on GitHub
|
| 151 |
+
</a>
|
| 152 |
+
</center>
|
| 153 |
+
'''
|
| 154 |
+
)
|
| 155 |
+
|
| 156 |
|
| 157 |
# Components function binding
|
| 158 |
txt_msg = text_box.submit(add_text, [state, chatbot, text_box], [chatbot, text_box], queue=False).then(
|
|
|
|
| 192 |
block.load(fn=initialization, inputs=[state])
|
| 193 |
|
| 194 |
block.queue()
|
| 195 |
+
block.launch(inbrowser=True)
|
bot_backend.py
CHANGED
|
@@ -37,10 +37,15 @@ You should:
|
|
| 37 |
|
| 38 |
Note: If the user uploads a file, you will receive a system message "User uploaded a file: filename". Use the filename as the path in the code. '''
|
| 39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
def get_config():
|
| 42 |
-
with open('config.json') as f:
|
| 43 |
-
config = json.load(f)
|
| 44 |
return config
|
| 45 |
|
| 46 |
|
|
@@ -125,11 +130,7 @@ class BotBackend(GPTResponseLog):
|
|
| 125 |
api_type = self.config['API_TYPE']
|
| 126 |
api_base = self.config['API_base']
|
| 127 |
api_version = self.config['API_VERSION']
|
| 128 |
-
|
| 129 |
-
api_key = self.config['API_KEY']
|
| 130 |
-
else:
|
| 131 |
-
api_key = os.getenv('OPENAI_API_KEY')
|
| 132 |
-
|
| 133 |
config_openai_api(api_type, api_base, api_version, api_key)
|
| 134 |
|
| 135 |
def _init_kwargs_for_chat_completion(self):
|
|
|
|
| 37 |
|
| 38 |
Note: If the user uploads a file, you will receive a system message "User uploaded a file: filename". Use the filename as the path in the code. '''
|
| 39 |
|
| 40 |
+
with open('config.json') as f:
|
| 41 |
+
config = json.load(f)
|
| 42 |
+
|
| 43 |
+
if not config['API_KEY']:
|
| 44 |
+
config['API_KEY'] = os.getenv('OPENAI_API_KEY')
|
| 45 |
+
os.unsetenv('OPENAI_API_KEY')
|
| 46 |
+
|
| 47 |
|
| 48 |
def get_config():
|
|
|
|
|
|
|
| 49 |
return config
|
| 50 |
|
| 51 |
|
|
|
|
| 130 |
api_type = self.config['API_TYPE']
|
| 131 |
api_base = self.config['API_base']
|
| 132 |
api_version = self.config['API_VERSION']
|
| 133 |
+
api_key = config['API_KEY']
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
config_openai_api(api_type, api_base, api_version, api_key)
|
| 135 |
|
| 136 |
def _init_kwargs_for_chat_completion(self):
|
github-log.png
ADDED
|