Skip to content

Commit

Permalink
release: 0.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
MarleneJiang committed Oct 7, 2023
1 parent 0d31312 commit b640f2e
Show file tree
Hide file tree
Showing 21 changed files with 4,487 additions and 2,004 deletions.
2 changes: 1 addition & 1 deletion build
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ npm exec prettier -- --loglevel=warn --write .

# make sure that nothing crashes when we require the output CJS or
# import the output ESM
(cd dist && node -e 'require("llm-ops")')
# (cd dist && node -e 'require("llm-ops")')
(cd dist && node -e 'import("llm-ops")' --input-type=module)

# Path: build-docs
Expand Down
2 changes: 1 addition & 1 deletion docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export default defineConfig({
{ text: "快速上手", link: "/guide/start" },
],
},
{ text: "部署", link: "/guide/deploy" }
{ text: "部署", link: "/guide/deploy" },
],
},
editLink: {
Expand Down
3 changes: 2 additions & 1 deletion docs/api/llm-ops.chain.call.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ call(params: chainCallSchema): Promise<import("llm-ops/utils").Result<any>>;

Promise&lt;import("llm-ops/utils").[Result](./llm-ops.result.md)<!-- -->&lt;any&gt;&gt;

Promise&lt;any&gt; 返回异步处理的链调用结果。
返回异步处理的链调用结果。

4 changes: 2 additions & 2 deletions docs/api/llm-ops.chain.exporthistory.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
**Signature:**

```typescript
exportHistory(): import("llm-ops/llm/index").messagesType;
exportHistory(): import("llm-ops/llm/llm").messagesType;
```
**Returns:**

import("llm-ops/llm/index").[messagesType](./llm-ops.messagestype.md)
import("llm-ops/llm/llm").[messagesType](./llm-ops.messagestype.md)

{<!-- -->any<!-- -->} 返回链的历史记录。

4 changes: 2 additions & 2 deletions docs/api/llm-ops.functionchain.exporthistory.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
**Signature:**

```typescript
exportHistory(): import("llm-ops/llm/index").messagesType;
exportHistory(): import("llm-ops/llm/llm").messagesType;
```
**Returns:**

import("llm-ops/llm/index").[messagesType](./llm-ops.messagestype.md)
import("llm-ops/llm/llm").[messagesType](./llm-ops.messagestype.md)

11 changes: 11 additions & 0 deletions docs/api/llm-ops.genmermaid.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [llm-ops](./llm-ops.md) &gt; [genMermaid](./llm-ops.genmermaid.md)

## genMermaid variable

**Signature:**

```typescript
genMermaid: (params: MermaidCallSchema) => Promise<string>
```
2 changes: 2 additions & 0 deletions docs/api/llm-ops.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
| [FunctionCallSchema](./llm-ops.functioncallschema.md) | |
| [FunctionInterface](./llm-ops.functioninterface.md) | |
| [MemoryPromptTemplateSchema](./llm-ops.memoryprompttemplateschema.md) | |
| [MermaidCallSchema](./llm-ops.mermaidcallschema.md) | |
| [milvusVectorDBCreateSchema](./llm-ops.milvusvectordbcreateschema.md) | |
| [milvusVectorDBIndexSchema](./llm-ops.milvusvectordbindexschema.md) | |
| [milvusVectorDBPromptTemplateSchema](./llm-ops.milvusvectordbprompttemplateschema.md) | |
Expand All @@ -74,6 +75,7 @@
| Variable | Description |
| --- | --- |
| [formatPromptTemplate](./llm-ops.formatprompttemplate.md) | <p>格式化提示模板函数。</p><p>此函数的主要目的是为了从提供的<code>prompts</code>对象中提取出一个格式化的提示模板。 这可以是一个单一的模板,也可以是一个模板数组。</p> |
| [genMermaid](./llm-ops.genmermaid.md) | |

## Type Aliases

Expand Down
11 changes: 11 additions & 0 deletions docs/api/llm-ops.mermaidcallschema.llm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [llm-ops](./llm-ops.md) &gt; [MermaidCallSchema](./llm-ops.mermaidcallschema.md) &gt; [llm](./llm-ops.mermaidcallschema.llm.md)

## MermaidCallSchema.llm property

**Signature:**

```typescript
llm?: LLM;
```
11 changes: 11 additions & 0 deletions docs/api/llm-ops.mermaidcallschema.llmschema.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [llm-ops](./llm-ops.md) &gt; [MermaidCallSchema](./llm-ops.mermaidcallschema.md) &gt; [llmSchema](./llm-ops.mermaidcallschema.llmschema.md)

## MermaidCallSchema.llmSchema property

**Signature:**

```typescript
llmSchema?: createLLMSchema;
```
21 changes: 21 additions & 0 deletions docs/api/llm-ops.mermaidcallschema.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [llm-ops](./llm-ops.md) &gt; [MermaidCallSchema](./llm-ops.mermaidcallschema.md)

## MermaidCallSchema interface

**Signature:**

```typescript
export interface MermaidCallSchema
```

## Properties

| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [llm?](./llm-ops.mermaidcallschema.llm.md) | | [LLM](./llm-ops.llm.md) | _(Optional)_ |
| [llmSchema?](./llm-ops.mermaidcallschema.llmschema.md) | | [createLLMSchema](./llm-ops.createllmschema.md) | _(Optional)_ |
| [request](./llm-ops.mermaidcallschema.request.md) | | [messageType](./llm-ops.messagetype.md) \| string | |
| [type?](./llm-ops.mermaidcallschema.type.md) | | string \| string\[\] | _(Optional)_ |

11 changes: 11 additions & 0 deletions docs/api/llm-ops.mermaidcallschema.request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [llm-ops](./llm-ops.md) &gt; [MermaidCallSchema](./llm-ops.mermaidcallschema.md) &gt; [request](./llm-ops.mermaidcallschema.request.md)

## MermaidCallSchema.request property

**Signature:**

```typescript
request: messageType | string;
```
11 changes: 11 additions & 0 deletions docs/api/llm-ops.mermaidcallschema.type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [llm-ops](./llm-ops.md) &gt; [MermaidCallSchema](./llm-ops.mermaidcallschema.md) &gt; [type](./llm-ops.mermaidcallschema.type.md)

## MermaidCallSchema.type property

**Signature:**

```typescript
type?: string | string[];
```
153 changes: 78 additions & 75 deletions docs/guide/deploy.md
Original file line number Diff line number Diff line change
@@ -1,75 +1,78 @@
# 部署

`llm-ops`作为一款支持`commonjs``esm``ts`的框架,可以在任何支持`nodejs`的环境中运行,包括`linux``macos``windows`等。

> 由于部分使用的依赖问题,暂不支持直接在浏览器中部署,之后会改进。
## next/nuxt

虽然`llm-ops`暂时无法直接在浏览器中使用,但是一般也不可能直接在浏览器中使用,防止`api-key`泄露。

在前端,可以使用`next`或者`nuxt`来进行`SSR/CSR`渲染,核心功能防止服务端,前端调用对应函数即可。

这里以next框架为例,介绍如何在前端使用`llm-ops`

完整项目代码可见[Github](https://github.com/MarleneJiang/llm-ops-preview)

```js

'use server'
import { Pipeline, PipeRegistry, LLM_OPS_CONFIG,EventEmitter } from "llm-ops";
import { useAppContext } from "@/lib/AppContext";
export const llm_ops_run = async (
schema,
inputText,
openaiKey,
heliconeKey
) => {
try {

LLM_OPS_CONFIG.OPENAI_API_KEY = openaiKey || "";
!!heliconeKey && (LLM_OPS_CONFIG.HELICONE_AUTH_API_KEY = heliconeKey);
!!heliconeKey && (LLM_OPS_CONFIG.OPEN_PATH = {
baseURL: "https://oai.hconeai.com/v1",
defaultHeaders: {
"Helicone-Auth": `Bearer ${heliconeKey}`,
},
});
const funcStore = PipeRegistry.init();
const schemaJson = JSON.parse(schema);
const pipeline = Pipeline.fromJSON(schemaJson, {}, funcStore);
const res = await pipeline.execute(inputText);
return res;
} catch (e) {
throw e
}
};
```

## laf

`llm-ops`可以直接部署在`serveless`云函数中,这里以`laf`为例,介绍如何在`laf`中使用`llm-ops`

```ts
import cloud from '@lafjs/cloud'
import { Pipeline, PipeRegistry, SerializablePipelineOptions } from "llm-ops";
export default async function (ctx: FunctionContext) {
const { schema, input } = ctx.body;
if (!schema || !input) {
return { "code": "001", "msg": "错误输入", "data": "" };
}
console.log("schema", schema)
const funcStore = PipeRegistry.init();
if (!!schema.pipes) {
const pipeline = Pipeline.fromJSON(schema as SerializablePipelineOptions, {}, funcStore);
const res = await pipeline.execute(input);
return { "code": "200", "msg": "", "data": res };
} else {
return { "code": "002", "msg": "schema.pipes错误输入", "data": "" };
}
}
```

借助`laf`的能力,我们能够迅速将其部署到云函数中,实现`llm-ops`的在线调用。

完整的laf函数代码可见[函数市场](https://laf.run/market/templates/6517c102d2f60c23eb96807d)
# 部署

`llm-ops`作为一款支持`commonjs``esm``ts`的框架,可以在任何支持`nodejs`的环境中运行,包括`linux``macos``windows`等。

> 由于部分使用的依赖问题,暂不支持直接在浏览器中部署,之后会改进。
## next/nuxt

虽然`llm-ops`暂时无法直接在浏览器中使用,但是一般也不可能直接在浏览器中使用,防止`api-key`泄露。

在前端,可以使用`next`或者`nuxt`来进行`SSR/CSR`渲染,核心功能防止服务端,前端调用对应函数即可。

这里以next框架为例,介绍如何在前端使用`llm-ops`

完整项目代码可见[Github](https://github.com/MarleneJiang/llm-ops-preview)

```js
"use server";
import { Pipeline, PipeRegistry, LLM_OPS_CONFIG, EventEmitter } from "llm-ops";
import { useAppContext } from "@/lib/AppContext";
export const llm_ops_run = async (
schema,
inputText,
openaiKey,
heliconeKey,
) => {
try {
LLM_OPS_CONFIG.OPENAI_API_KEY = openaiKey || "";
!!heliconeKey && (LLM_OPS_CONFIG.HELICONE_AUTH_API_KEY = heliconeKey);
!!heliconeKey &&
(LLM_OPS_CONFIG.OPEN_PATH = {
baseURL: "https://oai.hconeai.com/v1",
defaultHeaders: {
"Helicone-Auth": `Bearer ${heliconeKey}`,
},
});
const funcStore = PipeRegistry.init();
const schemaJson = JSON.parse(schema);
const pipeline = Pipeline.fromJSON(schemaJson, {}, funcStore);
const res = await pipeline.execute(inputText);
return res;
} catch (e) {
throw e;
}
};
```

## laf

`llm-ops`可以直接部署在`serveless`云函数中,这里以`laf`为例,介绍如何在`laf`中使用`llm-ops`

```ts
import cloud from "@lafjs/cloud";
import { Pipeline, PipeRegistry, SerializablePipelineOptions } from "llm-ops";
export default async function (ctx: FunctionContext) {
const { schema, input } = ctx.body;
if (!schema || !input) {
return { code: "001", msg: "错误输入", data: "" };
}
console.log("schema", schema);
const funcStore = PipeRegistry.init();
if (!!schema.pipes) {
const pipeline = Pipeline.fromJSON(
schema as SerializablePipelineOptions,
{},
funcStore,
);
const res = await pipeline.execute(input);
return { code: "200", msg: "", data: res };
} else {
return { code: "002", msg: "schema.pipes错误输入", data: "" };
}
}
```

借助`laf`的能力,我们能够迅速将其部署到云函数中,实现`llm-ops`的在线调用。

完整的laf函数代码可见[函数市场](https://laf.run/market/templates/6517c102d2f60c23eb96807d)
1 change: 1 addition & 0 deletions jest.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module.exports = {
transformIgnorePatterns: [
"/node_modules/",
"node_modules/(?!@ngrx|(?!deck.gl)|ng-dynamic)",
"/node_modules/(?!mermaid)",
],
setupFiles: ["dotenv/config"],
testTimeout: 20_000,
Expand Down
34 changes: 17 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "llm-ops",
"version": "0.0.4",
"version": "0.0.6",
"description": "高效制作llm workflow的低代码框架",
"main": "package/index.js",
"author": "Marlene && IdeaLeap",
Expand Down Expand Up @@ -33,38 +33,38 @@
"publish": "cd dist && npm publish --access public"
},
"dependencies": {
"@idealeap/pipeline": "^1.1.5",
"@idealeap/pipeline": "^1.1.6",
"@zilliz/milvus2-sdk-node": "^2.2.24",
"dotenv": "^16.3.1",
"mermaid-ssr": "^10.5.0",
"openai": "4.8.0",
"typescript": "^5.1.6",
"mermaid": "^10.5.0"
"typescript": "^5.1.6"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^6.1.0",
"@typescript-eslint/parser": "^6.1.0",
"@microsoft/api-documenter": "^7.23.2",
"@microsoft/api-extractor": "^7.37.0",
"prettier": "^3.0.0",
"eslint": "^8.45.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-tsdoc": "^0.2.17",
"llm-ops": "link:./package",
"@types/jest": "^29.5.3",
"@types/node": "^20.4.2",
"@typescript-eslint/eslint-plugin": "^6.1.0",
"@typescript-eslint/parser": "^6.1.0",
"eslint": "^8.45.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-n": "^15.0.0 || ^16.0.0 ",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-tsdoc": "^0.2.17",
"jest": "^29.6.2",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"tslib": "^2.6.0",
"vitepress": "^1.0.0-beta.5",
"llm-ops": "link:./package",
"node-fetch": "2",
"prettier": "^3.0.0",
"ts-jest": "^29.1.1",
"ts-morph": "^19.0.0",
"ts-node": "^10.9.1",
"tsc-alias": "^1.8.6",
"tsc-multi": "^1.1.0",
"tsconfig-paths": "^4.0.0"
"tsconfig-paths": "^4.0.0",
"tslib": "^2.6.0",
"vitepress": "^1.0.0-beta.5"
}
}
2 changes: 1 addition & 1 deletion package/llm/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "./llm.js";
export * from "./llm.js";
10 changes: 5 additions & 5 deletions package/utils/gen/__tests__/mermaid.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { genMermaid } from "llm-ops";

test("genMermaid", async () => {
const res = await genMermaid({
request:"在对数字化转型的探讨中,技术、策略和人是三大核心要素。技术为数字化转型提供了可能性,允许企业利用先进的工具和平台去优化、创新和扩展其业务范围。而策略则为数字化转型提供了方向,确保企业的技术部署与其长期的商业目标和愿景相一致。最后,人是数字化转型的中心,因为不论有多先进的技术或策略,如果员工和客户不能或不愿适应新的变革,那么转型就不可能成功。因此,在进行数字化转型时,企业必须确保技术的适用性、策略的明晰性和人的参与性,以确保转型的全面性和成功性。"
});
genMermaid({
request:
"在对数字化转型的探讨中,技术、策略和人是三大核心要素。技术为数字化转型提供了可能性,允许企业利用先进的工具和平台去优化、创新和扩展其业务范围。而策略则为数字化转型提供了方向,确保企业的技术部署与其长期的商业目标和愿景相一致。最后,人是数字化转型的中心,因为不论有多先进的技术或策略,如果员工和客户不能或不愿适应新的变革,那么转型就不可能成功。因此,在进行数字化转型时,企业必须确保技术的适用性、策略的明晰性和人的参与性,以确保转型的全面性和成功性。",
}).then((res) => {
console.log(res);
});
});
Loading

0 comments on commit b640f2e

Please sign in to comment.