@lobehub/chat 0.148.4 → 0.148.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/package.json +2 -2
- package/src/app/settings/llm/TogetherAI/index.tsx +1 -0
- package/src/libs/agent-runtime/togetherai/index.ts +32 -1
- package/src/libs/agent-runtime/togetherai/type.ts +76 -0
- package/src/libs/agent-runtime/utils/openaiCompatibleFactory/index.ts +7 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog
|
|
4
4
|
|
|
5
|
+
### [Version 0.148.5](https://github.com/lobehub/lobe-chat/compare/v0.148.4...v0.148.5)
|
|
6
|
+
|
|
7
|
+
<sup>Released on **2024-04-22**</sup>
|
|
8
|
+
|
|
9
|
+
#### 💄 Styles
|
|
10
|
+
|
|
11
|
+
- **misc**: Support together ai to fetch model list.
|
|
12
|
+
|
|
13
|
+
<br/>
|
|
14
|
+
|
|
15
|
+
<details>
|
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
17
|
+
|
|
18
|
+
#### Styles
|
|
19
|
+
|
|
20
|
+
- **misc**: Support together ai to fetch model list, closes [#2138](https://github.com/lobehub/lobe-chat/issues/2138) ([e6d3e4a](https://github.com/lobehub/lobe-chat/commit/e6d3e4a))
|
|
21
|
+
|
|
22
|
+
</details>
|
|
23
|
+
|
|
24
|
+
<div align="right">
|
|
25
|
+
|
|
26
|
+
[](#readme-top)
|
|
27
|
+
|
|
28
|
+
</div>
|
|
29
|
+
|
|
5
30
|
### [Version 0.148.4](https://github.com/lobehub/lobe-chat/compare/v0.148.3...v0.148.4)
|
|
6
31
|
|
|
7
32
|
<sup>Released on **2024-04-21**</sup>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/chat",
|
|
3
|
-
"version": "0.148.
|
|
3
|
+
"version": "0.148.5",
|
|
4
4
|
"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.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"framework",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"@lobehub/chat-plugins-gateway": "latest",
|
|
93
93
|
"@lobehub/icons": "latest",
|
|
94
94
|
"@lobehub/tts": "latest",
|
|
95
|
-
"@lobehub/ui": "^1.138.
|
|
95
|
+
"@lobehub/ui": "^1.138.8",
|
|
96
96
|
"@next/third-parties": "^14.2.2",
|
|
97
97
|
"@sentry/nextjs": "^7.111.0",
|
|
98
98
|
"@vercel/analytics": "^1.2.2",
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import { LOBE_DEFAULT_MODEL_LIST } from '@/config/modelProviders';
|
|
2
|
+
|
|
1
3
|
import { AgentRuntimeErrorType } from '../error';
|
|
2
4
|
import { ModelProvider } from '../types';
|
|
3
5
|
import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory';
|
|
6
|
+
import { TogetherAIModel } from './type';
|
|
4
7
|
|
|
8
|
+
const baseURL = 'https://api.together.xyz';
|
|
5
9
|
export const LobeTogetherAI = LobeOpenAICompatibleFactory({
|
|
6
|
-
baseURL:
|
|
10
|
+
baseURL: `${baseURL}/v1`,
|
|
7
11
|
constructorOptions: {
|
|
8
12
|
defaultHeaders: {
|
|
9
13
|
'HTTP-Referer': 'https://chat-preview.lobehub.com',
|
|
@@ -17,5 +21,32 @@ export const LobeTogetherAI = LobeOpenAICompatibleFactory({
|
|
|
17
21
|
bizError: AgentRuntimeErrorType.TogetherAIBizError,
|
|
18
22
|
invalidAPIKey: AgentRuntimeErrorType.InvalidTogetherAIAPIKey,
|
|
19
23
|
},
|
|
24
|
+
models: async ({ apiKey }) => {
|
|
25
|
+
const data = await fetch(`${baseURL}/api/models`, {
|
|
26
|
+
headers: {
|
|
27
|
+
Authorization: `Bearer ${apiKey}`,
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
if (!data.ok) {
|
|
31
|
+
throw new Error(`Together Fetch Error: ${data.statusText || data.status}`);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const models: TogetherAIModel[] = await data.json();
|
|
35
|
+
|
|
36
|
+
return models
|
|
37
|
+
.filter((m) => m.display_type === 'chat')
|
|
38
|
+
.map((model) => {
|
|
39
|
+
return {
|
|
40
|
+
description: model.description,
|
|
41
|
+
displayName: model.display_name,
|
|
42
|
+
enabled: LOBE_DEFAULT_MODEL_LIST.find((m) => model.name.endsWith(m.id))?.enabled || false,
|
|
43
|
+
functionCall: model.description?.includes('function calling'),
|
|
44
|
+
id: model.name,
|
|
45
|
+
maxOutput: model.context_length,
|
|
46
|
+
tokens: model.context_length,
|
|
47
|
+
vision: model.description?.includes('vision') || model.name?.includes('vision'),
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
},
|
|
20
51
|
provider: ModelProvider.TogetherAI,
|
|
21
52
|
});
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
|
|
2
|
+
interface ModelInstanceConfig {
|
|
3
|
+
appearsIn: any[]; // 你可以替换为实际类型
|
|
4
|
+
order: number;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
interface Config {
|
|
8
|
+
add_generation_prompt: boolean;
|
|
9
|
+
chat_template: string;
|
|
10
|
+
prompt_format: string;
|
|
11
|
+
stop: string[];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface Pricing {
|
|
15
|
+
hourly: number;
|
|
16
|
+
input: number;
|
|
17
|
+
output: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface Instance {
|
|
21
|
+
avzone: string;
|
|
22
|
+
cluster: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface Depth {
|
|
26
|
+
asks: Record<string, number>;
|
|
27
|
+
asks_updated: string;
|
|
28
|
+
gpus: Record<string, number>;
|
|
29
|
+
num_asks: number;
|
|
30
|
+
num_bids: number;
|
|
31
|
+
num_running: number;
|
|
32
|
+
permit_required: boolean;
|
|
33
|
+
price: {
|
|
34
|
+
base: number;
|
|
35
|
+
finetune: number;
|
|
36
|
+
hourly: number;
|
|
37
|
+
input: number;
|
|
38
|
+
output: number;
|
|
39
|
+
};
|
|
40
|
+
qps: number;
|
|
41
|
+
stats: {
|
|
42
|
+
avzone: string;
|
|
43
|
+
capacity: number;
|
|
44
|
+
cluster: string;
|
|
45
|
+
error_rate: number;
|
|
46
|
+
qps: number;
|
|
47
|
+
retry_rate: number;
|
|
48
|
+
throughput_in: number;
|
|
49
|
+
throughput_out: number;
|
|
50
|
+
}[];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface TogetherAIModel {
|
|
54
|
+
_id: string;
|
|
55
|
+
access: string;
|
|
56
|
+
config: Config;
|
|
57
|
+
context_length: number;
|
|
58
|
+
created_at: string;
|
|
59
|
+
creator_organization: string;
|
|
60
|
+
depth: Depth;
|
|
61
|
+
description: string;
|
|
62
|
+
descriptionLink: string;
|
|
63
|
+
display_name: string;
|
|
64
|
+
display_type: string;
|
|
65
|
+
hardware_label: string;
|
|
66
|
+
instances: Instance[];
|
|
67
|
+
isFeaturedModel: boolean;
|
|
68
|
+
license: string;
|
|
69
|
+
link: string;
|
|
70
|
+
modelInstanceConfig: ModelInstanceConfig;
|
|
71
|
+
name: string;
|
|
72
|
+
num_parameters: number;
|
|
73
|
+
pricing: Pricing;
|
|
74
|
+
show_in_playground: boolean;
|
|
75
|
+
update_at: string;
|
|
76
|
+
}
|
|
@@ -38,9 +38,11 @@ interface OpenAICompatibleFactoryOptions {
|
|
|
38
38
|
bizError: ILobeAgentRuntimeErrorType;
|
|
39
39
|
invalidAPIKey: ILobeAgentRuntimeErrorType;
|
|
40
40
|
};
|
|
41
|
-
models?:
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
models?:
|
|
42
|
+
| ((params: { apiKey: string }) => Promise<ChatModelCard[]>)
|
|
43
|
+
| {
|
|
44
|
+
transformModel?: (model: OpenAI.Model) => ChatModelCard;
|
|
45
|
+
};
|
|
44
46
|
provider: string;
|
|
45
47
|
}
|
|
46
48
|
|
|
@@ -122,6 +124,8 @@ export const LobeOpenAICompatibleFactory = ({
|
|
|
122
124
|
}
|
|
123
125
|
|
|
124
126
|
async models() {
|
|
127
|
+
if (typeof models === 'function') return models({ apiKey: this.client.apiKey });
|
|
128
|
+
|
|
125
129
|
const list = await this.client.models.list();
|
|
126
130
|
|
|
127
131
|
return list.data
|