hanoch.rahimi@gmail commited on
Commit
adb5688
·
1 Parent(s): 96f5188

bug fixes. initial like buttons

Browse files
Files changed (1) hide show
  1. app.py +27 -14
app.py CHANGED
@@ -80,7 +80,8 @@ def card(company_id, name, description, score, data_type, region, country, metad
80
  <span>{business_model}</span>
81
  </div>
82
  <div class="col-md-1 col-sm-1">
83
- <button onclick="like_company({name});">
 
84
  </div>
85
  """
86
 
@@ -91,7 +92,7 @@ def card(company_id, name, description, score, data_type, region, country, metad
91
  <span>[Score: {score}</span>
92
  </div>
93
  """
94
- markdown = markdown + "</div></div>"
95
  return st.markdown(markdown, unsafe_allow_html=True)
96
 
97
 
@@ -117,10 +118,7 @@ def call_openai(prompt, engine="gpt-3.5-turbo", temp=0, top_p=1.0, max_tokens=40
117
  try:
118
  response = openai.ChatCompletion.create(
119
  model=engine,
120
- messages=[
121
- {"role": "system", "content": "You are an assistant analyzing startup companies for investments."},
122
- {"role": "user", "content": prompt}
123
- ],
124
  temperature=temp,
125
  max_tokens=max_tokens
126
  )
@@ -166,11 +164,13 @@ def run_query(query, prompt, scrape_boost, top_k , regions, countries, is_debug,
166
  answer['id'] = match['id']
167
  answer["name"] = match["metadata"]['company_name']
168
  answer["description"] = match["metadata"]['description'] if "description" in match['metadata'] else ""
169
- data = {"Summary": match["metadata"]["summary"]}
170
- try:
171
- data = json.loads(match["metadata"]["summary"])
172
- except Exception as e:
173
- pass
 
 
174
  answer['data'] = data
175
 
176
  results.append(answer)
@@ -187,8 +187,11 @@ def run_query(query, prompt, scrape_boost, top_k , regions, countries, is_debug,
187
  User query: {query}
188
  """
189
  prompt_template = PromptTemplate(template=prompt_txt, input_variables=["descriptions", "query"])
190
- prompt = prompt_template.format(descriptions = [f"{res['name']}: {res['data']['Summary']}" for res in results[:10]], query = query)
191
- m_text = call_openai(prompt, engine="gpt-3.5-turbo-16k", temp=0, top_p=1.0, max_tokens=16192)
 
 
 
192
 
193
  m_text
194
 
@@ -297,7 +300,15 @@ if check_password():
297
 
298
 
299
  st.markdown(
300
- f'''
 
 
 
 
 
 
 
 
301
  <style>
302
  .sidebar .sidebar-content {{
303
  width: 375px;
@@ -321,6 +332,8 @@ if check_password():
321
  top_k = st.number_input('# Top Results', value=20)
322
  is_debug = st.checkbox("Debug output", value = False, key="debug")
323
  index_namespace = st.selectbox(label="Data Type", options=["websummarized", "web", "cbli", "all"], index=0)
 
 
324
 
325
 
326
 
 
80
  <span>{business_model}</span>
81
  </div>
82
  <div class="col-md-1 col-sm-1">
83
+ <button type='button' onclick="like_company({company_id});">Like</button>
84
+ <button type='button' onclick="dislike_company({company_id});">DisLike</button>
85
  </div>
86
  """
87
 
 
92
  <span>[Score: {score}</span>
93
  </div>
94
  """
95
+ markdown = markdown + "</div>"
96
  return st.markdown(markdown, unsafe_allow_html=True)
97
 
98
 
 
118
  try:
119
  response = openai.ChatCompletion.create(
120
  model=engine,
121
+ messages=[{"role": "user", "content": prompt}],
 
 
 
122
  temperature=temp,
123
  max_tokens=max_tokens
124
  )
 
164
  answer['id'] = match['id']
165
  answer["name"] = match["metadata"]['company_name']
166
  answer["description"] = match["metadata"]['description'] if "description" in match['metadata'] else ""
167
+ data = None
168
+ data = {"Summary": match["metadata"]["summary"]}
169
+ if 'summary' in match['metadata']:
170
+ try:
171
+ data = json.loads(match["metadata"]["summary"])
172
+ except Exception as e:
173
+ pass
174
  answer['data'] = data
175
 
176
  results.append(answer)
 
187
  User query: {query}
188
  """
189
  prompt_template = PromptTemplate(template=prompt_txt, input_variables=["descriptions", "query"])
190
+ descriptions = str([f"{res['name']}: {res['data']['Summary']}" for res in results[:20] if 'Summary' in res['data']])
191
+ ntokens = len(descriptions.split(" "))
192
+ print(f"#Tokens {ntokens}:\n {descriptions}")
193
+ prompt = prompt_template.format(descriptions = descriptions, query = query)
194
+ m_text = call_openai(prompt, engine="gpt-3.5-turbo-16k", temp=0, top_p=1.0)
195
 
196
  m_text
197
 
 
300
 
301
 
302
  st.markdown(
303
+ '''
304
+ <script>
305
+ function like_company(company_id) {
306
+ console.log("Company " + company_id + " Liked!");
307
+ }
308
+ function dislike_company(company_id) {
309
+ console.log("Company " + company_id + " Disliked!");
310
+ }
311
+ </script>
312
  <style>
313
  .sidebar .sidebar-content {{
314
  width: 375px;
 
332
  top_k = st.number_input('# Top Results', value=20)
333
  is_debug = st.checkbox("Debug output", value = False, key="debug")
334
  index_namespace = st.selectbox(label="Data Type", options=["websummarized", "web", "cbli", "all"], index=0)
335
+ liked_companies = st.text_input(label="liked companies", key='liked_companies')
336
+ disliked_companies = st.text_input(label="disliked companies", key='disliked_companies')
337
 
338
 
339