Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -9,9 +9,6 @@ import subprocess
|
|
9 |
|
10 |
#HUGGINGFACEHUB_API_TOKEN = os.environ["HUGGINGFACEHUB_API_TOKEN"]
|
11 |
|
12 |
-
config = CustomAppConfig(embedding_fn=EmbeddingFunctions.OPENAI, provider=Providers.OPENAI, embedding_fn_model="text-embedding-ada-002")
|
13 |
-
app = CustomApp(config)
|
14 |
-
|
15 |
class ContextCreator:
|
16 |
def __init__(self, app):
|
17 |
self.app = app
|
@@ -37,6 +34,13 @@ class ContextCreator:
|
|
37 |
if file.name.endswith('.docx'):
|
38 |
self.app.add(file.name, data_type='docx_file')
|
39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
def build_context(pdf_urls, docx_urls, youtube_urls, web_urls, sitemap_url, upload_files):
|
41 |
context_creator = ContextCreator(app)
|
42 |
context_creator.create_context(pdf_urls, docx_urls, youtube_urls, web_urls, sitemap_url, upload_files)
|
@@ -48,10 +52,6 @@ def llm_respond(query, chat_history):
|
|
48 |
time.sleep(2)
|
49 |
return "", chat_history
|
50 |
|
51 |
-
def environ_api_key(api_key):
|
52 |
-
os.environ["OPENAI_API_KEY"] = api_key
|
53 |
-
return "OpenAI API key set !"
|
54 |
-
|
55 |
def loading():
|
56 |
return "Loading..."
|
57 |
|
|
|
9 |
|
10 |
#HUGGINGFACEHUB_API_TOKEN = os.environ["HUGGINGFACEHUB_API_TOKEN"]
|
11 |
|
|
|
|
|
|
|
12 |
class ContextCreator:
|
13 |
def __init__(self, app):
|
14 |
self.app = app
|
|
|
34 |
if file.name.endswith('.docx'):
|
35 |
self.app.add(file.name, data_type='docx_file')
|
36 |
|
37 |
+
def environ_api_key(api_key):
|
38 |
+
global app
|
39 |
+
os.environ["OPENAI_API_KEY"] = api_key
|
40 |
+
config = CustomAppConfig(embedding_fn=EmbeddingFunctions.OPENAI, provider=Providers.OPENAI, embedding_fn_model="text-embedding-ada-002")
|
41 |
+
app = CustomApp(config)
|
42 |
+
return "OpenAI API key set !"
|
43 |
+
|
44 |
def build_context(pdf_urls, docx_urls, youtube_urls, web_urls, sitemap_url, upload_files):
|
45 |
context_creator = ContextCreator(app)
|
46 |
context_creator.create_context(pdf_urls, docx_urls, youtube_urls, web_urls, sitemap_url, upload_files)
|
|
|
52 |
time.sleep(2)
|
53 |
return "", chat_history
|
54 |
|
|
|
|
|
|
|
|
|
55 |
def loading():
|
56 |
return "Loading..."
|
57 |
|