-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f28b2b8
commit 3a7fcd3
Showing
8 changed files
with
134 additions
and
21 deletions.
There are no files selected for viewing
This file contains 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 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 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
9 changes: 8 additions & 1 deletion
9
libs/shinkai-node-state/src/v2/mutations/addLLMProvider/index.ts
This file contains 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 |
---|---|---|
@@ -1,12 +1,19 @@ | ||
import { addLLMProvider as addLLMProviderAPI } from '@shinkai_network/shinkai-message-ts/api/jobs/index'; | ||
import { | ||
addLLMProvider as addLLMProviderAPI, | ||
testLLMProvider, | ||
} from '@shinkai_network/shinkai-message-ts/api/jobs/index'; | ||
|
||
import { AddLLMProviderInput } from './types'; | ||
|
||
export const addLLMProvider = async ({ | ||
nodeAddress, | ||
token, | ||
agent, | ||
enableTest, | ||
}: AddLLMProviderInput) => { | ||
if (!agent.model.Ollama && enableTest) { | ||
await testLLMProvider(nodeAddress, token, agent); | ||
} | ||
const data = await addLLMProviderAPI(nodeAddress, token, agent); | ||
return data; | ||
}; |
This file contains 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
19 changes: 19 additions & 0 deletions
19
libs/shinkai-node-state/src/v2/mutations/testLLMProvider/index.ts
This file contains 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,19 @@ | ||
import { | ||
addLLMProvider as addLLMProviderAPI, | ||
testLLMProvider, | ||
} from '@shinkai_network/shinkai-message-ts/api/jobs/index'; | ||
|
||
import { AddLLMProviderInput } from './types'; | ||
|
||
export const addLLMProvider = async ({ | ||
nodeAddress, | ||
token, | ||
agent, | ||
}: AddLLMProviderInput) => { | ||
if (!agent.model.Ollama) { | ||
await testLLMProvider(nodeAddress, token, agent); | ||
} | ||
|
||
const data = await addLLMProviderAPI(nodeAddress, token, agent); | ||
return data; | ||
}; |
11 changes: 11 additions & 0 deletions
11
libs/shinkai-node-state/src/v2/mutations/testLLMProvider/types.ts
This file contains 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,11 @@ | ||
import { Token } from '@shinkai_network/shinkai-message-ts/api/general/types'; | ||
import { | ||
AddLLMProviderResponse, | ||
SerializedLLMProvider, | ||
} from '@shinkai_network/shinkai-message-ts/api/jobs/types'; | ||
|
||
export type AddLLMProviderInput = Token & { | ||
nodeAddress: string; | ||
agent: SerializedLLMProvider; | ||
}; | ||
export type AddLLMProviderOutput = AddLLMProviderResponse; |
19 changes: 19 additions & 0 deletions
19
libs/shinkai-node-state/src/v2/mutations/testLLMProvider/useAddLLMProvider.ts
This file contains 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,19 @@ | ||
import type { UseMutationOptions } from '@tanstack/react-query'; | ||
import { useMutation } from '@tanstack/react-query'; | ||
|
||
import { APIError } from '../../types'; | ||
import { addLLMProvider } from '.'; | ||
import { AddLLMProviderInput, AddLLMProviderOutput } from './types'; | ||
|
||
type Options = UseMutationOptions< | ||
AddLLMProviderOutput, | ||
APIError, | ||
AddLLMProviderInput | ||
>; | ||
|
||
export const useAddLLMProvider = (options?: Options) => { | ||
return useMutation({ | ||
mutationFn: addLLMProvider, | ||
...options, | ||
}); | ||
}; |