-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
more work on getting-started/task-engine example
- Loading branch information
Tony Worm
committed
May 26, 2024
1 parent
2be9007
commit e0c5be0
Showing
3 changed files
with
90 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package examples | ||
|
||
import "strings" | ||
|
||
server: { | ||
@flow(server) | ||
|
||
// task: get auth from external command | ||
gcp: { | ||
@task(os.Exec) | ||
cmd: ["gcloud", "auth", "print-access-token"] | ||
stdout: string | ||
key: strings.TrimSpace(stdout) | ||
} | ||
|
||
run: { | ||
@task(api.Serve) | ||
|
||
port: "8080" | ||
routes: { | ||
|
||
// simple hello route | ||
"/hello": { | ||
method: "GET" | ||
resp: { | ||
status: 200 | ||
body: "hallo chat!" | ||
} | ||
} | ||
|
||
// echo request object back as json | ||
"/jsonecho": { | ||
method: ["GET", "POST"] | ||
req: body: {} | ||
resp: json: req | ||
} | ||
|
||
// our gemini call warpped in an API | ||
"/chat": { | ||
@flow() | ||
|
||
method: "POST" | ||
|
||
// input schema | ||
req: { | ||
body: { | ||
msg: string | ||
} | ||
} | ||
|
||
// task: api call via reusable task | ||
call: _gemini & { | ||
apikey: gcp.key | ||
msg: req.body.msg | ||
} | ||
|
||
// the response to user | ||
resp: { | ||
status: 200 | ||
body: call.final.text | ||
} | ||
} | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters