-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from jezekra1/feat-add-ibm-vllm-adapter
feat(ibm-vllm): add llm adapter
- Loading branch information
Showing
20 changed files
with
2,100 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import "dotenv/config.js"; | ||
import { IBMvLLM } from "bee-agent-framework/adapters/ibm-vllm/llm"; | ||
import { IBMVllmChatLLM } from "bee-agent-framework/adapters/ibm-vllm/chat"; | ||
import { BaseMessage } from "bee-agent-framework/llms/primitives/message"; | ||
import { Client } from "bee-agent-framework/adapters/ibm-vllm/client"; | ||
|
||
const client = new Client(); | ||
{ | ||
console.info("===RAW==="); | ||
const llm = new IBMvLLM({ | ||
client, | ||
modelId: "meta-llama/llama-3-1-70b-instruct", | ||
}); | ||
|
||
console.info("Meta", await llm.meta()); | ||
|
||
const response = await llm.generate("Hello world!", { | ||
stream: false, | ||
}); | ||
console.info(response.text); | ||
} | ||
|
||
{ | ||
console.info("===CHAT==="); | ||
const llm = IBMVllmChatLLM.fromPreset("meta-llama/llama-3-1-70b-instruct", { client }); | ||
|
||
console.info("Meta", await llm.meta()); | ||
|
||
const response = await llm.generate([ | ||
BaseMessage.of({ | ||
role: "user", | ||
text: "Hello world!", | ||
}), | ||
]); | ||
console.info(response.messages); | ||
} |
This file was deleted.
Oops, something went wrong.
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
53 changes: 53 additions & 0 deletions
53
scripts/ibm_vllm_generate_protos/ibm_vllm_generate_protos.sh
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,53 @@ | ||
#!/bin/bash | ||
# Copyright 2024 IBM Corp. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -e | ||
|
||
GRPC_PROTO_PATH="./src/adapters/ibm-vllm/proto" | ||
GRPC_TYPES_PATH="./src/adapters/ibm-vllm/types.ts" | ||
|
||
SCRIPT_DIR="$(dirname "$0")" | ||
OUTPUT_RELATIVE_PATH="dist/generation.d.ts" | ||
GRPC_TYPES_TMP_PATH=types | ||
|
||
rm -f "$GRPC_TYPES_PATH" | ||
|
||
rm -rf "${SCRIPT_DIR}"/{dist,dts,types} | ||
|
||
|
||
yarn run proto-loader-gen-types \ | ||
--defaults \ | ||
--keepCase \ | ||
--oneofs \ | ||
--longs=Number \ | ||
--enums=String \ | ||
--grpcLib=@grpc/grpc-js \ | ||
--"outDir=${SCRIPT_DIR}/${GRPC_TYPES_TMP_PATH}" \ | ||
"${GRPC_PROTO_PATH}"/*.proto | ||
|
||
|
||
cd "$SCRIPT_DIR" | ||
tsup --dts-only | ||
sed -i.bak '$ d' "$OUTPUT_RELATIVE_PATH" | ||
sed -i.bak -E "s/^interface/export interface/" "$OUTPUT_RELATIVE_PATH" | ||
sed -i.bak -E "s/^type/export type/" "$OUTPUT_RELATIVE_PATH" | ||
cd - | ||
|
||
mv "$SCRIPT_DIR/$OUTPUT_RELATIVE_PATH" "$GRPC_TYPES_PATH" | ||
rm -rf "${SCRIPT_DIR}"/{dist,dts,types} | ||
|
||
yarn run lint:fix "${GRPC_TYPES_PATH}" | ||
yarn prettier --write "${GRPC_TYPES_PATH}" | ||
yarn copyright |
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,6 @@ | ||
{ | ||
"name": "ibm-vllm-proto-types", | ||
"type": "module", | ||
"version": "1.0.0", | ||
"typings": "./types/generation.d.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,14 @@ | ||
{ | ||
"compilerOptions": { | ||
"moduleResolution": "node", | ||
"rootDir": ".", | ||
"baseUrl": ".", | ||
"target": "ESNext", | ||
"module": "ES6", | ||
"outDir": "dist", | ||
"declaration": true, | ||
"emitDeclarationOnly": true, | ||
"skipLibCheck": true, | ||
"sourceMap": false | ||
} | ||
} |
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,32 @@ | ||
/** | ||
* Copyright 2024 IBM Corp. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { defineConfig } from "tsup"; | ||
|
||
export default defineConfig({ | ||
entry: ["types/generation.ts"], | ||
tsconfig: "./tsconfig.proto.json", | ||
sourcemap: false, | ||
dts: true, | ||
format: ["esm"], | ||
treeshake: false, | ||
legacyOutput: false, | ||
skipNodeModulesBundle: true, | ||
bundle: true, | ||
splitting: false, | ||
silent: false, | ||
clean: true, | ||
}); |
Oops, something went wrong.