Skip to content

Commit

Permalink
fix: 修复type问题
Browse files Browse the repository at this point in the history
  • Loading branch information
MarleneJiang committed Sep 20, 2023
1 parent 3e4e483 commit 2bde6f6
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 28 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
</p>
<p align="center">基于GWT理论构建的 LLM Agent 智能系统框架.</p>


## 🎨 技术栈

- Openai
Expand Down
2 changes: 1 addition & 1 deletion jest.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ module.exports = {
],
setupFiles: ["dotenv/config"],
testTimeout: 20_000,
testMatch: ['<rootDir>/**/*.{spec,test}.ts'],
testMatch: ["<rootDir>/**/*.{spec,test}.ts"],
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"tsn": "ts-node -r tsconfig-paths/register",
"format": "prettier --write --cache --cache-strategy metadata . !dist",
"build": "bash ./build",
"publish":"cd dist && npm publish --access public"
"publish": "cd dist && npm publish --access public"
},
"dependencies": {
"@idealeap/pipeline": "^1.1.1",
Expand Down
2 changes: 1 addition & 1 deletion package/llm/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ test("测试LLM的对话 & 替换log函数", async () => {
});

test("全局设置Config", async () => {
// GWT_CONFIG.OPENAI_API_KEY = "";
GWT_CONFIG.OPENAI_API_KEY = "";
class testA {
async a() {
const llm = new LLM({});
Expand Down
37 changes: 34 additions & 3 deletions package/llm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,44 @@ import { GWT_CONFIG } from "@idealeap/gwt/utils/index";
export type messagesType = OpenAI.Chat.CreateChatCompletionRequestMessage[];
export type messageType = OpenAI.Chat.CreateChatCompletionRequestMessage;
export type resMessagesType = OpenAI.Chat.Completions.ChatCompletion.Choice[];
export type functionsType = OpenAI.Chat.CompletionCreateParams.Function[];
export interface FunctionCallOption {
/**
* The name of the function to call.
*/
name: string;
}
export interface FunctionInterface {
/**
* The name of the function to be called. Must be a-z, A-Z, 0-9, or contain
* underscores and dashes, with a maximum length of 64.
*/
name: string;

/**
* The parameters the functions accepts, described as a JSON Schema object. See the
* [guide](https://platform.openai.com/docs/guides/gpt/function-calling) for
* examples, and the
* [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for
* documentation about the format.
*
* To describe a function that accepts no parameters, provide the value
* `{"type": "object", "properties": {}}`.
*/
parameters: Record<string, unknown>;

/**
* A description of what the function does, used by the model to choose when and
* how to call the function.
*/
description?: string;
}
export type functionsType = FunctionInterface[];
export type function_callType =
| "none"
| "auto"
| OpenAI.Chat.CompletionCreateParams.FunctionCallOption;
| FunctionCallOption;
export type messageFunctionCallType =
OpenAI.Chat.CreateChatCompletionRequestMessage.FunctionCall;
OpenAI.Chat.ChatCompletionMessage.FunctionCall;
export type chatCompletionType = OpenAI.Chat.Completions.ChatCompletion;
export type llmType = OpenAI;
export type chatParamsType = OpenAI.Chat.CompletionCreateParams;
Expand Down
8 changes: 4 additions & 4 deletions package/utils/config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import "dotenv/config";
export class GWT_CONFIG {
static OPEN_PATH = {
baseURL:"https://oai.hconeai.com/v1",
baseURL: "https://oai.hconeai.com/v1",
defaultHeaders: {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
"Helicone-Auth": `Bearer ${process.env["HELICONE_AUTH_API_KEY"]}`,
},
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
"Helicone-Auth": `Bearer ${process.env["HELICONE_AUTH_API_KEY"]}`,
},
};
static OPENAI_API_KEY = process.env["OPENAI_API_KEY"];
static HELICONE_AUTH_API_KEY = process.env["HELICONE_AUTH_API_KEY"];
Expand Down
34 changes: 17 additions & 17 deletions scripts/make-dist-package-json.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,32 @@ for (const key of ["types", "main", "module"]) {
if (typeof pkgJson[key] === "string")
pkgJson[key] = pkgJson[key].replace(/^(\.\/)?dist\//, "./");
}
pkgJson["main"]="dist/index.js"
pkgJson["types"]="dist/index.d.ts"
pkgJson["type"]="commonjs"
pkgJson["main"] = "dist/index.js";
pkgJson["types"] = "dist/index.d.ts";
pkgJson["type"] = "commonjs";
pkgJson["exports"] = {
".": {
"require": {
"types": "./index.d.ts",
"default": "./index.js"
require: {
types: "./index.d.ts",
default: "./index.js",
},
"types": "./index.d.mts",
"default": "./index.mjs"
types: "./index.d.mts",
default: "./index.mjs",
},
"./*.mjs": {
"types": "./*.d.ts",
"default": "./*.mjs"
types: "./*.d.ts",
default: "./*.mjs",
},
"./*.js": {
"types": "./*.d.ts",
"default": "./*.js"
types: "./*.d.ts",
default: "./*.js",
},
"./*": {
"types": "./*.d.ts",
"require": "./*.js",
"default": "./*.mjs"
}
}
types: "./*.d.ts",
require: "./*.js",
default: "./*.mjs",
},
};
delete pkgJson.devDependencies;
delete pkgJson.scripts["docs:build"];
delete pkgJson.scripts["docs:dev"];
Expand Down

0 comments on commit 2bde6f6

Please sign in to comment.