Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 133 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# LobeChat Development Guidelines

This document serves as a comprehensive guide for all team members when developing LobeChat.

## Tech Stack

Built with modern technologies:

- **Frontend**: Next.js 15, React 19, TypeScript
- **UI Components**: Ant Design, @lobehub/ui, antd-style
- **State Management**: Zustand, SWR
- **Database**: PostgreSQL, PGLite, Drizzle ORM
- **Testing**: Vitest, Testing Library
- **Package Manager**: pnpm (monorepo structure)
- **Build Tools**: Next.js (Turbopack in dev, Webpack in prod), Vitest

## Directory Structure

The project follows a well-organized monorepo structure:

- `apps/` - Main applications
- `packages/` - Shared packages and libraries
- `src/` - Main source code
- `docs/` - Documentation
- `.cursor/rules/` - Development rules and guidelines

## Development Workflow

### Git Workflow

- Use rebase for git pull: `git pull --rebase`
- Git commit messages should prefix with gitmoji
- Git branch name format: `username/feat/feature-name`
- Use `.github/PULL_REQUEST_TEMPLATE.md` for PR descriptions

### Package Management

- Use `pnpm` as the primary package manager
- Use `bun` to run npm scripts
- Use `bunx` to run executable npm packages
- Navigate to specific packages using `cd packages/<package-name>`

### Code Style Guidelines

#### TypeScript

- Follow strict TypeScript practices for type safety and code quality
- Use proper type annotations
- Prefer interfaces over types for object shapes
- Use generics for reusable components

#### React Components

- Use functional components with hooks
- Follow the component structure guidelines
- Use antd-style & @lobehub/ui for styling
- Implement proper error boundaries

#### Database Schema

- Follow Drizzle ORM naming conventions
- Use plural snake_case for table names
- Implement proper foreign key relationships
- Follow the schema style guide

### Testing Strategy

**Required Rule**: `testing-guide/testing-guide.mdc`

**Commands**:

- Web: `bunx vitest run --silent='passed-only' '[file-path-pattern]'`
- Packages: `cd packages/[package-name] && bunx vitest run --silent='passed-only' '[file-path-pattern]'`

**Important Notes**:

- Wrap file paths in single quotes to avoid shell expansion
- Never run `bun run test` - this runs all tests and takes ~10 minutes
- If a test fails twice, stop and ask for help
- Always add tests for new code

### Type Checking

- Use `bun run type-check` to check for type errors
- Ensure all TypeScript errors are resolved before committing

### Internationalization

- Add new keys to `src/locales/default/namespace.ts`
- Translate at least `zh-CN` files for development preview
- Use hierarchical nested objects, not flat keys
- Don't run `pnpm i18n` manually (handled by CI)

## Available Development Rules

The project provides comprehensive rules in `.cursor/rules/` directory:

### Core Development

- `backend-architecture.mdc` - Three-layer architecture and data flow
- `react-component.mdc` - Component patterns and UI library usage
- `drizzle-schema-style-guide.mdc` - Database schema conventions
- `define-database-model.mdc` - Model templates and CRUD patterns
- `i18n.mdc` - Internationalization workflow

### State Management & UI

- `zustand-slice-organization.mdc` - Store organization patterns
- `zustand-action-patterns.mdc` - Action implementation patterns
- `packages/react-layout-kit.mdc` - Flex layout component usage

### Testing & Quality

- `testing-guide/testing-guide.mdc` - Comprehensive testing strategy
- `code-review.mdc` - Code review process and standards

### Desktop (Electron)

- `desktop-feature-implementation.mdc` - Main/renderer process patterns
- `desktop-local-tools-implement.mdc` - Tool integration workflow
- `desktop-menu-configuration.mdc` - Menu system configuration
- `desktop-window-management.mdc` - Window management patterns
- `desktop-controller-tests.mdc` - Controller testing guide

## Best Practices

- **Conservative for existing code, modern approaches for new features**
- **Code Language**: Use Chinese for files with existing Chinese comments, American English for new files
- Always add tests for new functionality
- Follow the established patterns in the codebase
- Use proper error handling and logging
- Implement proper accessibility features
- Consider internationalization from the start
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.118.0](https://github.com/lobehub/lobe-chat/compare/v1.117.1...v1.118.0)

<sup>Released on **2025-08-29**</sup>

#### ✨ Features

- **misc**: Add new provider AkashChat.

<br/>

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

#### What's improved

- **misc**: Add new provider AkashChat, closes [#8923](https://github.com/lobehub/lobe-chat/issues/8923) ([2f3bf0f](https://github.com/lobehub/lobe-chat/commit/2f3bf0f))

</details>

<div align="right">

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

</div>

### [Version 1.117.1](https://github.com/lobehub/lobe-chat/compare/v1.117.0...v1.117.1)

<sup>Released on **2025-08-29**</sup>
Expand Down
7 changes: 7 additions & 0 deletions changelog/v1.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
[
{
"children": {
"features": ["Add new provider AkashChat."]
},
"date": "2025-08-29",
"version": "1.118.0"
},
{
"children": {
"improvements": ["Move chat item into chat."]
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.117.1",
"version": "1.118.0",
"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
43 changes: 43 additions & 0 deletions packages/model-runtime/src/akashchat/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { ModelProvider } from '../types';
import { processMultiProviderModelList } from '../utils/modelParse';
import { createOpenAICompatibleRuntime } from '../utils/openaiCompatibleFactory';

export interface AkashChatModelCard {
id: string;
}

export const LobeAkashChatAI = createOpenAICompatibleRuntime({
baseURL: 'https://chatapi.akash.network/api/v1',
chatCompletion: {
handlePayload: (payload) => {
const { model, ...rest } = payload;

return {
...rest,
model,
stream: true,
} as any;
},
},
debug: {
chatCompletion: () => process.env.DEBUG_AKASH_CHAT_COMPLETION === '1',
},
models: async ({ client }) => {
try {
const modelsPage = (await client.models.list()) as any;
const rawList: any[] = modelsPage.data || [];

// Remove `created` field from each model item
const modelList: AkashChatModelCard[] = rawList.map(({ created, ...rest }) => rest);

return await processMultiProviderModelList(modelList, 'akashchat');
} catch (error) {
console.warn(
'Failed to fetch AkashChat models. Please ensure your AkashChat API key is valid:',
error,
);
return [];
}
},
provider: ModelProvider.AkashChat,
});
1 change: 1 addition & 0 deletions packages/model-runtime/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { LobeAkashChatAI } from './akashchat';
export { LobeAnthropicAI } from './anthropic';
export { LobeAzureAI } from './azureai';
export { LobeAzureOpenAI } from './azureOpenai';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ exports[`LobeOpenAI > models > should get models 1`] = `
"maxOutput": undefined,
"reasoning": false,
"releasedAt": "2022-12-16",
"type": "chat",
"type": "embedding",
"vision": false,
},
{
Expand Down
2 changes: 2 additions & 0 deletions packages/model-runtime/src/runtimeMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { LobeAi21AI } from './ai21';
import { Lobe302AI } from './ai302';
import { LobeAi360AI } from './ai360';
import { LobeAiHubMixAI } from './aihubmix';
import { LobeAkashChatAI } from './akashchat';
import { LobeAnthropicAI } from './anthropic';
import { LobeAzureOpenAI } from './azureOpenai';
import { LobeAzureAI } from './azureai';
Expand Down Expand Up @@ -61,6 +62,7 @@ export const providerRuntimeMap = {
ai302: Lobe302AI,
ai360: LobeAi360AI,
aihubmix: LobeAiHubMixAI,
akashchat: LobeAkashChatAI,
anthropic: LobeAnthropicAI,
azure: LobeAzureOpenAI,
azureai: LobeAzureAI,
Expand Down
1 change: 1 addition & 0 deletions packages/model-runtime/src/types/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export enum ModelProvider {
Ai302 = 'ai302',
Ai360 = 'ai360',
AiHubMix = 'aihubmix',
AkashChat = 'akashchat',
Anthropic = 'anthropic',
Azure = 'azure',
AzureAI = 'azureai',
Expand Down
15 changes: 14 additions & 1 deletion packages/model-runtime/src/utils/modelParse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@ export const IMAGE_MODEL_KEYWORDS = [
'^V_1',
] as const;

// 嵌入模型关键词配置
export const EMBEDDING_MODEL_KEYWORDS = [
'embedding',
'embed',
'bge',
'm3e',
] as const;

/**
* 检测关键词列表是否匹配模型ID(支持多种匹配模式)
* @param modelId 模型ID(小写)
Expand Down Expand Up @@ -278,7 +286,12 @@ const processModelCard = (
IMAGE_MODEL_KEYWORDS.map((k) => k.toLowerCase()),
)
? 'image'
: 'chat');
: isKeywordListMatch(
model.id.toLowerCase(),
EMBEDDING_MODEL_KEYWORDS.map((k) => k.toLowerCase()),
)
? 'embedding'
: 'chat');

// image model can't find parameters
if (modelType === 'image' && !model.parameters && !knownModel?.parameters) {
Expand Down
1 change: 1 addition & 0 deletions packages/types/src/user/settings/keyVaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export interface UserKeyVaults extends SearchEngineKeyVaults {
ai302?: OpenAICompatibleKeyVault;
ai360?: OpenAICompatibleKeyVault;
aihubmix?: OpenAICompatibleKeyVault;
akashchat?: OpenAICompatibleKeyVault;
anthropic?: OpenAICompatibleKeyVault;
azure?: AzureOpenAIKeyVault;
azureai?: AzureOpenAIKeyVault;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
Ai21ProviderCard,
Ai302ProviderCard,
Ai360ProviderCard,
AkashChatProviderCard,
AnthropicProviderCard,
BaichuanProviderCard,
CohereProviderCard,
Expand Down Expand Up @@ -113,6 +114,7 @@ export const useProviderList = (): ProviderItem[] => {
GiteeAIProviderCard,
PPIOProviderCard,
InfiniAIProviderCard,
AkashChatProviderCard,
Ai302ProviderCard,
],
[
Expand Down
Loading
Loading