Skip to content

Commit cf0705d

Browse files
authored
Merge pull request #97 from aws-samples/spy_dev
merge code for main
2 parents 2b053aa + 72f7fe9 commit cf0705d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+3599
-649
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ celerybeat.pid
120120
*.sage.py
121121

122122
# Environments
123-
.env
124123
.venv
125124
env/
126125
venv/

README.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ This is a comprehensive framework designed to enable Generative BI capabilities
55
- Text-to-SQL functionality for querying customized data sources using natural language.
66
- User-friendly interface for adding, editing, and managing data sources, tables, and column descriptions.
77
- Performance enhancement through the integration of historical question-answer ranking and entity recognition.
8+
- Customize business information, including entity information, formulas, SQL samples, and analysis ideas for complex business problems.
9+
- Add agent task splitting function to handle complex attribution analysis problems.
810
- Intuitive question-answering UI that provides insights into the underlying Text-to-SQL mechanism.
911
- Simple agent design interface for handling complex queries through a conversational approach.
1012

@@ -50,10 +52,17 @@ After the role is created, and then add permission by creating inline policy as
5052
"Sid": "VisualEditor0",
5153
"Effect": "Allow",
5254
"Action": [
53-
"bedrock:*",
54-
"dynamodb:*"
55+
"bedrock:InvokeModel",
56+
"bedrock:InvokeModelWithResponseStream",
57+
"dynamodb:*Table",
58+
"dynamodb:*Item",
59+
"dynamodb:Scan",
60+
"dynamodb:Query"
5561
],
56-
"Resource": "*"
62+
"Resource": [
63+
"arn:aws:bedrock:us-west-2::foundation-model/*",
64+
"arn:aws:dynamodb:us-west-2:**YOURACCOUNTID**:table/Nlq*"
65+
]
5766
}
5867
]
5968
}
@@ -171,7 +180,7 @@ the default account is
171180

172181
```
173182
username: admin
174-
password: awsadmin
183+
password: # Please set the password following instructions below
175184
```
176185

177186
if you want change the password or add username, you can change the
@@ -203,8 +212,8 @@ preauthorized:
203212
change the password to hashed password
204213
205214
```python
206-
import streamlit_authenticator as stauth
207-
hashed_passwords = stauth.Hasher(['abc', 'def']).generate()
215+
from streamlit_authenticator.utilities.hasher import Hasher
216+
hashed_passwords = Hasher(['abc', 'def']).generate()
208217
```
209218

210219

README_CN.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
- 通过自然语言查询自定义数据源的Text-to-SQL功能。
88
- 用户友好的界面,可添加、编辑和管理数据源、表和列描述。
99
- 通过集成历史问题答案排名和实体识别来提高性能。
10+
- 自定义业务信息,包括实体信息,公式,SQL样本,复杂业务问题分析思路等。
11+
- 增加agent任务拆分功能,能够处理复杂的归因分析问题。
1012
- 直观的问答界面,可深入了解底层的Text-to-SQL机制。
1113
- 简单的代理设计界面,可通过对话方式处理复杂查询。
1214

@@ -163,7 +165,7 @@ docker exec nlq-webserver python opensearch_deploy.py custom false
163165

164166
```
165167
username: admin
166-
password: awsadmin
168+
password: # 请按照以下教程设定密码
167169
```
168170

169171
如果你想修改密码或者增加用户,可以修改如下文件
@@ -196,8 +198,8 @@ preauthorized:
196198
密码需要从明文转换成哈希过之后的密码,可以通过如下方式,获取
197199
198200
```python
199-
import streamlit_authenticator as stauth
200-
hashed_passwords = stauth.Hasher(['abc', 'def']).generate()
201+
from streamlit_authenticator.utilities.hasher import Hasher
202+
hashed_passwords = Hasher(['abc', 'def']).generate()
201203
```
202204

203205

application/api/enum.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ def get_message(self):
2121
class ContentEnum(Enum):
2222
EXCEPTION = "exception"
2323
COMMON = "common"
24+
STATE = "state"
2425
END = "end"

application/api/main.py

Lines changed: 45 additions & 343 deletions
Large diffs are not rendered by default.

application/api/schemas.py

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ class Question(BaseModel):
1111
agent_cot_flag: bool = True
1212
profile_name: str = "shopping-demo"
1313
explain_gen_process_flag: bool = True
14-
gen_suggested_question_flag: bool = True
14+
gen_suggested_question_flag: bool = False
15+
answer_with_insights: bool = False
1516
top_k: float = 250
1617
top_p: float = 0.9
1718
max_tokens: int = 2048
1819
temperature: float = 0.01
19-
20-
21-
class QuestionSocket(Question):
22-
session_id: str
20+
context_window: int = 3
21+
session_id: str = "-1"
22+
user_id: str = "admin"
2323

2424

2525
class Example(BaseModel):
@@ -28,13 +28,6 @@ class Example(BaseModel):
2828
answer: str
2929

3030

31-
# class Answer(BaseModel):
32-
# examples: list[Example]
33-
# sql: str
34-
# sql_explain: str
35-
# sql_query_result: list[Any]
36-
37-
3831
class QueryEntity(BaseModel):
3932
query: str
4033
sql: str
@@ -45,7 +38,7 @@ class FeedBackInput(BaseModel):
4538
data_profiles: str
4639
query: str
4740
query_intent: str
48-
query_answer_list: list[QueryEntity]
41+
query_answer: str
4942

5043

5144
class Option(BaseModel):
@@ -57,21 +50,23 @@ class CustomQuestion(BaseModel):
5750
custom_question: list[str]
5851

5952

53+
class ChartEntity(BaseModel):
54+
chart_type: str
55+
chart_data: list[Any]
56+
57+
6058
class SQLSearchResult(BaseModel):
6159
sql: str
6260
sql_data: list[Any]
6361
data_show_type: str
6462
sql_gen_process: str
6563
data_analyse: str
64+
sql_data_chart: list[ChartEntity]
6665

6766

6867
class TaskSQLSearchResult(BaseModel):
6968
sub_task_query: str
70-
sql: str
71-
sql_data: list[Any]
72-
data_show_type: str
73-
sql_gen_process: str
74-
data_analyse: str
69+
sql_search_result: SQLSearchResult
7570

7671

7772
class KnowledgeSearchResult(BaseModel):

0 commit comments

Comments
 (0)