Spaces:
Running
Running
added new front end
Browse files
app.py
CHANGED
@@ -1,4 +1,41 @@
|
|
1 |
import streamlit as st
|
|
|
|
|
2 |
|
3 |
-
|
4 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
+
from utils import load_json, count_tokens
|
3 |
+
import json
|
4 |
|
5 |
+
# Set up the Streamlit page configuration
|
6 |
+
st.set_page_config(page_title="Cintra Code Chunker", layout="wide")
|
7 |
+
|
8 |
+
def main():
|
9 |
+
# Streamlit widgets for file selection
|
10 |
+
st.title("Cintra Code Chunker")
|
11 |
+
uploaded_file = st.file_uploader("Choose a file")
|
12 |
+
if uploaded_file is not None:
|
13 |
+
# Displaying the original file content
|
14 |
+
file_content = uploaded_file.getvalue().decode("utf-8")
|
15 |
+
st.text_area("File content", value=file_content, height=250, max_chars=50000)
|
16 |
+
|
17 |
+
# Input for token chunk size target
|
18 |
+
token_chunk_size = st.slider(
|
19 |
+
"Select token chunk size target", min_value=10, max_value=500, value=100
|
20 |
+
)
|
21 |
+
|
22 |
+
# Button to trigger chunking process
|
23 |
+
if st.button("Chunk Code"):
|
24 |
+
# Assuming the existence of a function to chunk code based on token size
|
25 |
+
# This is a placeholder for the actual chunking logic which would likely involve
|
26 |
+
# the 'count_tokens' function from utils.py and some logic to split the code into chunks
|
27 |
+
# For demonstration, we'll just show a message
|
28 |
+
st.success(
|
29 |
+
f"Code has been chunked with a target of {token_chunk_size} tokens per chunk."
|
30 |
+
)
|
31 |
+
# Displaying the chunked code - this would be replaced with actual chunked code display logic
|
32 |
+
st.text_area(
|
33 |
+
"Chunked Code",
|
34 |
+
value="Chunked code would appear here...",
|
35 |
+
height=250,
|
36 |
+
max_chars=50000,
|
37 |
+
)
|
38 |
+
|
39 |
+
|
40 |
+
if __name__ == "__main__":
|
41 |
+
main()
|