mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-07-25 05:46:13 +00:00
perf: model testing
This commit is contained in:
@@ -101,7 +101,7 @@ class LLMModelsService:
|
|||||||
model=runtime_llm_model,
|
model=runtime_llm_model,
|
||||||
messages=[llm_entities.Message(role='user', content='Hello, world!')],
|
messages=[llm_entities.Message(role='user', content='Hello, world!')],
|
||||||
funcs=[],
|
funcs=[],
|
||||||
extra_args={},
|
extra_args=model_data.get('extra_args', {}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class AnthropicMessages(requester.ProviderAPIRequester):
|
|||||||
client: anthropic.AsyncAnthropic
|
client: anthropic.AsyncAnthropic
|
||||||
|
|
||||||
default_config: dict[str, typing.Any] = {
|
default_config: dict[str, typing.Any] = {
|
||||||
'base_url': 'https://api.anthropic.com/v1',
|
'base_url': 'https://api.anthropic.com',
|
||||||
'timeout': 120,
|
'timeout': 120,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,6 +44,7 @@ class AnthropicMessages(requester.ProviderAPIRequester):
|
|||||||
self.client = anthropic.AsyncAnthropic(
|
self.client = anthropic.AsyncAnthropic(
|
||||||
api_key='',
|
api_key='',
|
||||||
http_client=httpx_client,
|
http_client=httpx_client,
|
||||||
|
base_url=self.requester_cfg['base_url'],
|
||||||
)
|
)
|
||||||
|
|
||||||
async def invoke_llm(
|
async def invoke_llm(
|
||||||
@@ -141,7 +142,6 @@ class AnthropicMessages(requester.ProviderAPIRequester):
|
|||||||
args['tools'] = tools
|
args['tools'] = tools
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# print(json.dumps(args, indent=4, ensure_ascii=False))
|
|
||||||
resp = await self.client.messages.create(**args)
|
resp = await self.client.messages.create(**args)
|
||||||
|
|
||||||
args = {
|
args = {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ spec:
|
|||||||
zh_Hans: 基础 URL
|
zh_Hans: 基础 URL
|
||||||
type: string
|
type: string
|
||||||
required: true
|
required: true
|
||||||
default: "https://api.anthropic.com/v1"
|
default: "https://api.anthropic.com"
|
||||||
- name: timeout
|
- name: timeout
|
||||||
label:
|
label:
|
||||||
en_US: Timeout
|
en_US: Timeout
|
||||||
|
|||||||
@@ -298,6 +298,18 @@ export default function EmbeddingForm({
|
|||||||
|
|
||||||
function testEmbeddingModelInForm() {
|
function testEmbeddingModelInForm() {
|
||||||
setModelTesting(true);
|
setModelTesting(true);
|
||||||
|
const extraArgsObj: Record<string, string | number | boolean> = {};
|
||||||
|
form
|
||||||
|
.getValues('extra_args')
|
||||||
|
?.forEach((arg: { key: string; type: string; value: string }) => {
|
||||||
|
if (arg.type === 'number') {
|
||||||
|
extraArgsObj[arg.key] = Number(arg.value);
|
||||||
|
} else if (arg.type === 'boolean') {
|
||||||
|
extraArgsObj[arg.key] = arg.value === 'true';
|
||||||
|
} else {
|
||||||
|
extraArgsObj[arg.key] = arg.value;
|
||||||
|
}
|
||||||
|
});
|
||||||
httpClient
|
httpClient
|
||||||
.testEmbeddingModel('_', {
|
.testEmbeddingModel('_', {
|
||||||
uuid: '',
|
uuid: '',
|
||||||
@@ -309,6 +321,7 @@ export default function EmbeddingForm({
|
|||||||
timeout: 120,
|
timeout: 120,
|
||||||
},
|
},
|
||||||
api_keys: [form.getValues('api_key')],
|
api_keys: [form.getValues('api_key')],
|
||||||
|
extra_args: extraArgsObj,
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
console.log(res);
|
console.log(res);
|
||||||
|
|||||||
@@ -312,6 +312,18 @@ export default function LLMForm({
|
|||||||
|
|
||||||
function testLLMModelInForm() {
|
function testLLMModelInForm() {
|
||||||
setModelTesting(true);
|
setModelTesting(true);
|
||||||
|
const extraArgsObj: Record<string, string | number | boolean> = {};
|
||||||
|
form
|
||||||
|
.getValues('extra_args')
|
||||||
|
?.forEach((arg: { key: string; type: string; value: string }) => {
|
||||||
|
if (arg.type === 'number') {
|
||||||
|
extraArgsObj[arg.key] = Number(arg.value);
|
||||||
|
} else if (arg.type === 'boolean') {
|
||||||
|
extraArgsObj[arg.key] = arg.value === 'true';
|
||||||
|
} else {
|
||||||
|
extraArgsObj[arg.key] = arg.value;
|
||||||
|
}
|
||||||
|
});
|
||||||
httpClient
|
httpClient
|
||||||
.testLLMModel('_', {
|
.testLLMModel('_', {
|
||||||
uuid: '',
|
uuid: '',
|
||||||
@@ -324,7 +336,7 @@ export default function LLMForm({
|
|||||||
},
|
},
|
||||||
api_keys: [form.getValues('api_key')],
|
api_keys: [form.getValues('api_key')],
|
||||||
abilities: form.getValues('abilities'),
|
abilities: form.getValues('abilities'),
|
||||||
extra_args: form.getValues('extra_args'),
|
extra_args: extraArgsObj,
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
console.log(res);
|
console.log(res);
|
||||||
|
|||||||
@@ -257,7 +257,7 @@ export default function DebugDialog({
|
|||||||
sessionType,
|
sessionType,
|
||||||
messageChain,
|
messageChain,
|
||||||
selectedPipelineId,
|
selectedPipelineId,
|
||||||
120000,
|
180000,
|
||||||
);
|
);
|
||||||
|
|
||||||
setMessages((prevMessages) => [...prevMessages, response.message]);
|
setMessages((prevMessages) => [...prevMessages, response.message]);
|
||||||
|
|||||||
Reference in New Issue
Block a user