Skip to content

Commit

Permalink
Merge branch 'lobehub:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
anyidea authored Jul 12, 2024
2 parents 332f244 + c9eef72 commit 56f613d
Show file tree
Hide file tree
Showing 13 changed files with 124 additions and 123 deletions.
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,31 @@

# Changelog

### [Version 1.3.6](https://github.com/lobehub/lobe-chat/compare/v1.3.5...v1.3.6)

<sup>Released on **2024-07-11**</sup>

#### ♻ Code Refactoring

- **misc**: Improve agent runtime code.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### Code refactoring

- **misc**: Improve agent runtime code, closes [#3199](https://github.com/lobehub/lobe-chat/issues/3199) ([9f211e2](https://github.com/lobehub/lobe-chat/commit/9f211e2))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>

### [Version 1.3.5](https://github.com/lobehub/lobe-chat/compare/v1.3.4...v1.3.5)

<sup>Released on **2024-07-10**</sup>
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,12 @@ Our marketplace is not just a showcase platform but also a collaborative space.

| Recent Submits | Description |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Ducky Programming Assistant](https://chat-preview.lobehub.com/market?agent=rubber-duck-programming)<br/><sup>By **[JiyuShao](https://github.com/JiyuShao)** on **2024-07-10**</sup> | Ducky Programming Assistant<br/>`programming` |
| [AOSP Source Code Expert](https://chat-preview.lobehub.com/market?agent=aosp-development)<br/><sup>By **[viruscoding](https://github.com/viruscoding)** on **2024-06-24**</sup> | An expert in AOSP (Android Open Source Project) for Android, with a deep understanding and analytical ability of the latest AOSP source code.<br/>`aosp` |
| [Fastapi Project Development Assistant](https://chat-preview.lobehub.com/market?agent=fastapi-development)<br/><sup>By **[xwxw098](https://github.com/xwxw098)** on **2024-06-19**</sup> | Proficient in Python modular development, skilled in using FastAPI, PostgreSQL, Tortoise-ORM, and other technologies, able to provide clear code structure and detailed comments for large projects.<br/>`fast-api` `python` `modular-development` |
| [IT Systems Architect](https://chat-preview.lobehub.com/market?agent=it-system-architect)<br/><sup>By **[a562314](https://github.com/a562314)** on **2024-06-19**</sup> | Senior IT architect specializing in requirements analysis, system design, technology selection, and cross-platform system optimization. With over 5 years of experience, proficient in Windows, macOS, and Linux operating systems, skilled in troubleshooting, and security protection.<br/>`it-architecture-design` `problem-solving` `agile-development` `system-optimization` `cross-platform-skills` `teamwork` |
| [Linux Kernel Expert](https://chat-preview.lobehub.com/market?agent=linux-kernel)<br/><sup>By **[wming126](https://github.com/wming126)** on **2024-06-19**</sup> | Role Description: I am an expert in Linux kernel, with a deep understanding and analytical ability of the latest kernel source code (as of June 2024). I can provide users with detailed and accurate information about the Linux kernel.<br/>`linux` `kernel` |

> 📊 Total agents: [<kbd>**293**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
> 📊 Total agents: [<kbd>**294**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
<!-- AGENT LIST -->

Expand Down
4 changes: 2 additions & 2 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,12 @@ LobeChat 的插件生态系统是其核心功能的重要扩展,它极大地

| 最近新增 | 助手说明 |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [小黄鸭编程助手](https://chat-preview.lobehub.com/market?agent=rubber-duck-programming)<br/><sup>By **[JiyuShao](https://github.com/JiyuShao)** on **2024-07-10**</sup> | 小黄鸭编程助手<br/>`programming` |
| [AOSP 源码专家](https://chat-preview.lobehub.com/market?agent=aosp-development)<br/><sup>By **[viruscoding](https://github.com/viruscoding)** on **2024-06-24**</sup> | 一位精通 AOSP(Android Open Source Project)安卓的专家,对最新 AOSP 源代码有着深入的理解和分析能力。<br/>`aosp` |
| [Fastapi 项目开发助手](https://chat-preview.lobehub.com/market?agent=fastapi-development)<br/><sup>By **[xwxw098](https://github.com/xwxw098)** on **2024-06-19**</sup> | 擅长 Python 模块化开发,熟练运用 FastAPI、PostgreSQL、Tortoise-ORM 等技术栈,能为大型项目提供清晰的代码结构并添加详细注释。<br/>`fast-api` `python` `模块化开发` |
| [IT 系统架构师](https://chat-preview.lobehub.com/market?agent=it-system-architect)<br/><sup>By **[a562314](https://github.com/a562314)** on **2024-06-19**</sup> | 资深 IT 架构师,擅长需求分析、系统设计、技术选型和跨平台系统优化。5 年以上经验,精通 Windows、macOS 和 Linux 三大操作系统,具备故障排除和安全防护能力<br/>`it架构设计` `问题解决` `敏捷开发` `系统优化` `跨平台技能` |
| [Linux 内核专家](https://chat-preview.lobehub.com/market?agent=linux-kernel)<br/><sup>By **[wming126](https://github.com/wming126)** on **2024-06-19**</sup> | 角色描述: 我是一位精通 Linux 内核的专家,对最新内核源代码(截至 2024 年 6 月)有着深入的理解和分析能力。我可以为用户提供关于 Linux 内核的详细、准确的信息。<br/>`linux` `kernel` |

> 📊 Total agents: [<kbd>**293**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
> 📊 Total agents: [<kbd>**294**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
<!-- AGENT LIST -->

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lobehub/chat",
"version": "1.3.5",
"version": "1.3.6",
"description": "Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
"keywords": [
"framework",
Expand Down
9 changes: 7 additions & 2 deletions src/app/api/chat/agentRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,16 @@ const getLlmOptionsFromPayload = (provider: string, payload: JWTPayload) => {
* Initializes the agent runtime with the user payload in backend
* @param provider - The provider name.
* @param payload - The JWT payload.
* @param params
* @returns A promise that resolves when the agent runtime is initialized.
*/
export const initAgentRuntimeWithUserPayload = (provider: string, payload: JWTPayload) => {
export const initAgentRuntimeWithUserPayload = (
provider: string,
payload: JWTPayload,
params: any = {},
) => {
return AgentRuntime.initializeWithProviderOptions(provider, {
[provider]: getLlmOptionsFromPayload(provider, payload),
[provider]: { ...getLlmOptionsFromPayload(provider, payload), ...params },
});
};

Expand Down
40 changes: 20 additions & 20 deletions src/libs/agent-runtime/AgentRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,93 +145,93 @@ class AgentRuntime {
}

case ModelProvider.ZhiPu: {
runtimeModel = await LobeZhipuAI.fromAPIKey(params.zhipu ?? {});
runtimeModel = await LobeZhipuAI.fromAPIKey(params.zhipu);
break;
}

case ModelProvider.Google: {
runtimeModel = new LobeGoogleAI(params.google ?? {});
runtimeModel = new LobeGoogleAI(params.google);
break;
}

case ModelProvider.Moonshot: {
runtimeModel = new LobeMoonshotAI(params.moonshot ?? {});
runtimeModel = new LobeMoonshotAI(params.moonshot);
break;
}

case ModelProvider.Bedrock: {
runtimeModel = new LobeBedrockAI(params.bedrock ?? {});
runtimeModel = new LobeBedrockAI(params.bedrock);
break;
}

case ModelProvider.Ollama: {
runtimeModel = new LobeOllamaAI(params.ollama ?? {});
runtimeModel = new LobeOllamaAI(params.ollama);
break;
}

case ModelProvider.Perplexity: {
runtimeModel = new LobePerplexityAI(params.perplexity ?? {});
runtimeModel = new LobePerplexityAI(params.perplexity);
break;
}

case ModelProvider.Anthropic: {
runtimeModel = new LobeAnthropicAI(params.anthropic ?? {});
runtimeModel = new LobeAnthropicAI(params.anthropic);
break;
}

case ModelProvider.DeepSeek: {
runtimeModel = new LobeDeepSeekAI(params.deepseek ?? {});
runtimeModel = new LobeDeepSeekAI(params.deepseek);
break;
}

case ModelProvider.Minimax: {
runtimeModel = new LobeMinimaxAI(params.minimax ?? {});
runtimeModel = new LobeMinimaxAI(params.minimax);
break;
}

case ModelProvider.Mistral: {
runtimeModel = new LobeMistralAI(params.mistral ?? {});
runtimeModel = new LobeMistralAI(params.mistral);
break;
}

case ModelProvider.Groq: {
runtimeModel = new LobeGroq(params.groq ?? {});
runtimeModel = new LobeGroq(params.groq);
break;
}

case ModelProvider.OpenRouter: {
runtimeModel = new LobeOpenRouterAI(params.openrouter ?? {});
runtimeModel = new LobeOpenRouterAI(params.openrouter);
break;
}

case ModelProvider.TogetherAI: {
runtimeModel = new LobeTogetherAI(params.togetherai ?? {});
runtimeModel = new LobeTogetherAI(params.togetherai);
break;
}

case ModelProvider.ZeroOne: {
runtimeModel = new LobeZeroOneAI(params.zeroone ?? {});
runtimeModel = new LobeZeroOneAI(params.zeroone);
break;
}

case ModelProvider.Qwen: {
runtimeModel = new LobeQwenAI(params.qwen ?? {});
runtimeModel = new LobeQwenAI(params.qwen);
break;
}

case ModelProvider.Stepfun: {
runtimeModel = new LobeStepfunAI(params.stepfun ?? {});
runtimeModel = new LobeStepfunAI(params.stepfun);
break;
}

case ModelProvider.Baichuan: {
runtimeModel = new LobeBaichuanAI(params.baichuan ?? {});
break
runtimeModel = new LobeBaichuanAI(params.baichuan);
break;
}

case ModelProvider.Taichu: {
runtimeModel = new LobeTaichuAI(params.taichu ?? {});
break
runtimeModel = new LobeTaichuAI(params.taichu);
break;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/libs/agent-runtime/anthropic/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class LobeAnthropicAI implements LobeRuntimeAI {

baseURL: string;

constructor({ apiKey, baseURL = DEFAULT_BASE_URL }: ClientOptions) {
constructor({ apiKey, baseURL = DEFAULT_BASE_URL }: ClientOptions = {}) {
if (!apiKey) throw AgentRuntimeError.createError(AgentRuntimeErrorType.InvalidProviderAPIKey);

this.client = new Anthropic({ apiKey, baseURL });
Expand Down
2 changes: 1 addition & 1 deletion src/libs/agent-runtime/bedrock/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class LobeBedrockAI implements LobeRuntimeAI {

region: string;

constructor({ region, accessKeyId, accessKeySecret }: LobeBedrockAIParams) {
constructor({ region, accessKeyId, accessKeySecret }: LobeBedrockAIParams = {}) {
if (!(accessKeyId && accessKeySecret))
throw AgentRuntimeError.createError(AgentRuntimeErrorType.InvalidBedrockCredentials);

Expand Down
2 changes: 1 addition & 1 deletion src/libs/agent-runtime/google/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class LobeGoogleAI implements LobeRuntimeAI {
private client: GoogleGenerativeAI;
baseURL?: string;

constructor({ apiKey, baseURL }: { apiKey?: string; baseURL?: string }) {
constructor({ apiKey, baseURL }: { apiKey?: string; baseURL?: string } = {}) {
if (!apiKey) throw AgentRuntimeError.createError(AgentRuntimeErrorType.InvalidProviderAPIKey);

this.client = new GoogleGenerativeAI(apiKey);
Expand Down
2 changes: 1 addition & 1 deletion src/libs/agent-runtime/minimax/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function parseMinimaxResponse(chunk: string): MinimaxResponse | undefined {
export class LobeMinimaxAI implements LobeRuntimeAI {
apiKey: string;

constructor({ apiKey }: { apiKey?: string }) {
constructor({ apiKey }: { apiKey?: string } = {}) {
if (!apiKey) throw AgentRuntimeError.createError(AgentRuntimeErrorType.InvalidProviderAPIKey);

this.apiKey = apiKey;
Expand Down
2 changes: 1 addition & 1 deletion src/libs/agent-runtime/ollama/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class LobeOllamaAI implements LobeRuntimeAI {

baseURL?: string;

constructor({ baseURL }: ClientOptions) {
constructor({ baseURL }: ClientOptions = {}) {
try {
if (baseURL) new URL(baseURL);
} catch {
Expand Down
Loading

0 comments on commit 56f613d

Please sign in to comment.