Skip to content

Commit

Permalink
Adding example for nl2sql with dail-sql algorithm (modelscope#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
garyzhang99 authored Apr 15, 2024
1 parent b1b6ea5 commit 2eb7892
Show file tree
Hide file tree
Showing 8 changed files with 897 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ the following libraries.
- [Self-Organizing Conversation](./examples/conversation_self_organizing)
- [Basic Conversation with LangChain library](./examples/conversation_with_langchain)
- [Conversation with ReAct Agent](./examples/conversation_with_react_agent)
- [Conversation in Natural Language to Query SQL](./examples/conversation_nl2sql/)
- [Conversation with RAG Agent](./examples/conversation_with_RAG_agents)

- Game
Expand Down
1 change: 1 addition & 0 deletions README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ AgentScope支持使用以下库快速部署本地模型服务。
- [智能体自组织的对话](./examples/conversation_self_organizing)
- [兼容LangChain的基础对话](./examples/conversation_with_langchain)
- [与ReAct智能体对话](./examples/conversation_with_react_agent)
- [通过对话查询SQL信息](./examples/conversation_nl2sql/)
- [与RAG智能体对话](./examples/conversation_with_RAG_agents)

- 游戏
Expand Down
22 changes: 22 additions & 0 deletions examples/conversation_nl2sql/configs/model_configs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[
{
"config_name": "gpt-3.5-turbo",
"model_type": "openai",
"model_name": "gpt-3.5-turbo",
"api_key": "xxx",
"organization": "xxx",
"generate_args": {
"temperature": 0.0
}
},
{
"config_name": "gpt-4",
"model_type": "openai",
"model_name": "gpt-4",
"api_key": "xxx",
"organization": "xxx",
"generate_args": {
"temperature": 0.5
}
}
]
85 changes: 85 additions & 0 deletions examples/conversation_nl2sql/database/concert_singer/schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
PRAGMA foreign_keys = ON;


CREATE TABLE "stadium" (
"Stadium_ID" int,
"Location" text,
"Name" text,
"Capacity" int,
"Highest" int,
"Lowest" int,
"Average" int,
PRIMARY KEY ("Stadium_ID")
);


INSERT INTO "stadium" VALUES (1,"Raith Rovers","Stark's Park","10104","4812","1294","2106");
INSERT INTO "stadium" VALUES (2,"Ayr United","Somerset Park","11998","2363","1057","1477");
INSERT INTO "stadium" VALUES (3,"East Fife","Bayview Stadium","2000","1980","533","864");
INSERT INTO "stadium" VALUES (4,"Queen's Park","Hampden Park","52500","1763","466","730");
INSERT INTO "stadium" VALUES (5,"Stirling Albion","Forthbank Stadium","3808","1125","404","642");
INSERT INTO "stadium" VALUES (6,"Arbroath","Gayfield Park","4125","921","411","638");
INSERT INTO "stadium" VALUES (7,"Alloa Athletic","Recreation Park","3100","1057","331","637");
INSERT INTO "stadium" VALUES (9,"Peterhead","Balmoor","4000","837","400","615");
INSERT INTO "stadium" VALUES (10,"Brechin City","Glebe Park","3960","780","315","552");

CREATE TABLE "singer" (
"Singer_ID" int,
"Name" text,
"Country" text,
"Song_Name" text,
"Song_release_year" text,
"Age" int,
"Is_male" bool,
PRIMARY KEY ("Singer_ID")
);



INSERT INTO "singer" VALUES (1,"Joe Sharp","Netherlands","You","1992",52,"F");
INSERT INTO "singer" VALUES (2,"Timbaland","United States","Dangerous","2008",32,"T");
INSERT INTO "singer" VALUES (3,"Justin Brown","France","Hey Oh","2013",29,"T");
INSERT INTO "singer" VALUES (4,"Rose White","France","Sun","2003",41,"F");
INSERT INTO "singer" VALUES (5,"John Nizinik","France","Gentleman","2014",43,"T");
INSERT INTO "singer" VALUES (6,"Tribal King","France","Love","2016",25,"T");


CREATE TABLE "concert" (
"concert_ID" int,
"concert_Name" text,
"Theme" text,
"Stadium_ID" text,
"Year" text,
PRIMARY KEY ("concert_ID"),
FOREIGN KEY ("Stadium_ID") REFERENCES "stadium"("Stadium_ID")
);



INSERT INTO "concert" VALUES (1,"Auditions","Free choice",1,2014);
INSERT INTO "concert" VALUES (2,"Super bootcamp","Free choice 2",2,2014);
INSERT INTO "concert" VALUES (3,"Home Visits","Bleeding Love",2,2015);
INSERT INTO "concert" VALUES (4,"Week 1","Wide Awake",10,2014);
INSERT INTO "concert" VALUES (5,"Week 1","Happy Tonight",9,2015);
INSERT INTO "concert" VALUES (6,"Week 2","Party All Night",7,2015);


CREATE TABLE "singer_in_concert" (
"concert_ID" int,
"Singer_ID" text,
PRIMARY KEY ("concert_ID","Singer_ID"),
FOREIGN KEY ("concert_ID") REFERENCES "concert"("concert_ID"),
FOREIGN KEY ("Singer_ID") REFERENCES "singer"("Singer_ID")
);

INSERT INTO "singer_in_concert" VALUES (1, 2);
INSERT INTO "singer_in_concert" VALUES (1, 3);
INSERT INTO "singer_in_concert" VALUES (1, 5);
INSERT INTO "singer_in_concert" VALUES (2, 3);
INSERT INTO "singer_in_concert" VALUES (2, 6);
INSERT INTO "singer_in_concert" VALUES (3, 5);
INSERT INTO "singer_in_concert" VALUES (4, 4);
INSERT INTO "singer_in_concert" VALUES (5, 6);
INSERT INTO "singer_in_concert" VALUES (5, 3);
INSERT INTO "singer_in_concert" VALUES (6, 2);

1 change: 1 addition & 0 deletions examples/conversation_nl2sql/database/train.json

Large diffs are not rendered by default.

Loading

0 comments on commit 2eb7892

Please sign in to comment.