File size: 2,673 Bytes
9dcfa9a
 
 
 
98915c7
 
 
 
9dcfa9a
 
ee01f11
 
 
cfde529
9dcfa9a
cfde529
 
98915c7
9dcfa9a
96c99bd
98915c7
 
ee01f11
9dcfa9a
 
98915c7
 
 
 
ee01f11
 
 
 
 
 
 
 
 
 
 
 
 
 
98915c7
 
 
ee01f11
96c99bd
9dcfa9a
ee01f11
 
 
9dcfa9a
 
 
 
 
 
 
 
d8796fc
ee01f11
d8796fc
 
ee01f11
 
9dcfa9a
ee01f11
 
cfde529
ee01f11
 
 
9dcfa9a
ee01f11
14a0aaa
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import streamlit as st
from streamlit_option_menu import option_menu
import pandas as pd
import os
import warnings
from langchain_community.utilities import GoogleSerperAPIWrapper
from langchain.agents import initialize_agent, Tool
from langchain.agents import AgentType
from langchain_groq import ChatGroq
from dotenv import load_dotenv
from funcs.llm import LLM
from views import home,upload_data,define_query,extract_information,view_and_download
from views.extract_information import ExtractInformation

warnings.filterwarnings("ignore", category=DeprecationWarning)


#environment
load_dotenv()
GROQ_API_KEY = os.getenv("GROQ_API_KEY")
SERPER_API_KEY = os.getenv("SERPER_API_KEY")
search = GoogleSerperAPIWrapper(serp_api_key=SERPER_API_KEY)
model = ChatGroq(model="llama-3.2-11b-vision-preview")


tools = [
    Tool(
        name="Web Search",
        func=search.run,
        description=(
            "This is your primary tool to search the web when you need information "
            "that is not available in the given context. Always provide a precise and specific search query "
            "when using this tool. Use it to retrieve up-to-date or detailed information such as locations, dates, "
            "contacts, addresses, company details, or any specific entity-related facts. "
            "Avoid making assumptions—only use the Web Search if the context does not have the needed details."
            "\n\nImportant Instructions:\n"
            "- Do not generate answers based on assumptions.\n"
            "- Use Web Search for facts that require external verification.\n"
            "- Provide concise and accurate search queries.\n"
            "- Return the most authoritative and recent data."
        ),
        return_direct=False,
        handle_tool_error=True  
    )
]

llm = LLM(tools,model,search)

st.set_page_config(page_title="DataScribe", page_icon=":notebook_with_decorative_cover:", layout="wide")
if "results" not in st.session_state:
    st.session_state["results"] = [] 
    
with st.sidebar:
    selected = option_menu(
        "DataScribe Menu",
        ["Home", "Upload Data", "Define Query", "Extract Information", "View & Download"],
        icons=["house", "cloud-upload", "gear", "search", "table"],
        menu_icon="cast",
        default_index=0
    )
if selected == "Home":
    home.CreatePage()

elif selected == "Upload Data":
    upload_data.CreatePage()
    
elif selected == "Define Query":
    define_query.CreatePage()
    
elif selected == "Extract Information":
    extract = ExtractInformation(llm)
    extract.CreatePage()
   
elif selected == "View & Download":
    view_and_download.CreatePage()