Spaces:
Build error
Build error
Update app.py
Browse files17 unmodified lines18192021222324252627282930313233343553 unmodified lines8990919293949596979835 unmodified lines13413513613713813914017 unmodified lines# Get the API key from the environment variableif 'initiated' not in st.session_state:HF_TOKEN = os.getenv("HF_TOKEN")if HF_TOKEN is None:st.error("API key not found. Please set the HF_TOKEN secret in your Hugging Face Space.")st.stop()icons = {"assistant": "robot.png", "user": "man-kddi.png"}DATA_DIR = "data"remote_llm = CustomLlama3(bearer_token = HF_TOKEN)# Ensure data directory existsos.makedirs(DATA_DIR, exist_ok=True)retriever=Nonest.session_state.initiated="true"def data_ingestion():53 unmodified lines)# Chainrag_chain = prompt | remote_llm | StrOutputParser()# Rundocs = retriever.invoke(question)generation = rag_chain.invoke({"context": "\n\n".join(doc.page_content for doc in docs), "question": question})return generation35 unmodified lineswith open(DATA_DIR+"/saved_link.txt", "w") as file:file.write(web_url)st.session_state["console_out"] += "Link saved: " + web_url + "\n"retriever = data_ingestion()st.success("Done")st.text_area("Console", st.session_state["console_out"])17 unmodified lines181920212223242526272829303132333435363753 unmodified lines91929394959697989910035 unmodified lines13613713813914014114217 unmodified lines# Get the API key from the environment variableHF_TOKEN = os.getenv("HF_TOKEN")if HF_TOKEN is None:st.error("API key not found. Please set the HF_TOKEN secret in your Hugging Face Space.")st.stop()icons = {"assistant": "robot.png", "user": "man-kddi.png"}DATA_DIR = "data"# Ensure data directory existsos.makedirs(DATA_DIR, exist_ok=True)if not hasattr(st, 'remote_llm'):st.remote_llm = CustomLlama3(bearer_token = HF_TOKEN)if not hasattr(st, 'retriever'):st.retriever = "None"def data_ingestion():53 unmodified lines)# Chainrag_chain = prompt | st.remote_llm | StrOutputParser()# Rundocs = st.retriever.invoke(question)generation = rag_chain.invoke({"context": "\n\n".join(doc.page_content for doc in docs), "question": question})return generation35 unmodified lineswith open(DATA_DIR+"/saved_link.txt", "w") as file:file.write(web_url)st.session_state["console_out"] += "Link saved: " + web_url + "\n"st.retriever = data_ingestion()st.success("Done")st.text_area("Console", st.session_state["console_out"])
app.py+17-15