Skip to content

Commit b1ddce5

Browse files
committed
Update docs
1 parent 6c711da commit b1ddce5

File tree

7 files changed

+110
-77
lines changed

7 files changed

+110
-77
lines changed

docs/guide/_meta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
{
1313
"type": "dir",
14-
"name": "web-dsl",
14+
"name": "web",
1515
"label": "Web"
1616
},
1717
{
File renamed without changes.

docs/index.md

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,3 @@
11
---
22
pageType: home
3-
4-
hero:
5-
name: AIScript
6-
text: The next generation language for human and AI.
7-
# tagline: This is the tagline
8-
actions:
9-
- theme: brand
10-
text: Quick Start
11-
link: /guide/
12-
- theme: alt
13-
text: GitHub
14-
link: https://github.com/aiscriptdev/aiscript
15-
image:
16-
src: /tuocan.png
17-
alt: Logo
183
---
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
```toml
2+
[auth.jwt]
3+
secret = "$JWT_SECRET"
4+
expiration = 3600
5+
6+
[auth.basic]
7+
username = "admin"
8+
password = "123456"
9+
```
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
```toml
2+
[sso.google]
3+
client_id = "123"
4+
client_secret = "abc"
5+
redirect_url = "http://localhost:8080/callback"
6+
scopes = ["email"]
7+
8+
[sso.github]
9+
client_id = "123"
10+
client_secret = "abc"
11+
redirect_url = "http://localhost:8080/callback"
12+
scopes = ["email"]
13+
```

theme/components/Landingpage/features.yaml

Lines changed: 86 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -92,64 +92,41 @@ web:
9292
// Request validation
9393
query {
9494
message: str,
95-
model?: str = "gpt-3.5-turbo"
95+
model: str = "gpt-3.5-turbo"
9696
}
9797
98-
// Response handling
99-
response {
100-
content: str,
101-
tokens: int
102-
}
103-
104-
// Route handler
105-
fn handle(req) -> response {
106-
let answer = prompt req.query.message => req.query.model;
107-
return {
108-
content: answer,
109-
tokens: len(answer)
110-
};
111-
}
98+
let answer = prompt query.message => {
99+
model: query.model
100+
};
101+
return { answer };
112102
}
113103
filename: routes.ai
114104
- title: Validator
115105
description: "Built-in request validation with type checking and custom validation rules for secure API endpoints."
116106
codeDemos:
117107
- code: |
118-
route POST "/api/user" {
108+
post /api/user {
119109
// Request body validation
110+
@json
120111
body {
121-
username: str {
122-
min_length: 3,
123-
max_length: 20,
124-
pattern: "^[a-zA-Z0-9_]+$"
125-
},
126-
email: str {
127-
format: "email"
128-
},
129-
age: int {
130-
minimum: 18
131-
}
112+
@string(min_length: 3, max_length: 20, pattern: "^[a-zA-Z0-9_]+$")
113+
username: str,
114+
@format(type="email")
115+
email: str,
116+
@number(min=18)
117+
age: int,
132118
}
133119
134-
fn handle(req) -> str {
135-
// Body is already validated
136-
db.users.create(req.body);
137-
return "User created successfully";
138-
}
120+
// Body is already validated
121+
db.users.create(req.body);
122+
return "User created successfully";
139123
}
140124
filename: validator.ai
141125
- title: OpenAPI
142126
description: "Automatic OpenAPI documentation generation from your route definitions with full type information and examples."
143127
codeDemos:
144128
- code: |
145-
// OpenAPI configuration
146-
openapi {
147-
title: "Chat API",
148-
version: "1.0.0",
149-
description: "AI-powered chat API"
150-
}
151-
152-
route POST "/api/chat" {
129+
post /api/chat {
153130
// This will be included in OpenAPI docs
154131
@doc "Create a new chat message"
155132
@tag "Chat"
@@ -168,34 +145,82 @@ web:
168145
}
169146
}
170147
filename: openapi.ai
171-
- title: Effortless Social Login
148+
- title: Effortless Auth and Social Login
172149
description: "Integrate social login providers with minimal configuration and type-safe authentication flows."
173150
codeDemos:
174151
- code: |
175-
// Configure auth providers
176-
auth {
177-
providers: {
178-
github: {
179-
client_id: env.GITHUB_CLIENT_ID,
180-
client_secret: env.GITHUB_CLIENT_SECRET
181-
},
182-
google: {
183-
client_id: env.GOOGLE_CLIENT_ID,
184-
client_secret: env.GOOGLE_CLIENT_SECRET
185-
}
186-
},
187-
callbacks: {
188-
async on_success(user) {
189-
await db.users.upsert(user);
190-
return redirect("/dashboard");
152+
// JWT auth
153+
@auth
154+
get /ask {
155+
query {
156+
@string(min_len=5, max_len=50)
157+
question: str
158+
}
159+
160+
ai fn ask_llm(question: str) -> str {
161+
return prompt question;
162+
}
163+
let answer = ask_llm(query.question);
164+
return answer;
165+
}
166+
filename: jwt_auth.ai
167+
- code: |
168+
// Username/Password auth
169+
@basic_auth
170+
post /guess {
171+
body {
172+
@number(min=1, max=100)
173+
magic: int = 1
174+
}
175+
176+
header.path = "/guess";
177+
let msg = "Try again!";
178+
if body.magic == 42 {
179+
msg = "You guessed it!";
180+
}
181+
return {
182+
body: msg,
183+
headers: {
184+
path: "/guess",
191185
}
186+
};
187+
}
188+
filename: basic_auth.ai
189+
- code: |
190+
@sso(provider="google")
191+
get /auth/google {
192+
let url = sso.authority_url();
193+
print(url);
194+
return temporary_redirect(target=url);
195+
}
196+
197+
@sso(provider="google")
198+
get /auth/google/callback {
199+
query {
200+
state: str,
201+
code: str,
192202
}
203+
204+
let user_info = sso.verify(state, code);
205+
print(user_info);
206+
return user_info;
193207
}
208+
filename: google_login.ai
209+
- code: |
210+
[auth.jwt]
211+
secret = "$JWT_SECRET"
212+
expiration = 3600
213+
214+
[auth.basic]
215+
username = "admin"
216+
password = "123456"
194217
195-
// Auth routes are automatically created
196-
// /auth/github
197-
// /auth/google
198-
filename: auth.ai
218+
[sso.google]
219+
client_id = "123"
220+
client_secret = "abc"
221+
redirect_url = "http://localhost:8080/auth/google/callback"
222+
scopes = ["email"]
223+
filename: project.toml
199224
200225
language:
201226
- title: Enum

theme/components/Landingpage/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const LandingPage = () => {
2020
<Hero
2121
showStars
2222
subTitle="The next generation language for human and AI."
23+
description='Dedicated for building AI applications.'
2324
getStartedButtonText='getStarted'
2425
githubURL="https://github.com/aiscriptdev/aiscript"
2526
onClickGetStarted={onClickGetStarted}

0 commit comments

Comments
 (0)