Skip to content

Commit

Permalink
Merge pull request #82 from samchon/feat/llm-3.1
Browse files Browse the repository at this point in the history
LLM schema conversion layer
  • Loading branch information
samchon authored Nov 23, 2024
2 parents 85a6fb8 + 31692ce commit 58f4f54
Show file tree
Hide file tree
Showing 49 changed files with 1,848 additions and 1,326 deletions.
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ Here is an example code utilizing the `@samchon/openapi` for LLM function callin
```typescript
import {
HttpLlm,
IChatGptSchema,
IHttpLlmApplication,
IHttpLlmFunction,
OpenApi,
Expand All @@ -95,13 +96,17 @@ const main = async (): Promise<void> => {
// convert to emended OpenAPI document,
// and compose LLM function calling application
const document: OpenApi.IDocument = OpenApi.convert(swagger);
const application: IHttpLlmApplication = HttpLlm.application(document);
const application: IHttpLlmApplication<"chatgpt"> = HttpLlm.application({
model: "chatgpt",
document,
});

// Let's imagine that LLM has selected a function to call
const func: IHttpLlmFunction | undefined = application.functions.find(
// (f) => f.name === "llm_selected_fuction_name"
(f) => f.path === "/bbs/articles" && f.method === "post",
);
const func: IHttpLlmFunction<IChatGptSchema.IParameters> | undefined =
application.functions.find(
// (f) => f.name === "llm_selected_fuction_name"
(f) => f.path === "/bbs/articles" && f.method === "post",
);
if (func === undefined) throw new Error("No matched function exists.");

// actual execution is by yourself
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "John Doe",
"age": 30
"name": "name",
"age": 0
}
26 changes: 14 additions & 12 deletions examples/function-calling/arguments/chatgpt.sale.input.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
],
"stocks": [
{
"name": "Surface Pro 9 i3/8GB/128GB",
"name": "Surface Pro 9 (i3, 8GB, 128GB)",
"price": {
"nominal": 1000000,
"real": 899000
Expand All @@ -110,7 +110,7 @@
]
},
{
"name": "Surface Pro 9 i3/16GB/256GB",
"name": "Surface Pro 9 (i3, 16GB, 256GB)",
"price": {
"nominal": 1200000,
"real": 1099000
Expand All @@ -132,7 +132,7 @@
]
},
{
"name": "Surface Pro 9 i3/16GB/512GB",
"name": "Surface Pro 9 (i3, 16GB, 512GB)",
"price": {
"nominal": 1400000,
"real": 1299000
Expand All @@ -154,7 +154,7 @@
]
},
{
"name": "Surface Pro 9 i5/16GB/256GB",
"name": "Surface Pro 9 (i5, 16GB, 256GB)",
"price": {
"nominal": 1500000,
"real": 1399000
Expand All @@ -176,7 +176,7 @@
]
},
{
"name": "Surface Pro 9 i5/32GB/512GB",
"name": "Surface Pro 9 (i5, 32GB, 512GB)",
"price": {
"nominal": 1800000,
"real": 1699000
Expand All @@ -198,7 +198,7 @@
]
},
{
"name": "Surface Pro 9 i7/16GB/512GB",
"name": "Surface Pro 9 (i7, 16GB, 512GB)",
"price": {
"nominal": 1800000,
"real": 1699000
Expand All @@ -220,7 +220,7 @@
]
},
{
"name": "Surface Pro 9 i7/32GB/512GB",
"name": "Surface Pro 9 (i7, 32GB, 512GB)",
"price": {
"nominal": 2000000,
"real": 1899000
Expand Down Expand Up @@ -250,7 +250,7 @@
"options": [],
"stocks": [
{
"name": "Extended Warranty Program",
"name": "Surface Pro 9 Warranty",
"price": {
"nominal": 100000,
"real": 89000
Expand All @@ -267,7 +267,7 @@
"options": [],
"stocks": [
{
"name": "Magnetic Keyboard",
"name": "Surface Pro 9 Keyboard",
"price": {
"nominal": 200000,
"real": 169000
Expand All @@ -283,10 +283,12 @@
],
"tags": [
"Surface Pro 9",
"laptop",
"tablet",
"2-in-1",
"tablet",
"laptop",
"Microsoft",
"technology"
"5G",
"detachable keyboard",
"touchscreen"
]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"age": 30,
"name": "test"
"name": "John"
}
Loading

0 comments on commit 58f4f54

Please sign in to comment.