|
from langchain_core.prompts import ChatPromptTemplate
|
|
from langchain_openai import ChatOpenAI, OpenAIEmbeddings
|
|
from langchain_community.vectorstores import Chroma
|
|
from engine.tools import RAGTool, CareerRoadmapGenerator
|
|
from engine.langchain_agent import create_agent,run_agent
|
|
from bot.rag_indexing.indexing import retriever_from_docs
|
|
|
|
import streamlit as st
|
|
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
|
|
import asyncio
|
|
from dotenv import load_dotenv
|
|
load_dotenv()
|
|
from bot.data_innput.input import user_input
|
|
|
|
st.set_page_config(page_title="Career Roadmap Generator")
|
|
st.header("Career Roadmap Generator")
|
|
st.write('Allows users to interact with the LLM')
|
|
|
|
if "memory" not in st.session_state:
|
|
st.session_state["memory"] = [{"role": "system", "content": "You are a helpful assistant for generating career roadmaps."}]
|
|
|
|
if "agent" not in st.session_state:
|
|
|
|
model_name = "gpt-4-turbo-preview"
|
|
st.session_state['agent'] = create_agent(model_name)
|
|
|
|
|
|
for message in st.session_state["memory"]:
|
|
if message["role"] == "assistant":
|
|
with st.chat_message(message["role"]):
|
|
msg = message["content"]["output"]
|
|
if "/bot/images/dall-e" in msg:
|
|
address = msg.split("(")[1][:-1]
|
|
print("address:",address)
|
|
st.image(address)
|
|
else:
|
|
st.markdown(msg)
|
|
elif message["role"] == "system":
|
|
pass
|
|
else:
|
|
with st.chat_message(message["role"]):
|
|
st.markdown(message["content"])
|
|
|
|
|
|
url = st.text_input("Please enter the job url:")
|
|
job_details = user_input(url)
|
|
|
|
|
|
if prompt := st.chat_input("Your message ..."):
|
|
st.session_state['memory'].append({"role":"user","content":prompt})
|
|
with st.chat_message("user"):
|
|
st.markdown(prompt)
|
|
response = asyncio.run(run_agent(st.session_state["agent"],prompt))
|
|
st.session_state['memory'].append({"role":"assistant","content":response})
|
|
with st.chat_message("assistant"):
|
|
if "/bot/images/dall-e" in response["output"]:
|
|
address = response["output"].split("(")[1][:-1]
|
|
st.image(address)
|
|
else:
|
|
st.markdown(response["output"])
|
|
|