Oriol Ganduxé Pregona commited on
Commit
7d0f65e
·
1 Parent(s): 9ed6379

Clearing responses on every question, making textfields bigger.

Browse files
Files changed (1) hide show
  1. code_qa_app.py +6 -4
code_qa_app.py CHANGED
@@ -49,7 +49,7 @@ openaikey = pn.widgets.PasswordInput(
49
  prompt = pn.widgets.TextEditor(
50
  value="",
51
  placeholder="Enter your questions here...",
52
- height=160,
53
  toolbar=False
54
  )
55
 
@@ -120,7 +120,6 @@ def qa(url_repo, branch, query, chain_type, k):
120
  # Question answering function
121
  def qa_cached_tuist(query, chain_type, k):
122
 
123
-
124
  # select which embeddings to use
125
  embeddings = OpenAIEmbeddings()
126
 
@@ -128,6 +127,7 @@ def qa_cached_tuist(query, chain_type, k):
128
  persist_directory = "tuist_cached_db/"
129
  db = Chroma(persist_directory=persist_directory, embedding_function=embeddings)
130
 
 
131
  llm = ChatOpenAI(
132
  model_name = "gpt-3.5-turbo",
133
  temperature=0.7,
@@ -143,7 +143,7 @@ def qa_cached_tuist(query, chain_type, k):
143
 
144
  # create a chain to answer questions
145
  qa = RetrievalQA.from_chain_type(
146
- llm=OpenAI(),
147
  chain_type=chain_type,
148
  retriever=retriever,
149
  return_source_documents=True
@@ -161,6 +161,8 @@ def qa_result(_):
161
  prompt_text = prompt.value
162
  if prompt_text:
163
 
 
 
164
  if use_cached_repo.value:
165
  result = qa_cached_tuist(query=prompt_text, chain_type=select_chain_type.value, k=select_k.value)
166
  else:
@@ -190,7 +192,7 @@ qa_interactive = pn.panel(
190
  )
191
 
192
  # Output
193
- output = pn.WidgetBox('*Output will show up here:*', qa_interactive, width=630, scroll=True)
194
 
195
  # Layout
196
  github_inputs = pn.Column(use_cached_repo, url_repo, branch_repo, width=600)
 
49
  prompt = pn.widgets.TextEditor(
50
  value="",
51
  placeholder="Enter your questions here...",
52
+ height=200,
53
  toolbar=False
54
  )
55
 
 
120
  # Question answering function
121
  def qa_cached_tuist(query, chain_type, k):
122
 
 
123
  # select which embeddings to use
124
  embeddings = OpenAIEmbeddings()
125
 
 
127
  persist_directory = "tuist_cached_db/"
128
  db = Chroma(persist_directory=persist_directory, embedding_function=embeddings)
129
 
130
+ # llm=OpenAI()
131
  llm = ChatOpenAI(
132
  model_name = "gpt-3.5-turbo",
133
  temperature=0.7,
 
143
 
144
  # create a chain to answer questions
145
  qa = RetrievalQA.from_chain_type(
146
+ llm=llm,
147
  chain_type=chain_type,
148
  retriever=retriever,
149
  return_source_documents=True
 
161
  prompt_text = prompt.value
162
  if prompt_text:
163
 
164
+ convos.clear()
165
+
166
  if use_cached_repo.value:
167
  result = qa_cached_tuist(query=prompt_text, chain_type=select_chain_type.value, k=select_k.value)
168
  else:
 
192
  )
193
 
194
  # Output
195
+ output = pn.WidgetBox('*Output will show up here:*', qa_interactive, width=1000, scroll=True)
196
 
197
  # Layout
198
  github_inputs = pn.Column(use_cached_repo, url_repo, branch_repo, width=600)