MakiAi commited on
Commit
45f42a2
·
2 Parent(s): 3897ed3 be798fa

Merge branch 'develop'

Browse files
Files changed (2) hide show
  1. .streamlit/config.toml +7 -0
  2. app.py +142 -6
.streamlit/config.toml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ [theme]
2
+ primaryColor="#7E84F2" # メインカラー(青紫)- ボタンやリンクなどのアクセント
3
+ backgroundColor="#BFD4D9" # メイン背景色(薄いグレーブルー)- 柔らかな印象
4
+ secondaryBackgroundColor="#FFFFFF" # サイドバーなどの二次的な背景(白)- コントラスト確保
5
+ textColor="#5E608C" # テキストカラー(濃い青紫)- 読みやすさを確保
6
+
7
+ font="sans serif"
app.py CHANGED
@@ -1,9 +1,145 @@
1
  import streamlit as st
 
 
2
  import os
 
3
 
4
- try:
5
- with open("README.md", "r", encoding="utf-8") as f:
6
- readme_content = f.read()
7
- st.markdown(readme_content, unsafe_allow_html=True)
8
- except FileNotFoundError:
9
- st.error("README.mdが見つかりませんでした。")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
+ from configs.agents import *
3
+ from swarm import Swarm
4
  import os
5
+ from datetime import datetime
6
 
7
+ # ページ設定
8
+ st.set_page_config(
9
+ page_title="🐱 Neko Neko Company AI Chat 🐱",
10
+ page_icon="🐱",
11
+ layout="wide"
12
+ )
13
+
14
+ # Swarmクライアントの初期化
15
+ client = Swarm()
16
+
17
+ # セッション状態の初期化
18
+ if 'messages' not in st.session_state:
19
+ st.session_state['messages'] = []
20
+ if 'api_key' not in st.session_state:
21
+ st.session_state['api_key'] = os.getenv("OPENAI_API_KEY", "")
22
+ if 'context_variables' not in st.session_state:
23
+ st.session_state['context_variables'] = {
24
+ "company_context": """neko neko company 会社概要:
25
+
26
+ 設立: 2024年
27
+ 従業員数: 50名
28
+ 事業内容: AIソリューション開発、システムインテグレーション
29
+
30
+ 主要メンバー:
31
+ 1. 代表取締役社長 猫山太郎
32
+ - 元IT企業CTO
33
+ - 経営戦略のスペシャリスト
34
+
35
+ 2. 事業部長 猫田次郎
36
+ - プロジェクトマネジメントの達人
37
+ - 複数の大規模プロジェクト成功実績
38
+
39
+ 3. デザイン部長 三毛猫美咲
40
+ - 国際的なデザイン賞受賞
41
+ - UI/UXデザインの第一人者
42
+
43
+ 4. 技術部長 シャム猫健一
44
+ - AIアーキテクト
45
+ - オープンソースコミッティメンバー
46
+
47
+ 5. 人事部長 黒猫和子
48
+ - 組織開発のエキスパート
49
+ - 従業員満足度向上のスペシャリスト
50
+ """}
51
+
52
+ # サイドバーの設定
53
+ with st.sidebar:
54
+ st.image("https://raw.githubusercontent.com/Sunwood-ai-labs/swarm-neko-neko-company/refs/heads/main/docs/swarm-neko-neko-company.png", use_column_width=True)
55
+ st.title("🐱 Neko Neko Company")
56
+
57
+ # API Key設定セクション
58
+ st.markdown("### ⚙️ API設定")
59
+ api_key = st.text_input("OpenAI API Key", value=os.getenv("OPENAI_API_KEY", ""), type="password")
60
+ if api_key:
61
+ os.environ["OPENAI_API_KEY"] = api_key
62
+ st.success("✅ API Keyが設定されました!")
63
+
64
+ st.markdown("---")
65
+ st.markdown("""
66
+ ### 社内AI支援システム
67
+
68
+ 各部署のAIエージェントが、あなたの質問やリクエストに応答します。
69
+
70
+ #### 🌟 主なエージェント
71
+ - 👋 受付 みけこ
72
+ - 👔 社長 にゃんたろう
73
+ - 📊 事業部長 もふすけ
74
+ - 🎨 デザイン部長 ぷりん
75
+ - 💻 技術部長 たま
76
+ - 🔧 主任エンジニア ごまちゃん
77
+ - 👥 人事部長 ふわり
78
+ """)
79
+
80
+ if st.button("チャットをクリア"):
81
+ st.session_state['messages'] = []
82
+ st.rerun()
83
+
84
+ # メインコンテンツ
85
+ st.title("🐱 Neko Neko Company AI Chat System")
86
+
87
+ # チャット履歴の表示
88
+ for message in st.session_state['messages']:
89
+ with st.chat_message(message["role"], avatar=message.get("avatar")):
90
+ st.write(f"**{message.get('name', 'User')}**: {message['content']}")
91
+
92
+ # ユーザー入力
93
+ if prompt := st.chat_input("メッセージを入力してください..."):
94
+ # ユーザーメッセージの追加
95
+ st.session_state['messages'].append({
96
+ "role": "user",
97
+ "content": prompt,
98
+ "name": "User"
99
+ })
100
+
101
+ with st.chat_message("user"):
102
+ st.write(f"**User**: {prompt}")
103
+
104
+ try:
105
+ # Swarmを使用してエージェントの応答を取得
106
+ messages = [{"role": "user", "content": prompt}]
107
+
108
+ # メッセージプレースホルダーの作成
109
+ with st.chat_message("assistant", avatar="🐱"):
110
+ message_placeholder = st.empty()
111
+ message_placeholder.markdown("🤔 考え中...")
112
+
113
+ # 非ストリーミングモードで実行
114
+ response = client.run(
115
+ agent=triage_agent,
116
+ messages=messages,
117
+ context_variables=st.session_state['context_variables'],
118
+ stream=False
119
+ )
120
+
121
+ # レスポンスからメッセージを取得
122
+ if response and response.messages:
123
+ # 最後のメッセージを取得
124
+ last_message = response.messages[-1]
125
+ full_response = last_message["content"]
126
+ current_agent_name = last_message.get("sender", triage_agent.name)
127
+ message_placeholder.markdown(f"**{current_agent_name}**: {full_response} 🐱")
128
+
129
+ # 全てのエージェントの応答を保存
130
+ if response and response.messages:
131
+ for msg in response.messages:
132
+ if msg["role"] == "assistant":
133
+ st.session_state['messages'].append({
134
+ "role": "assistant",
135
+ "content": msg["content"],
136
+ "name": msg.get("sender", triage_agent.name),
137
+ "avatar": "🐱"
138
+ })
139
+
140
+ except Exception as e:
141
+ st.error(f"エラーが発生しました: {str(e)}")
142
+
143
+ # フッター
144
+ st.markdown("---")
145
+ st.markdown("© 2024 Neko Neko Company. All rights reserved. 🐱")