-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate.sh
More file actions
118 lines (95 loc) · 2.66 KB
/
create.sh
File metadata and controls
118 lines (95 loc) · 2.66 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/bash
# Exit on error
set -e
# Create directory structure
mkdir -p config models services handlers ui utils
# Create __init__.py files
touch config/__init__.py models/__init__.py services/__init__.py handlers/__init__.py ui/__init__.py utils/__init__.py
# Create key files
cat > config/settings.py <<EOL
# Configuration and constants
APP_NAME = "Streamlit LLM App"
VERSION = "1.0.0"
EOL
cat > models/candidate.py <<EOL
# Data models for candidate
class Candidate:
def __init__(self, name, experience):
self.name = name
self.experience = experience
EOL
cat > services/llm_service.py <<EOL
# LLM integration service
def get_llm_response(prompt: str) -> str:
return f"Response to: {prompt}"
EOL
cat > services/validation_service.py <<EOL
# Input validation service
def validate_input(user_input: str) -> bool:
return bool(user_input and user_input.strip())
EOL
cat > handlers/conversation_handler.py <<EOL
# Conversation flow logic
def handle_conversation(user_input: str) -> str:
from services.llm_service import get_llm_response
return get_llm_response(user_input)
EOL
cat > handlers/state_handler.py <<EOL
# Session state management
import streamlit as st
def init_state():
if 'messages' not in st.session_state:
st.session_state.messages = []
EOL
cat > ui/components.py <<EOL
# UI components
import streamlit as st
def render_header():
st.title("Streamlit LLM App")
def render_input():
return st.text_input("Your message")
EOL
cat > ui/styles.py <<EOL
# Custom CSS or Streamlit styles
def apply_styles():
return """
<style>
body { font-family: sans-serif; }
</style>
"""
EOL
cat > utils/helpers.py <<EOL
# Utility functions
def format_message(msg: str) -> str:
return msg.strip().capitalize()
EOL
# Main app
cat > main.py <<EOL
import streamlit as st
from handlers.state_handler import init_state
from handlers.conversation_handler import handle_conversation
from ui.components import render_header, render_input
from ui.styles import apply_styles
# Apply styles
st.markdown(apply_styles(), unsafe_allow_html=True)
# Initialize session state
init_state()
# Render UI
render_header()
user_msg = render_input()
if user_msg:
reply = handle_conversation(user_msg)
st.session_state.messages.append({"user": user_msg, "bot": reply})
# Display conversation
for chat in st.session_state.messages:
st.write(f"**You:** {chat['user']}")
st.write(f"**Bot:** {chat['bot']}")
EOL
# Requirements
cat > requirements.txt <<EOL
streamlit
EOL
echo "Project structure created successfully."
echo "To run the app:"
echo "1. Install dependencies: pip install -r requirements.txt"
echo "2. Run: streamlit run main.py"