devve1 commited on
Commit
846607c
1 Parent(s): 01ede4f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -17
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": f"""Use the following pieces of context to answer the user question.
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"Question: {query}"
 
 
 
 
 
155
  }
156
- ], stop=["</s>"], temperature=0.7)
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='Dark Souls').load()
263
- docs_3 = WikipediaLoader(query='Zelda II: The Adventure of Link').load()
264
- #docs_4 = WikipediaLoader(query='The Witcher').load()
265
- #docs_5 = WikipediaLoader(query='Genshin Impact ').load()
266
- #docs_6 = WikipediaLoader(query='The Elder Scrolls').load()
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: