Spaces:
Runtime error
Runtime error
langchain
Browse files- gradio_llm_example.py +8 -2
gradio_llm_example.py
CHANGED
@@ -6,7 +6,14 @@ import shutil
|
|
6 |
# How to RUN code ==> gradio gradio_llm_example.py
|
7 |
|
8 |
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
# Define text and title information
|
12 |
title1 = "## </br> </br> </br> π€π¬ QA App"
|
@@ -96,7 +103,6 @@ def read_content(content, files_name):
|
|
96 |
my_content = str(content[:10])
|
97 |
content_list.append(my_content)
|
98 |
text_list.append(f"File {file_name} ready to be used. \n")
|
99 |
-
print(content)
|
100 |
except Exception as e:
|
101 |
print(f"Error occurred while writing the file: {e}")
|
102 |
text_list.append(f"Error occurred while writing the file {file_name}: {e}")
|
|
|
6 |
# How to RUN code ==> gradio gradio_llm_example.py
|
7 |
|
8 |
|
9 |
+
from langchain import HuggingFacePipeline
|
10 |
+
def load_llm_model(model: str = "google/flan-t5-large") -> HuggingFacePipeline:
|
11 |
+
llm = HuggingFacePipeline.from_model_id(
|
12 |
+
model_id=model,
|
13 |
+
task="text2text-generation",
|
14 |
+
model_kwargs={"max_length": 1500, "load_in_8bit": True},
|
15 |
+
)
|
16 |
+
return llm
|
17 |
|
18 |
# Define text and title information
|
19 |
title1 = "## </br> </br> </br> π€π¬ QA App"
|
|
|
103 |
my_content = str(content[:10])
|
104 |
content_list.append(my_content)
|
105 |
text_list.append(f"File {file_name} ready to be used. \n")
|
|
|
106 |
except Exception as e:
|
107 |
print(f"Error occurred while writing the file: {e}")
|
108 |
text_list.append(f"Error occurred while writing the file {file_name}: {e}")
|