Skip to content

Commit

Permalink
style: 修改类型定义格式
Browse files Browse the repository at this point in the history
  • Loading branch information
TBXark committed Oct 17, 2023
1 parent ffe9581 commit 28a5fe4
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 50 deletions.
2 changes: 1 addition & 1 deletion dist/buildinfo.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"sha": "3cce4ce", "timestamp": 1697203145}
{"sha": "3713d4d", "timestamp": 1697520630}
4 changes: 2 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ var ENV = {
// 检查更新的分支
UPDATE_BRANCH: "master",
// 当前版本
BUILD_TIMESTAMP: 1697203145,
BUILD_TIMESTAMP: 1697520630,
// 当前版本 commit id
BUILD_VERSION: "3cce4ce",
BUILD_VERSION: "3713d4d",
I18N: null,
LANGUAGE: "zh-cn",
// 使用流模式
Expand Down
2 changes: 1 addition & 1 deletion dist/timestamp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1697203145
1697520630
2 changes: 1 addition & 1 deletion src/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export async function chatWithLLM(text, context, modifier) {

const llm = loadLLM(context);
if (llm === null) {
return sendMessageToTelegramWithContext(context)('LLM is not enable');
return sendMessageToTelegramWithContext(context)('LLM is not enable');
}
const answer = await requestCompletionsFromLLM(text, context, llm, modifier, onStream);
context.CURRENT_CHAT_CONTEXT.parse_mode = parseMode;
Expand Down
3 changes: 2 additions & 1 deletion src/context.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {CONST, DATABASE, ENV} from './env.js';
// import {TelegramMessage} from './type.d.ts';
// eslint-disable-next-line no-unused-vars
import './type.js';

/**
* 上下文信息
Expand Down
3 changes: 1 addition & 2 deletions src/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,8 @@ export function initEnv(env, i18n) {

// AUTO SET VALUES
if (!ENV.OPENAI_API_BASE) {
ENV.OPENAI_API_BASE=`${ENV.OPENAI_API_DOMAIN}/v1`
ENV.OPENAI_API_BASE=`${ENV.OPENAI_API_DOMAIN}/v1`;
}

}
ENV.I18N = i18n((ENV.LANGUAGE || 'cn').toLowerCase());
ENV.SYSTEM_INIT_MESSAGE = ENV.I18N.env.system_init_message;
Expand Down
3 changes: 2 additions & 1 deletion src/message.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import {sendMessageToTelegramWithContext} from './telegram.js';
import {handleCommandMessage} from './command.js';
import {errorToString} from './utils.js';
import {chatWithLLM} from './chat.js';
// import {TelegramMessage, TelegramWebhookRequest} from './type.d.ts';
// eslint-disable-next-line no-unused-vars
import './type.js';


/**
Expand Down
41 changes: 0 additions & 41 deletions src/type.d.ts

This file was deleted.

42 changes: 42 additions & 0 deletions src/type.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* @typedef {Object} TelegramUser
* @property {number} id - The ID of the user.
* @property {boolean} is_bot - True, if the user is a bot.
* @property {string} first_name - The first name of the user.
* @property {string} [last_name] - The last name of the user.
* @property {string} [username] - The username of the user.
* @property {string} [language_code] - The language code of the user.
*/

/**
* @typedef {Object} TelegramChat
* @property {number} id - The ID of the chat.
* @property {string} type - The type of the chat.
*/

/**
* @typedef {Object} TelegramMessageEntity
* @property {string} type - Type of the entity.
* @property {number} offset - Offset in UTF-16 code units to the start of the entity.
* @property {number} length - Length of the entity in UTF-16 code units.
* @property {string} [url] - URL of the entity.
* @property {TelegramUser} [user] - The user this entity refers to.
*/

/**
* @typedef {Object} TelegramMessage
* @property {number} message_id - The message's unique identifier.
* @property {TelegramUser} from - The user that sent the message.
* @property {TelegramChat} chat - The chat where the message was sent.
* @property {number} date - The date the message was sent.
* @property {string} text - The text of the message.
* @property {TelegramMessageEntity[]} [entities] - An array of message entities.
* @property {TelegramMessage} [reply_to_message] - The message that this message is a reply to.
*/

/**
* @typedef {Object} TelegramWebhookRequest
* @property {number} update_id - The update's unique identifier.
* @property {TelegramMessage} message - The message
* @property {TelegramMessage} edited_message - The edited message
*/

0 comments on commit 28a5fe4

Please sign in to comment.