Spaces:
Sleeping
Sleeping
ASledziewska
commited on
Commit
•
ab8f613
1
Parent(s):
8465f96
Update llm_response_generator.py
Browse files
llm_response_generator.py
CHANGED
@@ -1,4 +1,6 @@
|
|
1 |
import os
|
|
|
|
|
2 |
from langchain_community.llms import HuggingFaceHub
|
3 |
from langchain_community.llms import OpenAI
|
4 |
# from langchain.llms import HuggingFaceHub, OpenAI
|
@@ -13,6 +15,9 @@ class LLLResponseGenerator():
|
|
13 |
def __init__(self):
|
14 |
print("initialized")
|
15 |
|
|
|
|
|
|
|
16 |
|
17 |
def llm_inference(
|
18 |
self,
|
@@ -96,7 +101,9 @@ class LLLResponseGenerator():
|
|
96 |
print(response)
|
97 |
# Extracting only the response part from the output
|
98 |
response_start_index = response.find("Response;")
|
99 |
-
|
|
|
|
|
100 |
|
101 |
else:
|
102 |
print(
|
|
|
1 |
import os
|
2 |
+
import re
|
3 |
+
from dotenv import load_dotenv, find_dotenv
|
4 |
from langchain_community.llms import HuggingFaceHub
|
5 |
from langchain_community.llms import OpenAI
|
6 |
# from langchain.llms import HuggingFaceHub, OpenAI
|
|
|
15 |
def __init__(self):
|
16 |
print("initialized")
|
17 |
|
18 |
+
def remove_html_tags(text):
|
19 |
+
clean_text = re.sub(r'<[^>]*>', '', text)
|
20 |
+
return clean_text
|
21 |
|
22 |
def llm_inference(
|
23 |
self,
|
|
|
101 |
print(response)
|
102 |
# Extracting only the response part from the output
|
103 |
response_start_index = response.find("Response;")
|
104 |
+
response_output = response[response_start_index + len("Response;"):].strip()
|
105 |
+
# print(response_output)
|
106 |
+
return response_output
|
107 |
|
108 |
else:
|
109 |
print(
|