-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean llm-app, and make streamlit ui more visible (#6528)
GitOrigin-RevId: 32d78c9faaa6482f3615bef0a98d8a93629aebdb
- Loading branch information
1 parent
0543cbe
commit 52b6b5a
Showing
42 changed files
with
741 additions
and
146 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file removed
BIN
-3.82 MB
examples/data/q_earnings/FY22_Q4_Consolidated_Financial_Statements.pdf
Binary file not shown.
Binary file removed
BIN
-2.99 MB
examples/data/q_earnings/FY23_Q1_Consolidated_Financial_Statements.pdf
Binary file not shown.
Binary file removed
BIN
-2.58 MB
examples/data/q_earnings/FY23_Q2_Consolidated_Financial_Statements.pdf
Binary file not shown.
Binary file removed
BIN
-2.99 MB
examples/data/q_earnings/FY23_Q3_Consolidated_Financial_Statements.pdf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import os | ||
|
||
import requests | ||
import streamlit as st | ||
from dotenv import load_dotenv | ||
|
||
with st.sidebar: | ||
st.markdown( | ||
"[View the source code on GitHub](https://github.com/pathwaycom/llm-app)" | ||
) | ||
|
||
# Load environment variables | ||
load_dotenv() | ||
api_host = os.environ.get("PATHWAY_REST_CONNECTOR_HOST", "127.0.0.1") | ||
api_port = int(os.environ.get("PATHWAY_REST_CONNECTOR_PORT", 8080)) | ||
|
||
|
||
# Streamlit UI elements | ||
st.title("LLM App") | ||
|
||
|
||
# Initialize chat history | ||
if "messages" not in st.session_state: | ||
st.session_state.messages = [] | ||
|
||
# Display chat messages from history on app rerun | ||
for message in st.session_state.messages: | ||
with st.chat_message(message["role"]): | ||
st.markdown(message["content"]) | ||
|
||
|
||
# React to user input | ||
if prompt := st.chat_input("How can I help you today?"): | ||
# Display user message in chat message container | ||
with st.chat_message("user"): | ||
st.markdown(prompt) | ||
|
||
# Add user message to chat history | ||
st.session_state.messages.append({"role": "user", "content": prompt}) | ||
|
||
url = f"http://{api_host}:{api_port}/" | ||
data = {"query": prompt, "user": "user"} | ||
|
||
response = requests.post(url, json=data) | ||
|
||
if response.status_code == 200: | ||
response = response.json() | ||
with st.chat_message("assistant"): | ||
st.markdown(response) | ||
st.session_state.messages.append({"role": "assistant", "content": response}) | ||
else: | ||
st.error( | ||
f"Failed to send data to Discounts API. Status code: {response.status_code}" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
415 changes: 415 additions & 0 deletions
415
examples/pipelines/contextful_geometric/data/pathway-docs.jsonl
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import os | ||
|
||
import requests | ||
import streamlit as st | ||
from dotenv import load_dotenv | ||
|
||
with st.sidebar: | ||
st.markdown( | ||
"[View the source code on GitHub](https://github.com/pathwaycom/llm-app)" | ||
) | ||
|
||
# Load environment variables | ||
load_dotenv() | ||
api_host = os.environ.get("PATHWAY_REST_CONNECTOR_HOST", "127.0.0.1") | ||
api_port = int(os.environ.get("PATHWAY_REST_CONNECTOR_PORT", 8080)) | ||
|
||
|
||
# Streamlit UI elements | ||
st.title("LLM App") | ||
|
||
|
||
# Initialize chat history | ||
if "messages" not in st.session_state: | ||
st.session_state.messages = [] | ||
|
||
# Display chat messages from history on app rerun | ||
for message in st.session_state.messages: | ||
with st.chat_message(message["role"]): | ||
st.markdown(message["content"]) | ||
|
||
|
||
# React to user input | ||
if prompt := st.chat_input("How can I help you today?"): | ||
# Display user message in chat message container | ||
with st.chat_message("user"): | ||
st.markdown(prompt) | ||
|
||
# Add user message to chat history | ||
st.session_state.messages.append({"role": "user", "content": prompt}) | ||
|
||
url = f"http://{api_host}:{api_port}/" | ||
data = {"query": prompt, "user": "user"} | ||
|
||
response = requests.post(url, json=data) | ||
|
||
if response.status_code == 200: | ||
response = response.json() | ||
with st.chat_message("assistant"): | ||
st.markdown(response) | ||
st.session_state.messages.append({"role": "assistant", "content": response}) | ||
else: | ||
st.error( | ||
f"Failed to send data to Discounts API. Status code: {response.status_code}" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import os | ||
|
||
import requests | ||
import streamlit as st | ||
from dotenv import load_dotenv | ||
|
||
with st.sidebar: | ||
st.markdown( | ||
"[View the source code on GitHub](https://github.com/pathwaycom/llm-app)" | ||
) | ||
|
||
# Load environment variables | ||
load_dotenv() | ||
api_host = os.environ.get("PATHWAY_REST_CONNECTOR_HOST", "127.0.0.1") | ||
api_port = int(os.environ.get("PATHWAY_REST_CONNECTOR_PORT", 8080)) | ||
|
||
|
||
# Streamlit UI elements | ||
st.title("LLM App") | ||
|
||
|
||
# Initialize chat history | ||
if "messages" not in st.session_state: | ||
st.session_state.messages = [] | ||
|
||
# Display chat messages from history on app rerun | ||
for message in st.session_state.messages: | ||
with st.chat_message(message["role"]): | ||
st.markdown(message["content"]) | ||
|
||
|
||
# React to user input | ||
if prompt := st.chat_input("How can I help you today?"): | ||
# Display user message in chat message container | ||
with st.chat_message("user"): | ||
st.markdown(prompt) | ||
|
||
# Add user message to chat history | ||
st.session_state.messages.append({"role": "user", "content": prompt}) | ||
|
||
url = f"http://{api_host}:{api_port}/" | ||
data = {"query": prompt, "user": "user"} | ||
|
||
response = requests.post(url, json=data) | ||
|
||
if response.status_code == 200: | ||
response = response.json() | ||
with st.chat_message("assistant"): | ||
st.markdown(response) | ||
st.session_state.messages.append({"role": "assistant", "content": response}) | ||
else: | ||
st.error( | ||
f"Failed to send data to Discounts API. Status code: {response.status_code}" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.