Spaces:
Sleeping
Sleeping
Commit ·
d37e3f4
1
Parent(s): 83fd90b
untracking pycache
Browse files- functions/__pycache__/gptResponse.cpython-312.pyc +0 -0
- functions/__pycache__/sidebar.cpython-312.pyc +0 -0
- functions/__pycache__/web_chain.cpython-312.pyc +0 -0
- functions/gptResponse.py +13 -9
- functions/sidebar.py +1 -0
- pages/__pycache__/home.cpython-312.pyc +0 -0
- pages/__pycache__/ragChat.cpython-312.pyc +0 -0
functions/__pycache__/gptResponse.cpython-312.pyc
DELETED
|
Binary file (1.69 kB)
|
|
|
functions/__pycache__/sidebar.cpython-312.pyc
DELETED
|
Binary file (569 Bytes)
|
|
|
functions/__pycache__/web_chain.cpython-312.pyc
DELETED
|
Binary file (2.17 kB)
|
|
|
functions/gptResponse.py
CHANGED
|
@@ -5,7 +5,10 @@ from dotenv import load_dotenv
|
|
| 5 |
import os
|
| 6 |
|
| 7 |
load_dotenv()
|
| 8 |
-
openai_key = os.getenv(
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
def get_response(user_query, chat_history, context):
|
| 11 |
template = """
|
|
@@ -18,20 +21,21 @@ def get_response(user_query, chat_history, context):
|
|
| 18 |
User question: {user_question}
|
| 19 |
"""
|
| 20 |
|
| 21 |
-
|
| 22 |
llm = ChatOpenAI(api_key=openai_key)
|
| 23 |
try:
|
| 24 |
prompt = ChatPromptTemplate.from_template(template)
|
| 25 |
|
| 26 |
llm = ChatOpenAI(api_key=openai_key)
|
| 27 |
-
|
| 28 |
chain = prompt | llm | StrOutputParser()
|
| 29 |
-
|
| 30 |
-
value = chain.stream(
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
|
|
|
|
|
|
| 35 |
if value:
|
| 36 |
response = " ".join([part for part in value])
|
| 37 |
return response
|
|
|
|
| 5 |
import os
|
| 6 |
|
| 7 |
load_dotenv()
|
| 8 |
+
openai_key = os.getenv(
|
| 9 |
+
"OPENAI_API_KEY"
|
| 10 |
+
) # may wanna ask user for this or handle error when its not there
|
| 11 |
+
|
| 12 |
|
| 13 |
def get_response(user_query, chat_history, context):
|
| 14 |
template = """
|
|
|
|
| 21 |
User question: {user_question}
|
| 22 |
"""
|
| 23 |
|
|
|
|
| 24 |
llm = ChatOpenAI(api_key=openai_key)
|
| 25 |
try:
|
| 26 |
prompt = ChatPromptTemplate.from_template(template)
|
| 27 |
|
| 28 |
llm = ChatOpenAI(api_key=openai_key)
|
| 29 |
+
|
| 30 |
chain = prompt | llm | StrOutputParser()
|
| 31 |
+
|
| 32 |
+
value = chain.stream(
|
| 33 |
+
{
|
| 34 |
+
"chat_history": chat_history,
|
| 35 |
+
"context": context,
|
| 36 |
+
"user_question": user_query,
|
| 37 |
+
}
|
| 38 |
+
)
|
| 39 |
if value:
|
| 40 |
response = " ".join([part for part in value])
|
| 41 |
return response
|
functions/sidebar.py
CHANGED
|
@@ -2,5 +2,6 @@ import streamlit as st
|
|
| 2 |
|
| 3 |
|
| 4 |
def sidebar():
|
|
|
|
| 5 |
st.sidebar.page_link("pages/home.py", label="Home", icon="🏠")
|
| 6 |
st.sidebar.page_link("pages/ragChat.py", label="RAG CHAT", icon="💬")
|
|
|
|
| 2 |
|
| 3 |
|
| 4 |
def sidebar():
|
| 5 |
+
st.sidebar.title("Navigation")
|
| 6 |
st.sidebar.page_link("pages/home.py", label="Home", icon="🏠")
|
| 7 |
st.sidebar.page_link("pages/ragChat.py", label="RAG CHAT", icon="💬")
|
pages/__pycache__/home.cpython-312.pyc
DELETED
|
Binary file (711 Bytes)
|
|
|
pages/__pycache__/ragChat.cpython-312.pyc
DELETED
|
Binary file (5.97 kB)
|
|
|