File tree Expand file tree Collapse file tree 4 files changed +47
-1
lines changed Expand file tree Collapse file tree 4 files changed +47
-1
lines changed Original file line number Diff line number Diff line change @@ -149,14 +149,31 @@ export const BedrockConverseChatCompleteConfig: ProviderConfig = {
149
149
required : true ,
150
150
transform : ( params : BedrockChatCompletionsParams ) => {
151
151
if ( ! params . messages ) return [ ] ;
152
- return params . messages
152
+ const transformedMessages = params . messages
153
153
. filter ( ( msg ) => msg . role !== 'system' )
154
154
. map ( ( msg ) => {
155
155
return {
156
156
role : msg . role === 'assistant' ? 'assistant' : 'user' ,
157
157
content : getMessageContent ( msg ) ,
158
158
} ;
159
159
} ) ;
160
+ let prevRole = '' ;
161
+ // combine user messages in succession
162
+ const combinedMessages = transformedMessages . reduce (
163
+ ( acc : typeof transformedMessages , msg ) => {
164
+ if ( msg . role === 'user' && prevRole === 'user' ) {
165
+ const lastMessage = acc [ acc . length - 1 ] ;
166
+ const newContent = [ ...lastMessage . content , ...msg . content ] ;
167
+ lastMessage . content = newContent as typeof lastMessage . content ;
168
+ } else {
169
+ acc . push ( msg ) ;
170
+ }
171
+ prevRole = msg . role ;
172
+ return acc ;
173
+ } ,
174
+ [ ]
175
+ ) ;
176
+ return combinedMessages ;
160
177
} ,
161
178
} ,
162
179
{
Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ import { UpstageConfig } from './upstage';
47
47
import { LAMBDA } from '../globals' ;
48
48
import { LambdaProviderConfig } from './lambda' ;
49
49
import { DashScopeConfig } from './dashscope' ;
50
+ import QdrantConfig from './qdrant' ;
50
51
51
52
const Providers : { [ key : string ] : ProviderConfigs } = {
52
53
openai : OpenAIConfig ,
@@ -94,6 +95,7 @@ const Providers: { [key: string]: ProviderConfigs } = {
94
95
upstage : UpstageConfig ,
95
96
[ LAMBDA ] : LambdaProviderConfig ,
96
97
dashscope : DashScopeConfig ,
98
+ qdrant : QdrantConfig ,
97
99
} ;
98
100
99
101
export default Providers ;
Original file line number Diff line number Diff line change
1
+ import { ProviderAPIConfig } from '../types' ;
2
+
3
+ const QdrantAPIConfig : ProviderAPIConfig = {
4
+ getBaseURL : ( { providerOptions } ) => {
5
+ return providerOptions . customHost || '' ;
6
+ } ,
7
+ headers : ( { providerOptions } ) => {
8
+ return { 'api-key' : `Bearer ${ providerOptions . apiKey } ` } ;
9
+ } ,
10
+ getEndpoint : ( { fn } ) => {
11
+ switch ( fn ) {
12
+ default :
13
+ return '' ;
14
+ }
15
+ } ,
16
+ } ;
17
+
18
+ export default QdrantAPIConfig ;
Original file line number Diff line number Diff line change
1
+ import { ProviderConfigs } from '../types' ;
2
+ import QdrantAPIConfig from './api' ;
3
+
4
+ const QdrantConfig : ProviderConfigs = {
5
+ api : QdrantAPIConfig ,
6
+ responseTransforms : { } ,
7
+ } ;
8
+
9
+ export default QdrantConfig ;
You can’t perform that action at this time.
0 commit comments