Zwea Htet commited on
Commit
1230ae3
1 Parent(s): 08d67c4

fixed llama package issue

Browse files
Files changed (2) hide show
  1. app.py +10 -2
  2. models/bloom.py +3 -3
app.py CHANGED
@@ -30,15 +30,23 @@ def validate(token: str):
30
  return response
31
 
32
  def create_index():
33
- index = bloom.initialize_index("")
34
-
35
 
36
  def get_response(vector_index, query_str):
37
  query_engine = vector_index.as_query_engine()
38
  response = query_engine.query(query_str)
39
  return response
40
 
 
41
  api_key = st.text_input("Enter your OpenAI API key here:", type="password")
 
 
 
 
 
 
 
42
 
43
  st.write("---")
44
  input_text = st.text_area("Ask your question")
 
30
  return response
31
 
32
  def create_index():
33
+ index = bloom.initialize_index("bloomLlama")
34
+ return index
35
 
36
  def get_response(vector_index, query_str):
37
  query_engine = vector_index.as_query_engine()
38
  response = query_engine.query(query_str)
39
  return response
40
 
41
+
42
  api_key = st.text_input("Enter your OpenAI API key here:", type="password")
43
+ if api_key:
44
+ resp = validate(api_key)
45
+ if ("error" in resp.json()):
46
+ st.info("Your API Token is incorrect! Try again.")
47
+ else:
48
+ os.environ["OPENAI_API_KEY"] = api_key
49
+ index = create_index()
50
 
51
  st.write("---")
52
  input_text = st.text_area("Ask your question")
models/bloom.py CHANGED
@@ -20,12 +20,12 @@ model = AutoModelForCausalLM.from_pretrained(model_name, config='T5Config')
20
 
21
  # define prompt helper
22
  # set maximum input size
23
- max_input_size = 2048
24
  # set number of output tokens
25
  num_output = 525
26
  # set maximum chunk overlap
27
- max_chunk_overlap = 20
28
- prompt_helper = PromptHelper(max_input_size, num_output, max_chunk_overlap)
29
 
30
  # define llm
31
  llm_predictor = LLMPredictor(llm=CustomLLM(model, tokenizer))
 
20
 
21
  # define prompt helper
22
  # set maximum input size
23
+ context_window = 2048
24
  # set number of output tokens
25
  num_output = 525
26
  # set maximum chunk overlap
27
+ chunk_overlap_ratio = 0.2
28
+ prompt_helper = PromptHelper(context_window, num_output, chunk_overlap_ratio)
29
 
30
  # define llm
31
  llm_predictor = LLMPredictor(llm=CustomLLM(model, tokenizer))