Skip to content

Commit

Permalink
Merge pull request #1196 from samchon/feat/agent
Browse files Browse the repository at this point in the history
Demonstration by Shopping Mall in website
  • Loading branch information
samchon authored Jan 21, 2025
2 parents 09234a4 + 77872e2 commit a7fb096
Show file tree
Hide file tree
Showing 30 changed files with 368 additions and 449 deletions.
2 changes: 1 addition & 1 deletion packages/agent/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nestia/agent",
"version": "0.3.6",
"version": "0.3.7",
"main": "lib/index.js",
"module": "lib/index.mjs",
"typings": "lib/index.d.ts",
Expand Down
8 changes: 8 additions & 0 deletions packages/agent/src/NestiaAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { NestiaAgentCostAggregator } from "./internal/NestiaAgentCostAggregator"
import { NestiaAgentOperationComposer } from "./internal/NestiaAgentOperationComposer";
import { NestiaAgentPromptTransformer } from "./internal/NestiaAgentPromptTransformer";
import { __map_take } from "./internal/__map_take";
import { INestiaAgentConfig } from "./structures/INestiaAgentConfig";
import { INestiaAgentController } from "./structures/INestiaAgentController";
import { INestiaAgentEvent } from "./structures/INestiaAgentEvent";
import { INestiaAgentOperationCollection } from "./structures/INestiaAgentOperationCollection";
Expand Down Expand Up @@ -157,6 +158,13 @@ export class NestiaAgent {
return [prompt, ...newbie];
}

/**
* Get configuration.
*/
public getConfig(): INestiaAgentConfig | undefined {
return this.props.config;
}

/**
* Get LLM Provider.
*/
Expand Down
22 changes: 10 additions & 12 deletions packages/agent/test/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,17 @@ const main = async (): Promise<void> => {
if (!TestGlobal.env.CHATGPT_API_KEY?.length) return;

// GET LLM APPLICATION SCHEMA
const swagger:
| SwaggerV2.IDocument
| OpenApiV3.IDocument
| OpenApiV3_1.IDocument = JSON.parse(
await fs.promises.readFile(
`${TestGlobal.ROOT}/../../../shopping-backend/packages/api/swagger.json`,
"utf8",
),
);
const document: OpenApi.IDocument = OpenApi.convert(typia.assert(swagger));
const application: IHttpLlmApplication<"chatgpt"> = HttpLlm.application({
model: "chatgpt",
document,
document: OpenApi.convert(
typia.json.assertParse<
SwaggerV2.IDocument | OpenApiV3.IDocument | OpenApiV3_1.IDocument
>(
await fetch(`http://127.0.0.1:37001/editor/swagger.json`).then((r) =>
r.text(),
),
),
),
options: {
reference: true,
},
Expand All @@ -50,7 +48,7 @@ const main = async (): Promise<void> => {

// HANDSHAKE WITH SHOPPING BACKEND
const connection: IHttpConnection = {
host: "http://localhost:37001",
host: "http://127.0.0.1:37001",
};
await ShoppingApi.functional.shoppings.customers.authenticate.create(
connection,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
const cp = require("child_process");
const fs = require("fs");
import cp from "child_process";
import fs from "fs";
import path from "path";
import { fileURLToPath } from "url";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const getAgentVersion = async () => {
const packageJson = JSON.parse(
Expand Down
2 changes: 1 addition & 1 deletion packages/chat/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
<div id="root" style="width: 100%; height: 100%"></div>
<script type="module" src="src/main.tsx"></script>
</body>
</html>
</html>
26 changes: 9 additions & 17 deletions packages/chat/package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"name": "@nestia/chat",
"version": "0.2.1",
"main": "lib/index.js",
"module": "lib/index.mjs",
"typings": "lib/index.d.ts",
"version": "0.2.4",
"type": "module",
"main": "./lib/index.mjs",
"typings": "./lib/index.d.ts",
"description": "Super A.I. Chatbot application by Swagger Document",
"scripts": {
"build": "npm run build:static && npm run build:lib",
"build:static": "rimraf dist && tsc -b && vite build",
"build:lib": "rimraf lib && tsc --project tsconfig.lib.json && rollup -c",
"build:lib": "rimraf lib && tsc --project tsconfig.lib.json --emitDeclarationOnly && rollup -c",
"dev": "vite",
"lint": "eslint .",
"preview": "vite preview",
"deploy": "node build/deploy.js"
"deploy": "node build/deploy.mjs"
},
"repository": {
"type": "git",
Expand All @@ -35,20 +35,12 @@
},
"homepage": "https://nestia.io",
"dependencies": {
"@mui/icons-material": "^6.3.1",
"@mui/material": "^5.15.6",
"@nestia/agent": "workspace:^",
"@mui/material": "^6.4.0",
"@nestia/agent": "^0.3.7",
"@samchon/openapi": "^2.4.0",
"html2canvas": "^1.4.1",
"js-file-download": "^0.4.12",
"js-yaml": "^4.1.0",
"prettier": "3.3.3",
"react-json-editor-ajrm": "^2.5.14",
"react-markdown": "^9.0.3",
"react-mui-fileuploader": "^0.5.2",
"rehype-raw": "^7.0.0",
"rehype-stringify": "^10.0.1",
"remark-mermaid-plugin": "^1.0.2",
"typia": "^7.6.0"
},
"devDependencies": {
Expand All @@ -64,7 +56,6 @@
"@types/node": "^22.10.5",
"@types/react": "^18.3.11",
"@types/react-dom": "^18.3.1",
"@types/react-json-editor-ajrm": "^2.5.6",
"@vitejs/plugin-react": "^4.3.3",
"eslint": "^9.13.0",
"eslint-plugin-react-hooks": "^5.0.0",
Expand All @@ -73,6 +64,7 @@
"openai": "^4.77.3",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"rimraf": "^6.0.1",
"rollup": "^4.24.2",
"ts-node": "^10.9.2",
"typescript": "~5.7.2",
Expand Down
File renamed without changes.
14 changes: 0 additions & 14 deletions packages/chat/shopping.html

This file was deleted.

158 changes: 0 additions & 158 deletions packages/chat/src/NestiaChatUploader.tsx

This file was deleted.

17 changes: 12 additions & 5 deletions packages/chat/src/components/MarkdownViewer.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import Markdown from "react-markdown";
import rehypeRaw from "rehype-raw";
import rehypeStringify from "rehype-stringify";
import remarkMermaidPlugin from "remark-mermaid-plugin";

export const MarkdownViewer = (props: MarkdownViewer.IProps) => {
return (
<Markdown
remarkPlugins={[remarkMermaidPlugin as any]}
rehypePlugins={[rehypeRaw, rehypeStringify]}
components={{
img: ({ ...props }) => (
<img
{...props}
style={{
display: "block",
maxWidth: "100%",
height: "auto",
}}
/>
),
}}
>
{props.children}
</Markdown>
Expand Down
1 change: 0 additions & 1 deletion packages/chat/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from "./NestiaChatApplication";
export * from "./NestiaChatUploader";
Loading

0 comments on commit a7fb096

Please sign in to comment.