Lhumpal commited on
Commit
bc03209
·
verified ·
1 Parent(s): 4533586

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -37,7 +37,7 @@ def build_faiss_vectorstore(chunks):
37
  return vectorstore
38
 
39
  # Function to retrieve similar text
40
- def retrieve(query, vectorstore, top_k=5):
41
  docs_and_scores = vectorstore.similarity_search_with_score(query=query, k=top_k)
42
 
43
  # Filter results based on score threshold
@@ -67,7 +67,7 @@ concise_text = dataset["concise"]["text"]
67
  concise_text_string = "".join(concise_text)
68
 
69
  # Chunk and index the documents
70
- chunks = chunk_text(concise_text_string, chunk_size=250)
71
  # Build the vectorsore
72
  vectorstore = build_faiss_vectorstore(chunks)
73
 
@@ -102,11 +102,12 @@ async def chat(request: ChatRequest):
102
  docs = "\n\n".join(docs)
103
 
104
  rag_prompt = f"""Use the following information to answer the user's query. You do not have to use all the information, just the pieces that directly
105
- help answer the query most accurately. Start directly with information, NOT with a rhetorical question. Respond in a conversational manner.
106
 
107
  Here is an example of the style and tone of a response:
108
 
109
- Query: How do big bucks use clear cuts for bedding?
 
110
  Response: Yeah, a lot of guys think big bucks just bed right in the middle of a clear cut because it’s thick, but that’s not really how they use it. The
111
  thick regrowth is great for food and cover, but those bucks still want an advantage. Most of the time, they’re bedding on the edges, right where the cut
112
  meets older timber. They’ll set up with the wind at their back so they can smell anything sneaking up behind them, and they’re looking out into the open
@@ -118,7 +119,7 @@ async def chat(request: ChatRequest):
118
 
119
  Using the information above, answer the user's query as accurately as possible:
120
 
121
- Query: {request.message}
122
  """
123
 
124
  # remove the unfformatted user message
@@ -133,7 +134,7 @@ async def chat(request: ChatRequest):
133
  config=GenerateContentConfig(
134
  system_instruction=[request.system_message],
135
  max_output_tokens=150,
136
- temperature=1.5
137
  ),
138
  )
139
 
 
37
  return vectorstore
38
 
39
  # Function to retrieve similar text
40
+ def retrieve(query, vectorstore, top_k=8):
41
  docs_and_scores = vectorstore.similarity_search_with_score(query=query, k=top_k)
42
 
43
  # Filter results based on score threshold
 
67
  concise_text_string = "".join(concise_text)
68
 
69
  # Chunk and index the documents
70
+ chunks = chunk_text(concise_text_string, chunk_size=350)
71
  # Build the vectorsore
72
  vectorstore = build_faiss_vectorstore(chunks)
73
 
 
102
  docs = "\n\n".join(docs)
103
 
104
  rag_prompt = f"""Use the following information to answer the user's query. You do not have to use all the information, just the pieces that directly
105
+ help answer the query most accurately. Start directly with information, NOT with a rhetorical question or you will be penalized. Respond in a conversational manner.
106
 
107
  Here is an example of the style and tone of a response:
108
 
109
+ User Query: How do big bucks use clear cuts for bedding?
110
+
111
  Response: Yeah, a lot of guys think big bucks just bed right in the middle of a clear cut because it’s thick, but that’s not really how they use it. The
112
  thick regrowth is great for food and cover, but those bucks still want an advantage. Most of the time, they’re bedding on the edges, right where the cut
113
  meets older timber. They’ll set up with the wind at their back so they can smell anything sneaking up behind them, and they’re looking out into the open
 
119
 
120
  Using the information above, answer the user's query as accurately as possible:
121
 
122
+ User Query: {request.message}
123
  """
124
 
125
  # remove the unfformatted user message
 
134
  config=GenerateContentConfig(
135
  system_instruction=[request.system_message],
136
  max_output_tokens=150,
137
+ temperature=1.75
138
  ),
139
  )
140