|
1 | 1 | import streamlit as st
|
2 | 2 | from agent_config import create_agent
|
3 |
| -from rag_question_tab import render_rag_tab |
4 | 3 | from process_video import process_video
|
| 4 | +from rag_question_tab import render_rag_tab |
5 | 5 |
|
6 |
| -st.set_page_config(page_title="Análise de Vídeos para Jornalismo", layout="wide") |
7 |
| -st.title("🧠 Agente de IA para Jornalismo Investigativo com Vídeos do YouTube") |
8 |
| - |
9 |
| -groq_key = st.text_input("🔑 Chave da API do Groq", type="password") |
10 |
| -huggingface_token = st.text_input("🔑 Token da API do Hugging Face", type="password") |
11 |
| -openai_key = st.text_input("🔑 Chave da API da OpenAI (para Whisper)", type="password") |
12 |
| - |
13 |
| -if groq_key and huggingface_token and openai_key: |
14 |
| - tabs = st.tabs(["Transcrição e análise", "Destaques", "Perguntas"]) |
15 |
| - |
16 |
| - with tabs[0]: |
17 |
| - st.subheader("📺 Analisar vídeo do YouTube") |
18 |
| - youtube_url = st.text_input("Cole aqui a URL do vídeo do YouTube:") |
| 6 | +# Aba de configurações no sidebar |
| 7 | +with st.sidebar: |
| 8 | + st.header("🔑 Configurações") |
| 9 | + groq_key = st.text_input("Chave da API do Groq", type="password") |
| 10 | + hf_key = st.text_input("Token da API do HuggingFace", type="password") |
19 | 11 |
|
20 |
| - if st.button("Analisar vídeo"): |
21 |
| - st.session_state.conversation_history = [] |
22 |
| - with st.spinner("Processando vídeo..."): |
23 |
| - try: |
24 |
| - result = process_video(youtube_url, groq_key, huggingface_token, openai_key) |
| 12 | + if groq_key: |
| 13 | + st.session_state["groq_api_key"] = groq_key |
| 14 | + st.success("Chave da Groq salva!") |
25 | 15 |
|
26 |
| - if isinstance(result, str): |
27 |
| - st.session_state.conversation_history.append(("assistant", result)) |
28 |
| - elif isinstance(result, dict) and "steps" in result: |
29 |
| - for step in result["steps"]: |
30 |
| - st.session_state.conversation_history.append( |
31 |
| - ("assistant", f"**{step['name']}:**\n\n{step['content']}") |
32 |
| - ) |
33 |
| - else: |
34 |
| - st.session_state.conversation_history.append(("assistant", str(result))) |
| 16 | + if hf_key: |
| 17 | + st.session_state["huggingface_token"] = hf_key |
| 18 | + st.success("Token do HuggingFace salvo!") |
35 | 19 |
|
36 |
| - st.success("Análise concluída!") |
37 |
| - except Exception as e: |
38 |
| - st.session_state.conversation_history.append(("assistant", f"Erro ao processar vídeo: {e}")) |
| 20 | +# Interface principal |
| 21 | +st.title("🎥 Assistente de Vídeos para Jornalistas") |
39 | 22 |
|
40 |
| - if "conversation_history" in st.session_state: |
41 |
| - for speaker, msg in st.session_state.conversation_history: |
42 |
| - st.markdown(f"**{speaker.title()}:**\n\n{msg}", unsafe_allow_html=True) |
| 23 | +tab1, tab2 = st.tabs(["📼 Transcrição e Análise", "📌 Perguntas sobre o Vídeo"]) |
43 | 24 |
|
44 |
| - with tabs[1]: |
45 |
| - st.subheader("📰 Destaques jornalísticos") |
46 |
| - if "highlights" in st.session_state: |
47 |
| - st.markdown(st.session_state.highlights) |
48 |
| - else: |
49 |
| - st.info("Nenhum destaque gerado ainda.") |
| 25 | +with tab1: |
| 26 | + process_video() |
50 | 27 |
|
51 |
| - with tabs[2]: |
52 |
| - render_rag_tab() |
53 |
| -else: |
54 |
| - st.info("Por favor, insira suas chaves de API para iniciar.") |
| 28 | +with tab2: |
| 29 | + render_rag_tab() |
0 commit comments