Update app.py
Browse files
app.py
CHANGED
@@ -141,19 +141,17 @@ def main(query: str, client: QdrantClient, collection_name: str, llm, dense_mode
|
|
141 |
|
142 |
response = llm.create_chat_completion(
|
143 |
messages = [
|
144 |
-
{"role": "system", "content":
|
145 |
-
If the context does not have the information, use your own knowledge.
|
146 |
-
If neither the context nor your own knowledge provides an answer, just say that you don't know, don't try to make up an answer.
|
147 |
-
Use three sentences maximum and keep the answer as concise as possible.
|
148 |
-
|
149 |
-
Context :
|
150 |
-
{context}"""
|
151 |
-
},
|
152 |
{
|
153 |
"role": "user",
|
154 |
-
"content": f"
|
|
|
|
|
|
|
|
|
|
|
155 |
}
|
156 |
-
], stop=["</s>"], temperature=0.
|
157 |
|
158 |
text = response["choices"][0]["message"]['content']
|
159 |
print(f'TEXT: {text}')
|
@@ -259,13 +257,11 @@ def load_models_and_documents():
|
|
259 |
os.mkdir(embeddings_path)
|
260 |
|
261 |
docs_1 = WikipediaLoader(query='Action-RPG').load()
|
262 |
-
docs_2 = WikipediaLoader(query='
|
263 |
-
docs_3 = WikipediaLoader(query='
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
#docs_7 = WikipediaLoader(query='Fallout').load()
|
268 |
-
docs = docs_1 + docs_2 + docs_3 #+ docs_4 + docs_5 + docs_6 + docs_7
|
269 |
chunks, dense_embeddings, sparse_embeddings = chunk_documents(docs, dense_model, sparse_model)
|
270 |
|
271 |
with open(chunks_path, "wb") as outfile:
|
|
|
141 |
|
142 |
response = llm.create_chat_completion(
|
143 |
messages = [
|
144 |
+
{"role": "system", "content": "You are a helpful assistant."},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
{
|
146 |
"role": "user",
|
147 |
+
"content": f"""If the context is not relevant,
|
148 |
+
please answer the question by using your own knowledge about the topic
|
149 |
+
|
150 |
+
{context}
|
151 |
+
|
152 |
+
Question: {question}"""
|
153 |
}
|
154 |
+
], stop=["</s>"], temperature=0, frequency_penalty=0.2, presence_penalty=0.4, top_p=0.2)
|
155 |
|
156 |
text = response["choices"][0]["message"]['content']
|
157 |
print(f'TEXT: {text}')
|
|
|
257 |
os.mkdir(embeddings_path)
|
258 |
|
259 |
docs_1 = WikipediaLoader(query='Action-RPG').load()
|
260 |
+
docs_2 = WikipediaLoader(query='Real-time strategy').load()
|
261 |
+
docs_3 = WikipediaLoader(query='First-person shooter').load()
|
262 |
+
docs_4 = WikipediaLoader(query='Multiplayer online battle arena').load()
|
263 |
+
docs_5 = WikipediaLoader(query='List of video game genres').load()
|
264 |
+
docs = docs_1 + docs_2 + docs_3 + docs_4 + docs_5
|
|
|
|
|
265 |
chunks, dense_embeddings, sparse_embeddings = chunk_documents(docs, dense_model, sparse_model)
|
266 |
|
267 |
with open(chunks_path, "wb") as outfile:
|