-
Notifications
You must be signed in to change notification settings - Fork 608
add feat. kluster_ai #1082
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
add feat. kluster_ai #1082
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e362618
add feat. kluster_ai
Ajay-Satish-01 51d4b29
fix: embed and chatComplete in KlusterAI
Ajay-Satish-01 8cc2c2c
Merge branch 'main' into kluster_ai
Ajay-Satish-01 71d6507
Merge branch 'main' into kluster_ai
Ajay-Satish-01 4e7a358
fix chatComplete object, add kluster ai to index
Ajay-Satish-01 3e33703
fix formatting
Ajay-Satish-01 79161ba
fix. removal of commented code
Ajay-Satish-01 a3dc20c
Merge branch 'main' into kluster_ai
Ajay-Satish-01 46dd457
Merge branch 'main' into kluster_ai
Ajay-Satish-01 b7f5dfe
Merge branch 'main' into kluster_ai
VisargD File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ProviderAPIConfig } from '../types'; | ||
|
||
const KlusterAIAPIConfig: ProviderAPIConfig = { | ||
getBaseURL: () => `https://api.kluster.ai/v1`, | ||
headers: ({ providerOptions }) => ({ | ||
'Content-Type': 'application/json', | ||
Authorization: `Bearer ${providerOptions.apiKey}`, | ||
}), | ||
getEndpoint: ({ fn }) => { | ||
switch (fn) { | ||
case 'chatComplete': | ||
return '/chat/completions'; | ||
case 'embed': | ||
return '/embeddings'; | ||
case 'uploadFile': | ||
return '/files'; | ||
default: | ||
return ''; | ||
} | ||
}, | ||
}; | ||
|
||
export default KlusterAIAPIConfig; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { KLUSTER_AI } from '../../globals'; | ||
import { OpenAIErrorResponseTransform } from '../openai/utils'; | ||
import { ChatCompletionResponse, ErrorResponse } from '../types'; | ||
|
||
interface KlusterAIChatCompleteResponse extends ChatCompletionResponse {} | ||
|
||
export const KlusterAIResponseTransform: ( | ||
response: KlusterAIChatCompleteResponse | ErrorResponse, | ||
responseStatus: number | ||
) => ChatCompletionResponse | ErrorResponse = (response, responseStatus) => { | ||
if (responseStatus !== 200 && 'error' in response) { | ||
return OpenAIErrorResponseTransform(response, KLUSTER_AI); | ||
} | ||
|
||
return response; | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { ProviderConfigs } from '../types'; | ||
import { KLUSTER_AI } from '../../globals'; | ||
import { | ||
chatCompleteParams, | ||
embedParams, | ||
responseTransformers, | ||
} from '../open-ai-base'; | ||
import KlusterAIAPIConfig from './api'; | ||
import { KlusterAIResponseTransform } from './chatComplete'; | ||
import { KlusterAIRequestTransform } from './uploadFile'; | ||
|
||
const KlusterAIConfig: ProviderConfigs = { | ||
chatComplete: chatCompleteParams( | ||
[], | ||
{ model: 'klusterai/Meta-Llama-3.1-8B-Instruct-Turbo' }, | ||
{ | ||
store: { | ||
param: 'store', | ||
}, | ||
metadata: { | ||
param: 'metadata', | ||
required: true, | ||
Ajay-Satish-01 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
} | ||
), | ||
embed: embedParams([], { | ||
model: 'klusterai/Meta-Llama-3.1-8B-Instruct-Turbo', | ||
}), | ||
api: KlusterAIAPIConfig, | ||
responseTransforms: { | ||
...responseTransformers(KLUSTER_AI, { | ||
chatComplete: true, | ||
embed: true, | ||
}), | ||
uploadFile: KlusterAIResponseTransform, | ||
}, | ||
requestTransforms: { | ||
uploadFile: KlusterAIRequestTransform, | ||
}, | ||
}; | ||
|
||
export default KlusterAIConfig; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const KlusterAIRequestTransform = (requestBody: ReadableStream) => { | ||
return requestBody; | ||
}; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.