Spaces:
Runtime error
Runtime error
ffreemt
commited on
Commit
•
86dc97a
1
Parent(s):
ce667dc
Update share=True for colab (import google.colab)
Browse files
app.py
CHANGED
@@ -4,7 +4,7 @@ and https://github.com/PromtEngineer/localGPT/blob/main/ingest.py
|
|
4 |
|
5 |
https://python.langchain.com/en/latest/getting_started/tutorials.html
|
6 |
"""
|
7 |
-
# pylint: disable=broad-exception-caught, unused-import, invalid-name, line-too-long, too-many-return-statements
|
8 |
import os
|
9 |
import time
|
10 |
from pathlib import Path
|
@@ -236,6 +236,7 @@ def ingest(
|
|
236 |
for doc in documents
|
237 |
]
|
238 |
|
|
|
239 |
# https://huggingface.co/TheBloke/vicuna-7B-1.1-HF
|
240 |
def gen_local_llm(model_id="TheBloke/vicuna-7B-1.1-HF"):
|
241 |
"""Gen a local llm.
|
@@ -310,7 +311,7 @@ def main():
|
|
310 |
openai_api_key = os.getenv("OPENAI_API_KEY")
|
311 |
logger.info(f"openai_api_key (hf space SECRETS/env): {openai_api_key}")
|
312 |
|
313 |
-
with gr.Blocks() as demo:
|
314 |
# name = gr.Textbox(label="Name")
|
315 |
# greet_btn = gr.Button("Submit")
|
316 |
# output = gr.Textbox(label="Output Box")
|
@@ -352,7 +353,14 @@ def main():
|
|
352 |
msg.submit(respond, [msg, chatbot], [msg, chatbot])
|
353 |
clear.click(lambda: None, None, chatbot, queue=False)
|
354 |
|
355 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
356 |
|
357 |
|
358 |
if __name__ == "__main__":
|
|
|
4 |
|
5 |
https://python.langchain.com/en/latest/getting_started/tutorials.html
|
6 |
"""
|
7 |
+
# pylint: disable=broad-exception-caught, unused-import, invalid-name, line-too-long, too-many-return-statements, import-outside-toplevel, no-name-in-module
|
8 |
import os
|
9 |
import time
|
10 |
from pathlib import Path
|
|
|
236 |
for doc in documents
|
237 |
]
|
238 |
|
239 |
+
|
240 |
# https://huggingface.co/TheBloke/vicuna-7B-1.1-HF
|
241 |
def gen_local_llm(model_id="TheBloke/vicuna-7B-1.1-HF"):
|
242 |
"""Gen a local llm.
|
|
|
311 |
openai_api_key = os.getenv("OPENAI_API_KEY")
|
312 |
logger.info(f"openai_api_key (hf space SECRETS/env): {openai_api_key}")
|
313 |
|
314 |
+
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
315 |
# name = gr.Textbox(label="Name")
|
316 |
# greet_btn = gr.Button("Submit")
|
317 |
# output = gr.Textbox(label="Output Box")
|
|
|
353 |
msg.submit(respond, [msg, chatbot], [msg, chatbot])
|
354 |
clear.click(lambda: None, None, chatbot, queue=False)
|
355 |
|
356 |
+
try:
|
357 |
+
from google import colab
|
358 |
+
|
359 |
+
share = True # start share when in colab
|
360 |
+
except Exception:
|
361 |
+
share = False
|
362 |
+
|
363 |
+
demo.launch(share=share)
|
364 |
|
365 |
|
366 |
if __name__ == "__main__":
|