-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1515 from Jaseci-Labs/littleX_doc
Jaseci cookbook
- Loading branch information
Showing
4 changed files
with
270 additions
and
4 deletions.
There are no files selected for viewing
92 changes: 92 additions & 0 deletions
92
jac/support/jac-lang.org/docs/learn/littleX/src/Jac_cloud_example.jac
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,92 @@ | ||
import:py from jac_cloud {FastAPI} | ||
|
||
walker post_no_body {} | ||
|
||
walker post_with_body { | ||
has a: str; | ||
} | ||
|
||
walker get_no_body { | ||
obj __specs__ { | ||
static has methods: list = ["get"]; | ||
} | ||
} | ||
|
||
walker get_with_query { | ||
has a: str; | ||
|
||
obj __specs__ { | ||
static has methods: list = ["get"], as_query: list = ["a"]; | ||
} | ||
} | ||
|
||
walker get_all_query { | ||
has a: str; | ||
has b: str; | ||
|
||
obj __specs__ { | ||
static has methods: list = ["get"], as_query: list = "*", auth: bool = False; | ||
} | ||
} | ||
|
||
walker post_path_var { | ||
has a: str; | ||
|
||
obj __specs__ { | ||
static has path: str = "/{a}", methods: list = ["post", "get"]; | ||
} | ||
} | ||
|
||
walker combination1 { | ||
has a: str; | ||
has b: str; | ||
has c: str; | ||
|
||
obj __specs__ { | ||
static has methods: list = ["post", "get"], as_query: list = ["a", "b"]; | ||
} | ||
} | ||
|
||
|
||
walker combination2 { | ||
has a: str; | ||
has b: str; | ||
has c: str; | ||
|
||
obj __specs__ { | ||
static has path: str = "/{a}", methods: list = ["post", "get", "put", "patch", "delete", "head", "trace", "options"], as_query: list = ["b"]; | ||
} | ||
} | ||
|
||
walker post_with_file { | ||
has single: UploadFile; | ||
has multiple: list[UploadFile]; | ||
has singleOptional: UploadFile | None = None; | ||
|
||
|
||
can enter with `root entry { | ||
print(self.single); | ||
print(self.multiple); | ||
print(self.singleOptional); | ||
} | ||
|
||
obj __specs__ {} | ||
} | ||
|
||
walker post_with_body_and_file { | ||
has val: int; | ||
has single: UploadFile; | ||
has multiple: list[UploadFile]; | ||
has optional_val: int = 0; | ||
|
||
can enter with `root entry { | ||
print(self.val); | ||
print(self.optional_val); | ||
print(self.single); | ||
print(self.multiple); | ||
} | ||
|
||
obj __specs__ { | ||
static has auth: bool = False; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
jac/support/jac-lang.org/docs/learn/littleX/src/kind-config.yaml
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,8 @@ | ||
kind: Cluster | ||
apiVersion: kind.x-k8s.io/v1alpha4 | ||
nodes: | ||
- role: control-plane | ||
extraPortMappings: | ||
- containerPort: 30080 | ||
hostPort: 30080 | ||
protocol: TCP |
32 changes: 32 additions & 0 deletions
32
jac/support/jac-lang.org/docs/learn/littleX/src/mtllm_example.jac
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,32 @@ | ||
import:py from mtllm.llms {Ollama} | ||
|
||
glob llm = Ollama(host="http://127.0.0.1:11434", model_name="llama3.2:1b"); | ||
|
||
can 'Summarize latest trends, major events, and notable interactions from the recent tweets in one line.' | ||
summarise_tweets(tweets: list[str]) -> 'Summarisation': str by llm(); | ||
|
||
|
||
with entry { | ||
Tweets = ["Just finished a thrilling book that I couldn't put down! What's your latest page-turner? 📚 #BookRecommendations" | ||
|
||
,"Movie nights are the best! What's a film that you can watch over and over? 🎬 #FilmLovers" | ||
|
||
,"Diving into a new fantasy series this weekend—what genre do you love to escape into? 🧙♂️ #Reading" | ||
|
||
,"Caught the latest blockbuster last night! What's your favorite film of the year so far? 🍿 #Cinema" | ||
|
||
,"Nothing like curling up with a good book and a cup of tea. What's your ideal reading setup? ☕📖 #CozyVibes" | ||
|
||
,"Just started a new hobby: film photography! What hobbies are you passionate about? 📸 #CreativeLife" | ||
|
||
,"Books can transport us to different worlds. What fictional universe would you love to live in? 🌌 #BookLovers" | ||
|
||
,"Anyone else binge-watching classic films lately? What's a must-see that everyone should experience? 🎥 #MovieMarathon" | ||
|
||
,"Reading is my escape. What's a book that changed your perspective on life? 🌍 #ImpactfulReads", | ||
|
||
"I love discovering indie films! What's an underrated gem you'd recommend? 🌟 #HiddenGems"]; | ||
print(summarise_tweets(Tweets)); | ||
} | ||
|
||
|
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