File size: 6,592 Bytes
973212e
 
 
 
 
 
 
b8e9809
 
 
 
 
 
 
 
 
 
 
21703b6
b8e9809
 
 
 
 
 
21703b6
 
 
9f28f76
b8e9809
 
 
 
21703b6
 
 
b8e9809
 
9f28f76
21703b6
 
 
 
 
 
 
 
b8e9809
 
 
 
6b7c40c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b02d824
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49ec43a
 
 
 
 
4fdb053
6dfa2f3
 
4fdb053
 
 
 
 
 
 
 
 
 
 
 
 
c18184f
4fdb053
 
 
 
 
 
 
59b9d1f
4fdb053
 
 
b02d824
4fdb053
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59b9d1f
d845172
 
 
 
 
 
59b9d1f
49ec43a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
import streamlit as st 
import os
from langchain_huggingface import HuggingFaceEndpoint, HuggingFacePipeline, ChatHuggingFace
from langchain_core.messages import HumanMessage,SystemMessage,AIMessage

hf_token = os.getenv("HF_TOKEN")


# Set the default page in session state
if "page" not in st.session_state:
    st.session_state.page = "home"

# Function to switch pages
def switch_page(page_name):
    st.session_state.page = page_name

# Home page with buttons for different domains
if st.session_state.page == "home":
    st.title("๐Ÿค– Innomatics ChatGenius Hub")
    st.markdown("Choose a domain to chat with an expert model:")

    col1, col2, col3 = st.columns(3)
    with col1:
        if st.button("Python ๐Ÿ"):
            switch_page("python")
        if st.button("Statistics ๐Ÿ“ˆ"):
            switch_page("statistics")
        
        

    with col2:
        if st.button("SQL ๐Ÿ›ข๏ธ"):
            switch_page("sql")
        if st.button("Machine Learning ๐Ÿค–"):
            switch_page("ml")
        

    with col3:
        if st.button("Power BI ๐Ÿ“Š"):
            switch_page("powerbi")
        if st.button("Deep Learning ๐Ÿง "):
            switch_page("deeplearning")
    with col2:
        if st.button("GenAI๐Ÿ”ฎ๐Ÿค–"):
            switch_page("genai")
            
        

# Example domain-specific chatbot page
elif st.session_state.page == "python":
    st.title("Python Chatbot ๐Ÿ")
#     hf_token = os.getenv("HUGGINGFACEHUB_API_TOKEN") or os.getenv("HF_TOKEN")
#     if not hf_token:
#         st.error("Please add your Hugging Face API token to Secrets (HUGGINGFACEHUB_API_TOKEN or HF_TOKEN).")
#         st.stop()

# # Setup the LangChain HuggingFaceEndpoint and ChatHuggingFace LLM
#     deep_seek_model = HuggingFaceEndpoint(
#     repo_id="deepseek-ai/DeepSeek-R1",
#     # provider = 'nebius'
#     temperature=0.7,
#     max_new_tokens=100,
#     task="conversational",
#     huggingfacehub_api_token=hf_token,
#     )

#     deepseek = ChatHuggingFace(
#     llm=deep_seek_model,
#     repo_id="deepseek-ai/DeepSeek-R1",
#     # provider="nebius",
#     temperature=0.7,
#     max_new_tokens=100,
#     task="conversational"
#     )


    gemma_model = HuggingFaceEndpoint(
    repo_id="google/gemma-3-27b-it",
    temperature=0.7,
    max_new_tokens=512,
    task="conversational",
    huggingfacehub_api_token=hf_token,
    )

    chat_gemma = ChatHuggingFace(
    llm=gemma_model,
    repo_id="google/gemma-3-27b-it",
    temperature=0.7,
    max_new_tokens=512,
    task="conversational",
    )
# Initialize session state for chat history
    if "messages" not in st.session_state:
        st.session_state.messages = [
        SystemMessage(content="Answer like a 10 year experinced Python developer")
    ]

    def generate_response(user_input):
    # Append user message
        st.session_state.messages.append(HumanMessage(content=user_input))
    # Invoke the model
        response = deepseek.invoke(st.session_state.messages)
    # Append AI response
        st.session_state.messages.append(AIMessage(content=response))
        return response

# User input
    user_input = st.text_input("Ask a question about Python:")

    if user_input:
        with st.spinner("Getting answer..."):
            answer = generate_response(user_input)
        st.markdown(f"**Answer:** {answer}")

# Display chat history
    if st.session_state.messages:
        for msg in st.session_state.messages[1:]:  # skip initial SystemMessage
            if isinstance(msg, HumanMessage):
                st.markdown(f"**You:** {msg.content}")
            elif isinstance(msg, AIMessage):
                st.markdown(f"**Bot:** {msg.content}")
    st.button("โฌ…๏ธ Back to Home", on_click=lambda: switch_page("home"))
    # Here you can load your Python LLM and chat interface

elif st.session_state.page == "sql":
    st.title("SQL Chatbot ๐Ÿ›ข๏ธ")
    if not hf_token:
        st.error("Please add your Hugging Face API token as an environment variable.")
        st.stop()

# Initialize the LLaMA model from HuggingFace (via Nebius provider)
    llama_model = HuggingFaceEndpoint(
    repo_id="meta-llama/Llama-3.1-8B-Instruct",
    temperature=0.7,
    max_new_tokens=512,
    task="conversational",
    huggingfacehub_api_token=hf_token,
    )

    llama = ChatHuggingFace(
    llm=llama_model,
    repo_id="meta-llama/Llama-3.1-8B-Instruct",
    # provider="nebius",
    temperature=0.7,
    max_new_tokens=512,
    task="conversational"
    )

# Streamlit A

    st.markdown("Ask anything related to SQL interviews!")

# Initialize chat history
    if "messages" not in st.session_state:
        st.session_state.messages = [SystemMessage(content="Answer clearly like a technical 10 year experienced person in SQL .")]

# User input
    user_input = st.text_input("๐Ÿ’ก Ask your SQL interview question:", placeholder="e.g., give me 10 SQL interview questions with answers")

    def generate_response(user_input):
        st.session_state.messages.append(HumanMessage(content=user_input))
        response = llama.invoke(st.session_state.messages)
        st.session_state.messages.append(AIMessage(content=response))
        return response

# Display response
    if user_input:
        with st.spinner("Thinking..."):
            answer = generate_response(user_input)
            st.markdown(f"**Answer:** {answer}")

# Show chat history
    st.markdown("### ๐Ÿ“œ Chat History")
    for msg in st.session_state.messages[1:]:  # Skip SystemMessage
        if isinstance(msg, HumanMessage):
            st.markdown(f"**You:** {msg.content}")
        elif isinstance(msg, AIMessage):
            st.markdown(f"**Bot:** {msg.content}")
        st.button("โฌ…๏ธ Back to Home", on_click=lambda: switch_page("home"))
        # Load SQL chatbot here

elif st.session_state.page == "powerbi":
    st.title("Power BI Chatbot ๐Ÿ“Š")
    st.button("โฌ…๏ธ Back to Home", on_click=lambda: switch_page("home"))

elif st.session_state.page == "ml":
    st.title("Machine Learning Chatbot ๐Ÿค–")
    st.button("โฌ…๏ธ Back to Home", on_click=lambda: switch_page("home"))

elif st.session_state.page == "deeplearning":
    st.title("Deep Learning Chatbot ๐Ÿง ")
    st.button("โฌ…๏ธ Back to Home", on_click=lambda: switch_page("home"))

elif st.session_state.page == "statistics":
    st.title("Statistics Chatbot ๐Ÿ“ˆ")
    st.button("โฌ…๏ธ Back to Home", on_click=lambda: switch_page("home"))

elif st.session_state.page == "genai":
    st.title("GenAI Chatbot ๐Ÿ“ˆ")
    st.button("โฌ…๏ธ Back to Home", on_click=lambda: switch_page("home"))