sidphbot commited on
Commit
2bf46ef
1 Parent(s): 8cfcf51

pydantic test

Browse files
Files changed (2) hide show
  1. app.py +26 -22
  2. requirements.txt +1 -1
app.py CHANGED
@@ -1,6 +1,7 @@
 
1
  import streamlit as st
2
- import pandas as pd
3
- import numpy as np
4
 
5
  from src.Surveyor import Surveyor
6
 
@@ -39,26 +40,27 @@ def show_survey_download(zip_file_name, survey_file_name, download_placeholder):
39
  )
40
 
41
 
42
- def survey_space(surveyor, download_placeholder):
 
 
 
 
 
 
 
 
 
 
 
43
 
44
- class KeywordsModel(BaseModel):
45
- research_keywords: Optional[str] = Field(
46
- '', description="Enter your research keywords:"
47
- )
48
- max_search: int = Field(
49
- 10, ge=1, le=50, multiple_of=1,
50
- description="num_papers_to_search:"
51
- )
52
- num_papers: int = Field(
53
- 3, ge=1, le=8, multiple_of=1,
54
- description="num_papers_to_select:"
55
- )
56
- class ArxivIDsModel(BaseModel):
57
- arxiv_ids: Optional[List[str]] = Field(
58
- [], max_items=8, regex=r"^[0-9]+\.[0-9]+$", description="Enter arxiv ids for your curated set of papers (e.g. 2205.12755, 2205.10937, ...):"
59
- )
60
-
61
-
62
  with st.sidebar.form(key="survey_keywords_form"):
63
  session_data = sp.pydantic_input(key="keywords_input_model", model=KeywordsModel)
64
  st.write('or')
@@ -68,7 +70,9 @@ def survey_space(surveyor, download_placeholder):
68
  run_kwargs = {'surveyor':surveyor, 'download_placeholder':download_placeholder}
69
  if submit:
70
  if session_data['research_keywords'] != '':
71
- run_kwargs.update({'research_keywords':session_data['research_keywords'], 'max_search':max_search, 'num_papers':num_papers})
 
 
72
  elif len(session_data['arxiv_ids']):
73
  run_kwargs.update({'arxiv_ids':session_data['arxiv_ids']})
74
  run_survey(**run_kwargs)
 
1
+ from typing import List, Optional
2
  import streamlit as st
3
+ import streamlit_pydantic as sp
4
+ from pydantic import BaseModel, Field
5
 
6
  from src.Surveyor import Surveyor
7
 
 
40
  )
41
 
42
 
43
+ class KeywordsModel(BaseModel):
44
+ research_keywords: Optional[str] = Field(
45
+ '', description="Enter your research keywords:"
46
+ )
47
+ max_search: int = Field(
48
+ 10, ge=1, le=50, multiple_of=1,
49
+ description="num_papers_to_search:"
50
+ )
51
+ num_papers: int = Field(
52
+ 3, ge=1, le=8, multiple_of=1,
53
+ description="num_papers_to_select:"
54
+ )
55
 
56
+
57
+ class ArxivIDsModel(BaseModel):
58
+ arxiv_ids: Optional[List[str]] = Field(
59
+ [], max_items=8, regex=r"^[0-9]+\.[0-9]+$", description="Enter arxiv ids for your curated set of papers (e.g. 2205.12755, 2205.10937, ...):"
60
+ )
61
+
62
+
63
+ def survey_space(surveyor, download_placeholder):
 
 
 
 
 
 
 
 
 
 
64
  with st.sidebar.form(key="survey_keywords_form"):
65
  session_data = sp.pydantic_input(key="keywords_input_model", model=KeywordsModel)
66
  st.write('or')
 
70
  run_kwargs = {'surveyor':surveyor, 'download_placeholder':download_placeholder}
71
  if submit:
72
  if session_data['research_keywords'] != '':
73
+ run_kwargs.update({'research_keywords':session_data['research_keywords'],
74
+ 'max_search':session_data['research_keywords'],
75
+ 'num_papers':session_data['research_keywords']})
76
  elif len(session_data['arxiv_ids']):
77
  run_kwargs.update({'arxiv_ids':session_data['arxiv_ids']})
78
  run_survey(**run_kwargs)
requirements.txt CHANGED
@@ -23,7 +23,7 @@ scispacy
23
  https://s3-us-west-2.amazonaws.com/ai2-s2-scispacy/releases/v0.5.0/en_core_sci_scibert-0.5.0.tar.gz
24
  https://s3-us-west-2.amazonaws.com/ai2-s2-scispacy/releases/v0.5.0/en_core_sci_lg-0.5.0.tar.gz
25
  streamlit
26
- streamlit-tags
27
  summarizer
28
  tabula
29
  tabula_py
 
23
  https://s3-us-west-2.amazonaws.com/ai2-s2-scispacy/releases/v0.5.0/en_core_sci_scibert-0.5.0.tar.gz
24
  https://s3-us-west-2.amazonaws.com/ai2-s2-scispacy/releases/v0.5.0/en_core_sci_lg-0.5.0.tar.gz
25
  streamlit
26
+ streamlit-pydantic
27
  summarizer
28
  tabula
29
  tabula_py