Oriol Ganduxé Pregona commited on
Commit
95e5c11
·
1 Parent(s): f5c4253

Adding some prints and changing a bit more the layout

Browse files
Files changed (1) hide show
  1. code_qa_app.py +9 -10
code_qa_app.py CHANGED
@@ -92,6 +92,8 @@ class FixedRetriever(BaseRetriever):
92
 
93
  # Question answering function
94
  def qa_fetching_repo(url_repo, branch, context_query, prompt_query, chain_type, k):
 
 
95
  # load data
96
  loader = GitLoader(
97
  clone_url=url_repo,
@@ -116,6 +118,7 @@ def qa_fetching_repo(url_repo, branch, context_query, prompt_query, chain_type,
116
  # Question answering function
117
  def qa_cached_tuist(context_query, prompt_query, chain_type, k):
118
 
 
119
  db = Chroma(persist_directory="tuist_cached_db/", embedding_function=OpenAIEmbeddings())
120
 
121
  return qa(db, context_query, prompt_query, chain_type, k)
@@ -123,12 +126,14 @@ def qa_cached_tuist(context_query, prompt_query, chain_type, k):
123
  def qa(db, context_query, prompt_query, chain_type, k):
124
 
125
  if context_query.strip():
 
126
  docs = db.similarity_search(context_query, k=k)
127
  retriever = FixedRetriever(docs)
128
  # You can test how an empty retriever makes our LLM ignorant about the context
129
  # retriever = FixedRetriever([])
130
 
131
  else:
 
132
  # expose this index in a retriever interface
133
  retriever = db.as_retriever(search_type="similarity", search_kwargs={"k": k})
134
 
@@ -150,8 +155,6 @@ def qa(db, context_query, prompt_query, chain_type, k):
150
  print(result['result'])
151
  return result
152
 
153
-
154
-
155
  convos = [] # store all panel objects in a list
156
 
157
  def qa_result(_):
@@ -219,14 +222,10 @@ setup = pn.Row(
219
  )
220
  )
221
 
222
- queries = pn.Row(
223
- pn.Column(
224
- context_texteditor,
225
- prompt_texteditor,
226
- run_button,
227
- margin=5
228
- ), width=600
229
- )
230
 
231
  pn.Column(
232
  pn.pane.Markdown("""
 
92
 
93
  # Question answering function
94
  def qa_fetching_repo(url_repo, branch, context_query, prompt_query, chain_type, k):
95
+
96
+ print("* QA fetching repo")
97
  # load data
98
  loader = GitLoader(
99
  clone_url=url_repo,
 
118
  # Question answering function
119
  def qa_cached_tuist(context_query, prompt_query, chain_type, k):
120
 
121
+ print("* QA cached tuist")
122
  db = Chroma(persist_directory="tuist_cached_db/", embedding_function=OpenAIEmbeddings())
123
 
124
  return qa(db, context_query, prompt_query, chain_type, k)
 
126
  def qa(db, context_query, prompt_query, chain_type, k):
127
 
128
  if context_query.strip():
129
+ print("* Using FixedRetriver")
130
  docs = db.similarity_search(context_query, k=k)
131
  retriever = FixedRetriever(docs)
132
  # You can test how an empty retriever makes our LLM ignorant about the context
133
  # retriever = FixedRetriever([])
134
 
135
  else:
136
+ print("* Using db as retriever")
137
  # expose this index in a retriever interface
138
  retriever = db.as_retriever(search_type="similarity", search_kwargs={"k": k})
139
 
 
155
  print(result['result'])
156
  return result
157
 
 
 
158
  convos = [] # store all panel objects in a list
159
 
160
  def qa_result(_):
 
222
  )
223
  )
224
 
225
+ queries = pn.Column(
226
+ pn.Row(context_texteditor, prompt_texteditor),
227
+ run_button,
228
+ margin=5)
 
 
 
 
229
 
230
  pn.Column(
231
  pn.pane.Markdown("""