File size: 1,290 Bytes
e04dd70
f85c548
e04dd70
 
73a1ad4
e04dd70
 
 
 
 
 
 
 
73a1ad4
 
 
 
 
 
 
 
e04dd70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import streamlit as st
from app import client, default_embedding_function
import pandas as pd
from generate_kb import generate_knowledge_box_from_url
from utils import get_chroma_client

# Title of the app
st.title("Create a knowledge box from CSV file")

# File uploader widget
uploaded_file = st.file_uploader("Choose a CSV file", type=["csv"])
df = None

collection_name = st.text_input(label="empy collection name")
if st.button("create empty knowledge box"):
    client = get_chroma_client()
    collection = client.create_collection(name=collection_name)
    st.success("collection created")
    st.write(collection)


if uploaded_file is not None:
    try:
        df = pd.read_csv(uploaded_file)
        st.write("DataFrame:")
        st.write(df)
    except Exception as e:
        st.error(str(e))


if uploaded_file is not None:
    st.text("dont use spaces but underscores _ in your new name")
    kb_name = st.text_input(label="new knowledge base name")
    if st.button("Generate new knowledge box"):
        urls = df.values.tolist()
        res = generate_knowledge_box_from_url(
            client=client,
            urls=urls,
            kb_name=kb_name,
            embedding_fct=default_embedding_function,
            chunk_size=2_000,
        )
        st.json(res)