Spaces:
Sleeping
Sleeping
Commit
·
cdaa74f
1
Parent(s):
13e00d0
Update app.py
Browse files
app.py
CHANGED
|
@@ -47,7 +47,7 @@ class Chatbot:
|
|
| 47 |
# Initialize an OpenAIEmbeddings model to compute embeddings of the chunks
|
| 48 |
embeddings = OpenAIEmbeddings()
|
| 49 |
|
| 50 |
-
# Build a knowledge base using
|
| 51 |
knowledge_base = Chroma.from_documents(chunks, embeddings)
|
| 52 |
|
| 53 |
# Return the resulting knowledge base
|
|
@@ -151,37 +151,6 @@ class Chatbot:
|
|
| 151 |
return history
|
| 152 |
|
| 153 |
|
| 154 |
-
def extract_excel_data(self,file_path):
|
| 155 |
-
# Read the Excel file
|
| 156 |
-
df = pd.read_excel(file_path)
|
| 157 |
-
|
| 158 |
-
# Flatten the data to a single list
|
| 159 |
-
data_list = []
|
| 160 |
-
for _, row in df.iterrows():
|
| 161 |
-
data_list.extend(row.tolist())
|
| 162 |
-
|
| 163 |
-
return data_list
|
| 164 |
-
|
| 165 |
-
def comparing_chemicals(self,excel_file_path,chemicals):
|
| 166 |
-
chemistry_capability = self.extract_excel_data(excel_file_path.name)
|
| 167 |
-
response = openai.Completion.create(
|
| 168 |
-
engine="text-davinci-003",
|
| 169 |
-
prompt= f"""Analyse the following text delimited by triple backticks to return the comman chemicals.
|
| 170 |
-
text : ```{chemicals} {chemistry_capability}```.
|
| 171 |
-
result should be in bullet points format.
|
| 172 |
-
""",
|
| 173 |
-
max_tokens=100,
|
| 174 |
-
n=1,
|
| 175 |
-
stop=None,
|
| 176 |
-
temperature=0,
|
| 177 |
-
top_p=1.0,
|
| 178 |
-
frequency_penalty=0.0,
|
| 179 |
-
presence_penalty=0.0
|
| 180 |
-
)
|
| 181 |
-
|
| 182 |
-
result = response.choices[0].text.strip()
|
| 183 |
-
return result
|
| 184 |
-
|
| 185 |
def clear_function(self,state):
|
| 186 |
state.clear()
|
| 187 |
# state = gr.State(self.get_empty_state())
|
|
|
|
| 47 |
# Initialize an OpenAIEmbeddings model to compute embeddings of the chunks
|
| 48 |
embeddings = OpenAIEmbeddings()
|
| 49 |
|
| 50 |
+
# Build a knowledge base using Chroma from the chunks and their embeddings
|
| 51 |
knowledge_base = Chroma.from_documents(chunks, embeddings)
|
| 52 |
|
| 53 |
# Return the resulting knowledge base
|
|
|
|
| 151 |
return history
|
| 152 |
|
| 153 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
def clear_function(self,state):
|
| 155 |
state.clear()
|
| 156 |
# state = gr.State(self.get_empty_state())
|