init
This commit is contained in:
parent
ece9e0644d
commit
db3fb182f2
37
main.py
37
main.py
@ -1,6 +1,33 @@
|
||||
class HelloWorld:
|
||||
def __init__(self):
|
||||
print("Hello, World!")
|
||||
import streamlit as st
|
||||
import requests
|
||||
|
||||
if __name__ == "__main__":
|
||||
hello = HelloWorld()
|
||||
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}")
|
||||
|
Loading…
Reference in New Issue
Block a user