mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-25 07:00:48 +09:00
chore: remove @memoh/shared
This commit is contained in:
+1
-1
@@ -6,7 +6,7 @@ import vue from 'eslint-plugin-vue'
|
||||
export default [
|
||||
...tseslint.configs.recommended,
|
||||
...vue.configs['flat/recommended'],
|
||||
{ ignores: ['**/node_modules/**', '**/dist/**'] },
|
||||
{ ignores: ['**/node_modules/**', '**/dist/**', 'packages/sdk/src/**'] },
|
||||
{
|
||||
files: ['packages/**/*.{js,jsx,ts,tsx}', 'agent/**/*.{js,jsx,ts,tsx}'],
|
||||
languageOptions: {
|
||||
|
||||
@@ -16,5 +16,5 @@ export default defineConfig({
|
||||
},
|
||||
'@hey-api/client-fetch',
|
||||
'@pinia/colada',
|
||||
]
|
||||
});
|
||||
],
|
||||
})
|
||||
@@ -18,7 +18,6 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@elysiajs/eden": "^1.4.6",
|
||||
"@memoh/shared": "workspace:*",
|
||||
"elysia": "latest",
|
||||
"commander": "^12.1.0",
|
||||
"chalk": "^5.4.1",
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
# @memoh/shared
|
||||
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"name": "@memoh/shared",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"exports": {
|
||||
".": "./src/index.ts"
|
||||
},
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"packageManager": "pnpm@10.27.0"
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
export interface robot{
|
||||
description: string
|
||||
time: Date,
|
||||
id: string | number,
|
||||
type: string,
|
||||
action: 'robot',
|
||||
state:'thinking'|'generate'|'complete'
|
||||
}
|
||||
|
||||
export interface user{
|
||||
description: string,
|
||||
time: Date,
|
||||
id: number | string,
|
||||
action:'user'
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
export * from './model'
|
||||
export * from './schedule'
|
||||
export * from './platform'
|
||||
export * from './mcp'
|
||||
export * from './chatInfo'
|
||||
@@ -1,48 +0,0 @@
|
||||
export interface BaseMCPConnection {
|
||||
type: string
|
||||
name: string
|
||||
}
|
||||
|
||||
export interface StdioMCPConnection extends BaseMCPConnection {
|
||||
type: 'stdio'
|
||||
command: string
|
||||
args: string[]
|
||||
env: Record<string, string>
|
||||
cwd: string
|
||||
}
|
||||
|
||||
export interface BaseHTTPMCPConnection extends BaseMCPConnection {
|
||||
url: string
|
||||
headers: Record<string, string>
|
||||
}
|
||||
|
||||
export interface HTTPMCPConnection extends BaseHTTPMCPConnection {
|
||||
type: 'http'
|
||||
}
|
||||
|
||||
export interface SSEMCPConnection extends BaseHTTPMCPConnection {
|
||||
type: 'sse'
|
||||
}
|
||||
|
||||
export type MCPConnection =
|
||||
| StdioMCPConnection
|
||||
| HTTPMCPConnection
|
||||
| SSEMCPConnection
|
||||
|
||||
|
||||
export interface MCPListItem{
|
||||
id: string;
|
||||
type: string;
|
||||
name: string;
|
||||
config: {
|
||||
cwd: string;
|
||||
env: Record<string, string>;
|
||||
args: string[];
|
||||
type: string;
|
||||
command: string;
|
||||
};
|
||||
active: boolean;
|
||||
user: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
export enum ModelClientType {
|
||||
OPENAI = 'openai',
|
||||
ANTHROPIC = 'anthropic',
|
||||
GOOGLE = 'google',
|
||||
}
|
||||
|
||||
export enum ModelType {
|
||||
CHAT = 'chat',
|
||||
EMBEDDING = 'embedding',
|
||||
}
|
||||
|
||||
export interface BaseModel {
|
||||
/**
|
||||
* @description The unique identifier for the model
|
||||
* @example 'gpt-4o'
|
||||
*/
|
||||
modelId: string
|
||||
|
||||
/**
|
||||
* @description The base URL for the model
|
||||
* @example 'https://api.openai.com/v1'
|
||||
*/
|
||||
baseUrl: string
|
||||
|
||||
/**
|
||||
* @description The API key for the model
|
||||
* @example 'sk-1234567890'
|
||||
*/
|
||||
apiKey: string
|
||||
|
||||
/**
|
||||
* @description The client type for the model
|
||||
* @enum {ModelClientType}
|
||||
*/
|
||||
clientType: ModelClientType
|
||||
|
||||
/**
|
||||
* @description The display name for the model
|
||||
* @example 'GPT 4o'
|
||||
*/
|
||||
name?: string
|
||||
|
||||
/**
|
||||
* @description The model type
|
||||
* @enum {ModelType}
|
||||
* @default {ModelType.CHAT}
|
||||
*/
|
||||
type?: ModelType
|
||||
}
|
||||
|
||||
export interface EmbeddingModel extends BaseModel {
|
||||
type?: ModelType.EMBEDDING
|
||||
|
||||
/**
|
||||
* @description The dimensions of the embedding
|
||||
* @example 1536
|
||||
*/
|
||||
dimensions: number
|
||||
}
|
||||
|
||||
export interface ChatModel extends BaseModel {
|
||||
type?: ModelType.CHAT
|
||||
}
|
||||
|
||||
export type Model = EmbeddingModel | ChatModel
|
||||
|
||||
|
||||
// 表格当中model的类型
|
||||
export interface ModelList {
|
||||
apiKey: string,
|
||||
baseUrl: string,
|
||||
clientType: 'OpenAI' | 'Anthropic' | 'Google',
|
||||
modelId: string,
|
||||
name: string,
|
||||
type: 'chat' | 'embedding',
|
||||
id: string,
|
||||
defaultChatModel: boolean,
|
||||
defaultEmbeddingModel: boolean,
|
||||
defaultSummaryModel: boolean
|
||||
}
|
||||
|
||||
export interface ProviderInfo{
|
||||
api_key: string;
|
||||
base_url: string;
|
||||
client_type: string;
|
||||
metadata: Record<'additionalProp1',object>;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface ModelInfo{
|
||||
dimensions:number
|
||||
is_multimodal:boolean
|
||||
input?: string[]
|
||||
llm_provider_id:string
|
||||
model_id:string
|
||||
name:string
|
||||
type: string
|
||||
enable_as?:string
|
||||
}
|
||||
|
||||
export const clientType = ['openai', 'anthropic', 'google', 'ollama'] as const
|
||||
@@ -1,7 +0,0 @@
|
||||
export interface Platform {
|
||||
id: string
|
||||
name: string
|
||||
// endpoint: string
|
||||
config: Record<string, unknown>
|
||||
active: boolean
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
export interface Schedule {
|
||||
id?: string
|
||||
pattern: string
|
||||
name: string
|
||||
description: string
|
||||
command: string
|
||||
maxCalls?: number | null
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
# Markdown 语法测试文档
|
||||
|
||||
## 1. 标题层级
|
||||
### 一级标题
|
||||
#### 二级标题
|
||||
##### 三级标题
|
||||
###### 六级标题
|
||||
|
||||
## 2. 文本格式
|
||||
**粗体文本**
|
||||
*斜体文本*
|
||||
~~删除线文本~~
|
||||
`代码片段`
|
||||
|
||||
> 引用文本
|
||||
> 可以多行
|
||||
|
||||
## 3. 列表
|
||||
|
||||
### 无序列表
|
||||
- 项目一
|
||||
- 项目二
|
||||
- 子项目
|
||||
- 项目三
|
||||
|
||||
### 有序列表
|
||||
1. 第一步
|
||||
2. 第二步
|
||||
3. 第三步
|
||||
|
||||
## 4. 链接与图片
|
||||
[百度](https://www.baidu.com)
|
||||

|
||||
|
||||
## 5. 表格
|
||||
| 姓名 | 年龄 | 职业 |
|
||||
|------|------|------|
|
||||
| 张三 | 25 | 开发 |
|
||||
| 李四 | 30 | 测试 |
|
||||
|
||||
## 6. 代码块
|
||||
```python
|
||||
def hello_world():
|
||||
print("Hello, World!")
|
||||
@@ -9,7 +9,6 @@
|
||||
"start": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@memoh/shared": "workspace:*",
|
||||
"@memoh/ui": "workspace:*",
|
||||
"@memoh/sdk": "workspace:*",
|
||||
"@pinia/colada": "^0.21.1",
|
||||
|
||||
@@ -89,7 +89,7 @@
|
||||
<SelectContent>
|
||||
<SelectGroup>
|
||||
<SelectItem
|
||||
v-for="type in clientType"
|
||||
v-for="type in CLIENT_TYPES"
|
||||
:key="type"
|
||||
:value="type"
|
||||
>
|
||||
@@ -152,7 +152,7 @@ import {
|
||||
import { toTypedSchema } from '@vee-validate/zod'
|
||||
import z from 'zod'
|
||||
import { useForm } from 'vee-validate'
|
||||
import { clientType } from '@memoh/shared'
|
||||
import { CLIENT_TYPES } from '@/composables/api/useProviders'
|
||||
import { useCreateProvider } from '@/composables/api/useProviders'
|
||||
|
||||
const open = defineModel<boolean>('open')
|
||||
|
||||
+13
-8
@@ -4,14 +4,11 @@
|
||||
<FontAwesomeIcon :icon="['fas', 'robot']" />
|
||||
</div>
|
||||
<section class="w-[90%]">
|
||||
<sup class="font-semibold">
|
||||
{{ robotSay.type }}
|
||||
</sup>
|
||||
<p class="leading-7 text-muted-foreground break-all">
|
||||
<LoadingDots v-if="robotSay.state === 'thinking'" />
|
||||
<LoadingDots v-if="message.streaming && !textContent" />
|
||||
<MarkdownRender
|
||||
v-else
|
||||
:content="robotSay.description"
|
||||
:content="textContent"
|
||||
custom-id="chat-answer"
|
||||
/>
|
||||
</p>
|
||||
@@ -20,14 +17,22 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { robot } from '@memoh/shared'
|
||||
import { computed } from 'vue'
|
||||
import type { ChatMessage } from '@/store/chat-list'
|
||||
import MarkdownRender, { enableKatex, enableMermaid } from 'markstream-vue'
|
||||
import LoadingDots from '@/components/loading-dots/index.vue'
|
||||
|
||||
enableKatex()
|
||||
enableMermaid()
|
||||
|
||||
defineProps<{
|
||||
robotSay: robot
|
||||
const props = defineProps<{
|
||||
message: ChatMessage
|
||||
}>()
|
||||
|
||||
const textContent = computed(() => {
|
||||
return props.message.blocks
|
||||
.filter(b => b.type === 'text')
|
||||
.map(b => b.type === 'text' ? b.content : '')
|
||||
.join('')
|
||||
})
|
||||
</script>
|
||||
@@ -4,16 +4,16 @@
|
||||
class="flex flex-col gap-4"
|
||||
>
|
||||
<template
|
||||
v-for="chatItem in chatList"
|
||||
v-for="chatItem in messages"
|
||||
:key="chatItem.id"
|
||||
>
|
||||
<UserChat
|
||||
v-if="chatItem.action === 'user'"
|
||||
:user-say="chatItem"
|
||||
v-if="chatItem.role === 'user'"
|
||||
:message="chatItem"
|
||||
/>
|
||||
<RobotChat
|
||||
v-if="chatItem.action === 'robot'"
|
||||
:robot-say="chatItem"
|
||||
<AssistantChat
|
||||
v-if="chatItem.role === 'assistant'"
|
||||
:message="chatItem"
|
||||
/>
|
||||
</template>
|
||||
</div>
|
||||
@@ -21,14 +21,15 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import UserChat from './user-chat/index.vue'
|
||||
import RobotChat from './robot-chat/index.vue'
|
||||
import AssistantChat from './assistant-chat/index.vue'
|
||||
import { inject, ref, watch } from 'vue'
|
||||
import { useChatList } from '@/store/chat-list'
|
||||
import { useChatStore } from '@/store/chat-list'
|
||||
import { storeToRefs } from 'pinia'
|
||||
import { useAutoScroll } from '@/composables/useAutoScroll'
|
||||
|
||||
const { chatList, sendMessage } = useChatList()
|
||||
const { loading } = storeToRefs(useChatList())
|
||||
const store = useChatStore()
|
||||
const { messages, sendMessage } = store
|
||||
const { streaming } = storeToRefs(store)
|
||||
|
||||
// ---- 消息发送 ----
|
||||
const chatSay = inject('chatSay', ref(''))
|
||||
@@ -47,5 +48,5 @@ watch(chatSay, async () => {
|
||||
|
||||
// ---- 自动滚动 ----
|
||||
const displayContainer = ref<HTMLElement>()
|
||||
useAutoScroll(displayContainer, loading)
|
||||
useAutoScroll(displayContainer, streaming)
|
||||
</script>
|
||||
|
||||
@@ -4,14 +4,21 @@
|
||||
class="leading-7 not-first:mt-6 max-w-[90%] ml-auto text-muted-foreground bg-[#F9F9F9] p-4 rounded-xl rounded-tr-none break-all dark:bg-[#1C1917]
|
||||
"
|
||||
>
|
||||
{{ userSay.description }}
|
||||
{{ textContent }}
|
||||
</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { user } from '@memoh/shared'
|
||||
const { userSay } = defineProps<{
|
||||
userSay: user
|
||||
import { computed } from 'vue'
|
||||
import type { ChatMessage } from '@/store/chat-list'
|
||||
|
||||
const props = defineProps<{
|
||||
message: ChatMessage
|
||||
}>()
|
||||
|
||||
const textContent = computed(() => {
|
||||
const block = props.message.blocks.find(b => b.type === 'text')
|
||||
return block?.type === 'text' ? block.content : ''
|
||||
})
|
||||
</script>
|
||||
@@ -260,7 +260,7 @@ import z from 'zod'
|
||||
import { toTypedSchema } from '@vee-validate/zod'
|
||||
import { useForm } from 'vee-validate'
|
||||
import { ref, inject, watch } from 'vue'
|
||||
import { type MCPListItem as MCPType } from '@memoh/shared'
|
||||
import { type MCPListItem as MCPType } from '@/composables/api/useMcp'
|
||||
import { useKeyValueTags } from '@/composables/useKeyValueTags'
|
||||
import { useCreateOrUpdateMcp } from '@/composables/api/useMcp'
|
||||
|
||||
|
||||
@@ -172,7 +172,7 @@ import { useForm } from 'vee-validate'
|
||||
import { inject, computed, watch, nextTick, type Ref, ref } from 'vue'
|
||||
import { toTypedSchema } from '@vee-validate/zod'
|
||||
import z from 'zod'
|
||||
import { type ModelInfo } from '@memoh/shared'
|
||||
import { type ModelInfo } from '@/composables/api/useModels'
|
||||
import { useCreateModel, useUpdateModel } from '@/composables/api/useModels'
|
||||
|
||||
const formSchema = toTypedSchema(z.object({
|
||||
|
||||
@@ -1,9 +1,24 @@
|
||||
import { fetchApi } from '@/utils/request'
|
||||
import { useQuery, useMutation, useQueryCache } from '@pinia/colada'
|
||||
import { type MCPListItem } from '@memoh/shared'
|
||||
|
||||
// ---- Types ----
|
||||
|
||||
export interface MCPListItem {
|
||||
id: string
|
||||
type: string
|
||||
name: string
|
||||
config: {
|
||||
cwd: string
|
||||
env: Record<string, string>
|
||||
args: string[]
|
||||
type: string
|
||||
command: string
|
||||
}
|
||||
active: boolean
|
||||
user: string
|
||||
createdAt: string
|
||||
updatedAt: string
|
||||
}
|
||||
|
||||
export interface McpListResponse {
|
||||
items: MCPListItem[]
|
||||
}
|
||||
|
||||
@@ -1,10 +1,20 @@
|
||||
import { fetchApi } from '@/utils/request'
|
||||
import { useQuery, useMutation, useQueryCache } from '@pinia/colada'
|
||||
import { type ModelInfo } from '@memoh/shared'
|
||||
import type { Ref } from 'vue'
|
||||
|
||||
// ---- Types ----
|
||||
|
||||
export interface ModelInfo {
|
||||
dimensions: number
|
||||
is_multimodal: boolean
|
||||
input?: string[]
|
||||
llm_provider_id: string
|
||||
model_id: string
|
||||
name: string
|
||||
type: string
|
||||
enable_as?: string
|
||||
}
|
||||
|
||||
export interface CreateModelRequest {
|
||||
model_id: string
|
||||
type: string
|
||||
|
||||
@@ -1,10 +1,19 @@
|
||||
import { fetchApi } from '@/utils/request'
|
||||
import { useQuery, useMutation, useQueryCache } from '@pinia/colada'
|
||||
import { type ProviderInfo } from '@memoh/shared'
|
||||
import type { Ref } from 'vue'
|
||||
|
||||
// ---- Types ----
|
||||
|
||||
export interface ProviderInfo {
|
||||
api_key: string
|
||||
base_url: string
|
||||
client_type: string
|
||||
metadata: Record<'additionalProp1', object>
|
||||
name: string
|
||||
}
|
||||
|
||||
export const CLIENT_TYPES = ['openai', 'anthropic', 'google', 'ollama'] as const
|
||||
|
||||
export type ProviderWithId = ProviderInfo & { id: string }
|
||||
|
||||
export interface CreateProviderRequest {
|
||||
|
||||
@@ -89,7 +89,7 @@ import {
|
||||
ScrollArea,
|
||||
} from '@memoh/ui'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import type { ModelInfo } from '@memoh/shared'
|
||||
import type { ModelInfo } from '@/composables/api/useModels'
|
||||
import type { ProviderWithId } from '@/composables/api/useProviders'
|
||||
|
||||
const props = defineProps<{
|
||||
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
Badge,
|
||||
Button
|
||||
} from '@memoh/ui'
|
||||
import { type MCPListItem as MCPType } from '@memoh/shared'
|
||||
import { type MCPListItem as MCPType } from '@/composables/api/useMcp'
|
||||
import { i18nRef } from '@/i18n'
|
||||
import { useMcpList, useDeleteMcp } from '@/composables/api/useMcp'
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ import {
|
||||
Button,
|
||||
} from '@memoh/ui'
|
||||
import ConfirmPopover from '@/components/confirm-popover/index.vue'
|
||||
import { type ModelInfo } from '@memoh/shared'
|
||||
import { type ModelInfo } from '@/composables/api/useModels'
|
||||
|
||||
defineProps<{
|
||||
model: ModelInfo
|
||||
|
||||
@@ -51,7 +51,7 @@ import {
|
||||
} from '@memoh/ui'
|
||||
import CreateModel from '@/components/create-model/index.vue'
|
||||
import ModelItem from './model-item.vue'
|
||||
import { type ModelInfo } from '@memoh/shared'
|
||||
import { type ModelInfo } from '@/composables/api/useModels'
|
||||
|
||||
defineProps<{
|
||||
providerId: string | undefined
|
||||
|
||||
@@ -100,7 +100,7 @@ import { computed, watch } from 'vue'
|
||||
import { toTypedSchema } from '@vee-validate/zod'
|
||||
import z from 'zod'
|
||||
import { useForm } from 'vee-validate'
|
||||
import { type ProviderInfo } from '@memoh/shared'
|
||||
import { type ProviderInfo } from '@/composables/api/useProviders'
|
||||
|
||||
const props = defineProps<{
|
||||
provider: Partial<ProviderInfo & { id: string }> | undefined
|
||||
|
||||
@@ -28,9 +28,8 @@ import {
|
||||
EmptyMedia,
|
||||
EmptyTitle,
|
||||
} from '@memoh/ui'
|
||||
import { type ProviderInfo } from '@memoh/shared'
|
||||
import { type ProviderInfo, CLIENT_TYPES } from '@/composables/api/useProviders'
|
||||
import AddProvider from '@/components/add-provider/index.vue'
|
||||
import { clientType } from '@memoh/shared'
|
||||
import { useProviderList } from '@/composables/api/useProviders'
|
||||
|
||||
const filterProvider = ref('')
|
||||
@@ -141,7 +140,7 @@ const openStatus = reactive({
|
||||
<SelectContent>
|
||||
<SelectGroup>
|
||||
<SelectItem
|
||||
v-for="type in clientType"
|
||||
v-for="type in CLIENT_TYPES"
|
||||
:key="type"
|
||||
:value="type"
|
||||
>
|
||||
|
||||
@@ -32,7 +32,8 @@ import { Separator } from '@memoh/ui'
|
||||
import ProviderForm from './components/provider-form.vue'
|
||||
import ModelList from './components/model-list.vue'
|
||||
import { computed, inject, provide, reactive, ref, toRef, watch } from 'vue'
|
||||
import { type ProviderInfo, type ModelInfo } from '@memoh/shared'
|
||||
import { type ModelInfo } from '@/composables/api/useModels'
|
||||
import { type ProviderInfo } from '@/composables/api/useProviders'
|
||||
import {
|
||||
useUpdateProvider,
|
||||
useDeleteProvider,
|
||||
|
||||
Generated
-8
@@ -109,9 +109,6 @@ importers:
|
||||
'@elysiajs/eden':
|
||||
specifier: ^1.4.6
|
||||
version: 1.4.6(elysia@1.4.22(@sinclair/typebox@0.34.47)(@types/bun@1.3.8)(exact-mirror@0.2.6(@sinclair/typebox@0.34.47))(file-type@21.3.0)(openapi-types@12.1.3)(typescript@5.9.3))
|
||||
'@memoh/shared':
|
||||
specifier: workspace:*
|
||||
version: link:../shared
|
||||
chalk:
|
||||
specifier: ^5.4.1
|
||||
version: 5.6.2
|
||||
@@ -149,8 +146,6 @@ importers:
|
||||
|
||||
packages/sdk: {}
|
||||
|
||||
packages/shared: {}
|
||||
|
||||
packages/ui:
|
||||
dependencies:
|
||||
'@tailwindcss/vite':
|
||||
@@ -259,9 +254,6 @@ importers:
|
||||
'@memoh/sdk':
|
||||
specifier: workspace:*
|
||||
version: link:../sdk
|
||||
'@memoh/shared':
|
||||
specifier: workspace:*
|
||||
version: link:../shared
|
||||
'@memoh/ui':
|
||||
specifier: workspace:*
|
||||
version: link:../ui
|
||||
|
||||
Reference in New Issue
Block a user