2024-10-13 04:55:54 +00:00
|
|
|
import streamlit as st
|
|
|
|
import requests
|
2024-10-12 19:26:45 +00:00
|
|
|
|
2024-10-13 04:55:54 +00:00
|
|
|
if "history" not in st.session_state:
|
|
|
|
st.session_state.history = []
|
|
|
|
|
|
|
|
|
|
|
|
def send_post_request(prompt):
|
|
|
|
url = "http://localhost:19194/"
|
|
|
|
payload = prompt.title()
|
|
|
|
response = requests.post(url, json=payload)
|
|
|
|
|
|
|
|
return response.text
|
|
|
|
|
|
|
|
|
|
|
|
st.title("Prompt History and Post Request App")
|
|
|
|
|
|
|
|
prompt = st.text_input("Enter your prompt:")
|
|
|
|
|
|
|
|
if st.button("Submit"):
|
|
|
|
if prompt:
|
|
|
|
st.session_state.history.append(prompt)
|
|
|
|
response = send_post_request(prompt)
|
|
|
|
|
|
|
|
st.success(f"Response: {response}")
|
|
|
|
else:
|
|
|
|
st.error("Please enter a prompt")
|
|
|
|
|
|
|
|
# Display history of prompts
|
|
|
|
if st.session_state.history:
|
|
|
|
st.write("### Prompt History")
|
|
|
|
for i, p in enumerate(st.session_state.history, 1):
|
|
|
|
st.write(f"{i}. {p}")
|