andreska commited on
Commit
68bd3e2
·
verified ·
1 Parent(s): 8beee20

Gemini fix to render try#2

Browse files
Files changed (1) hide show
  1. app.py +31 -3
app.py CHANGED
@@ -3,7 +3,37 @@ import streamlit as st
3
  from datasets import load_dataset
4
  from huggingface_hub import InferenceClient
5
 
6
- # ... (rest of your code)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
  # Define the placeholder globally (outside columns)
9
  placeholder = st.empty()
@@ -41,8 +71,6 @@ def handle_submit():
41
  else:
42
  st.session_state.conversation(f"<p><strong>Adrega AI:</strong>: Please enter a question.")
43
 
44
- # ... (rest of your code)
45
-
46
  st.text_input('Ask me a question', key='user_input', on_change=handle_submit)
47
  col1, col2 = st.columns(2)
48
  with col1:
 
3
  from datasets import load_dataset
4
  from huggingface_hub import InferenceClient
5
 
6
+ # Get the API key from the environment variable
7
+ api_key = os.getenv("HF_API_KEY")
8
+ client = InferenceClient(api_key=api_key)
9
+
10
+ # Load the dataset
11
+ dataset = load_dataset("andreska/adregadocs", split="test")
12
+
13
+ # Function to read the content from the dataset
14
+ def read_dataset(dataset):
15
+ text = []
16
+ for item in dataset:
17
+ text.append(item['text'])
18
+ return "\n".join(text)
19
+
20
+ context = read_dataset(dataset)
21
+
22
+ # Inject custom CSS
23
+ st.markdown(
24
+ """
25
+ <style>
26
+ .scrollable-div {
27
+ height: 400px;
28
+ width: 100%;
29
+ overflow-y: auto;
30
+ padding: 10px;
31
+ border: 1px solid #ccc;
32
+ }
33
+ </style>
34
+ """,
35
+ unsafe_allow_html=True
36
+ )
37
 
38
  # Define the placeholder globally (outside columns)
39
  placeholder = st.empty()
 
71
  else:
72
  st.session_state.conversation(f"<p><strong>Adrega AI:</strong>: Please enter a question.")
73
 
 
 
74
  st.text_input('Ask me a question', key='user_input', on_change=handle_submit)
75
  col1, col2 = st.columns(2)
76
  with col1: