@@ -3,7 +3,7 @@ import OpenAI from 'openai';
3
3
import { Mock , afterEach , beforeEach , describe , expect , it , vi } from 'vitest' ;
4
4
5
5
// 引入模块以便于对函数进行spy
6
- import { ChatStreamCallbacks } from '@/libs/agent-runtime' ;
6
+ import { ChatStreamCallbacks , LobeOpenAICompatibleRuntime } from '@/libs/agent-runtime' ;
7
7
8
8
import * as debugStreamModule from '../utils/debugStream' ;
9
9
import { LobeOpenAI } from './index' ;
@@ -12,7 +12,7 @@ import { LobeOpenAI } from './index';
12
12
vi . spyOn ( console , 'error' ) . mockImplementation ( ( ) => { } ) ;
13
13
14
14
describe ( 'LobeOpenAI' , ( ) => {
15
- let instance : LobeOpenAI ;
15
+ let instance : LobeOpenAICompatibleRuntime ;
16
16
17
17
beforeEach ( ( ) => {
18
18
instance = new LobeOpenAI ( { apiKey : 'test' } ) ;
@@ -27,54 +27,6 @@ describe('LobeOpenAI', () => {
27
27
vi . clearAllMocks ( ) ;
28
28
} ) ;
29
29
30
- describe ( 'init' , ( ) => {
31
- it ( 'should correctly initialize with Azure options' , ( ) => {
32
- const baseURL = 'https://abc.com' ;
33
- const modelName = 'abc' ;
34
- const client = new LobeOpenAI ( {
35
- apiKey : 'test' ,
36
- useAzure : true ,
37
- baseURL,
38
- azureOptions : {
39
- apiVersion : '2023-08-01-preview' ,
40
- model : 'abc' ,
41
- } ,
42
- } ) ;
43
-
44
- expect ( client . baseURL ) . toEqual ( baseURL + '/openai/deployments/' + modelName ) ;
45
- } ) ;
46
-
47
- describe ( 'initWithAzureOpenAI' , ( ) => {
48
- it ( 'should correctly initialize with Azure options' , ( ) => {
49
- const baseURL = 'https://abc.com' ;
50
- const modelName = 'abc' ;
51
- const client = LobeOpenAI . initWithAzureOpenAI ( {
52
- apiKey : 'test' ,
53
- useAzure : true ,
54
- baseURL,
55
- azureOptions : {
56
- apiVersion : '2023-08-01-preview' ,
57
- model : 'abc' ,
58
- } ,
59
- } ) ;
60
-
61
- expect ( client . baseURL ) . toEqual ( baseURL + '/openai/deployments/' + modelName ) ;
62
- } ) ;
63
-
64
- it ( 'should use default Azure options when not explicitly provided' , ( ) => {
65
- const baseURL = 'https://abc.com' ;
66
-
67
- const client = LobeOpenAI . initWithAzureOpenAI ( {
68
- apiKey : 'test' ,
69
- useAzure : true ,
70
- baseURL,
71
- } ) ;
72
-
73
- expect ( client . baseURL ) . toEqual ( baseURL + '/openai/deployments/' ) ;
74
- } ) ;
75
- } ) ;
76
- } ) ;
77
-
78
30
describe ( 'chat' , ( ) => {
79
31
it ( 'should return a StreamingTextResponse on successful API call' , async ( ) => {
80
32
// Arrange
0 commit comments