-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
35 lines (27 loc) · 1.39 KB
/
app.py
File metadata and controls
35 lines (27 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import streamlit as st
import sandworm
st.set_page_config(
page_title="SandWorm: Your Farming Companion for Regenerative Agriculture",
layout="wide",
page_icon="🧑🌾",
initial_sidebar_state="expanded",
menu_items={"About": "Built by @dcarpintero"},
)
st.title("🧑🌾 Helping Farmers around The World!")
def query_llm(prompt):
st.session_state.messages.append({"role": "user", "content": prompt})
st.chat_message("user").write(prompt)
response = sandworm.generate_season_plan(prompt)
st.session_state.messages.append({"role": "assistant", "content": response})
st.chat_message("assistant").write(response)
if "messages" not in st.session_state:
st.session_state["messages"] = [{"role": "assistant",
"content": """Hi there! It's SandWorm, an AI farming assistant. I will create a personal farming plan for your family needs!"""}]
st.session_state.messages.append({"role": "assistant",
"content": """Just tell me where is your land located, how many family members you have, and your planned monthly income from exceeds."""})
for msg in st.session_state.messages:
# skip system messages
if msg["role"] != "system":
st.chat_message(msg["role"]).write(msg["content"])
if prompt := st.chat_input():
query_llm(prompt)