mahynski commited on
Commit
feeb9a7
1 Parent(s): 7670068
Files changed (2) hide show
  1. app.py +25 -1
  2. requirements.txt +3 -1
app.py CHANGED
@@ -5,8 +5,16 @@ from llama_index.llms.huggingface import HuggingFaceLLM
5
  from llama_index.llms.mistralai import MistralAI
6
  from llama_index.llms.openai import OpenAI
7
 
 
 
 
 
 
8
  from streamlit_pdf_viewer import pdf_viewer
9
 
 
 
 
10
  st.set_page_config(layout="wide")
11
 
12
  with st.sidebar:
@@ -41,7 +49,7 @@ with st.sidebar:
41
  else:
42
  llm_list = []
43
 
44
- llm = st.selectbox(
45
  label="Select LLM Model",
46
  options=llm_list,
47
  index=0
@@ -56,6 +64,22 @@ with st.sidebar:
56
  step=0.05,
57
  )
58
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  # Enter Token
60
  token = st.text_input(
61
  "Enter your token",
 
5
  from llama_index.llms.mistralai import MistralAI
6
  from llama_index.llms.openai import OpenAI
7
 
8
+ from llama_index.core import (
9
+ VectorStoreIndex,
10
+ Settings,
11
+ )
12
+
13
  from streamlit_pdf_viewer import pdf_viewer
14
 
15
+ # Global configurations
16
+ from llama_index.core import set_global_handler
17
+ set_global_handler("langfuse")
18
  st.set_page_config(layout="wide")
19
 
20
  with st.sidebar:
 
49
  else:
50
  llm_list = []
51
 
52
+ llm_name = st.selectbox(
53
  label="Select LLM Model",
54
  options=llm_list,
55
  index=0
 
64
  step=0.05,
65
  )
66
 
67
+ max_output_tokens = 4096
68
+
69
+ # Create LLM
70
+ if provider == 'openai':
71
+ llm = OpenAI(
72
+ model=llm_name,
73
+ temperature=temperature,
74
+ max_tokens=max_tokens
75
+ )
76
+ # Global tokenization needs to be consistent with LLM
77
+ # https://docs.llamaindex.ai/en/stable/module_guides/models/llms/
78
+ Settings.tokenizer = tiktoken.encoding_for_model(llm_name).encode
79
+ Settings.num_output = max_tokens
80
+ Settings.context_window = 4096 # max possible
81
+
82
+
83
  # Enter Token
84
  token = st.text_input(
85
  "Enter your token",
requirements.txt CHANGED
@@ -5,4 +5,6 @@ llama-index-llms-gemini
5
  llama-index-llms-huggingface
6
  llama-index-llms-huggingface-api
7
  llama-index-llms-mistralai
8
- llama-index-llms-openai
 
 
 
5
  llama-index-llms-huggingface
6
  llama-index-llms-huggingface-api
7
  llama-index-llms-mistralai
8
+ llama-index-llms-openai
9
+ tiktoken
10
+ llama-parse