Skip to content

Commit

Permalink
Merge branch 'main' into add_max_new_tokens
Browse files Browse the repository at this point in the history
Signed-off-by: Lukáš Janeček <[email protected]>
  • Loading branch information
Lukáš Janeček committed Oct 22, 2024
2 parents f0aa3a7 + 850dcbd commit 9a7f1c8
Show file tree
Hide file tree
Showing 9 changed files with 236 additions and 456 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Deployment

on:
push:
branches: ['main']

jobs:
deploy:
name: Deploy via Travis
runs-on: ubuntu-latest
environment: development
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3' # Not needed with a `.ruby-version` or `.tool-versions`
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: 'Install Travis CLI'
run: gem install travis --no-document
- name: 'Trigger rebuild'
run: travis restart --api-endpoint ${{ vars.TRAVIS_ENDPOINT }} --token ${{ secrets.TRAVIS_ACCESS_TOKEN }} --repo ${{ vars.TRAVIS_REPO }} ${{ vars.TRAVIS_BUILD }}
42 changes: 42 additions & 0 deletions .github/workflows/ghcr-publish-release-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: build and publish release image to GHCR

on:
release:
types: [released, prereleased]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract version from tag
id: get_version
run: |
echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Build and push bee-api image
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.get_version.outputs.VERSION }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache,mode=max
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bee-api",
"version": "0.0.1",
"version": "0.0.5",
"license": "Apache-2.0",
"author": "IBM Corp.",
"type": "module",
Expand Down Expand Up @@ -45,7 +45,7 @@
"@zilliz/milvus2-sdk-node": "^2.4.4",
"ajv": "^8.17.1",
"axios": "^1.7.7",
"bee-agent-framework": "0.0.32",
"bee-agent-framework": "0.0.33",
"bee-observe-connector": "0.0.4",
"bullmq": "5.8.1",
"cache-manager": "^5.7.6",
Expand Down
575 changes: 144 additions & 431 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/runs/execution/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import { LoadedRun } from '@/runs/execution/types.js';
import { UserResource } from '@/tools/entities/tool-resources/user-resource.entity.js';
import { SystemResource } from '@/tools/entities/tool-resources/system-resource.entity.js';
import { BEE_OBSERVE_API_AUTH_KEY, BEE_OBSERVE_API_URL } from '@/config.js';
import { Attachment } from '@/messages/attachment.entity';

const agentExecutionTime = new Summary({
name: 'agent_execution_time_seconds',
Expand Down Expand Up @@ -80,7 +81,7 @@ export async function executeRun(run: LoadedRun) {
(message) =>
new BaseMessage(
message.role,
`${message.content}${message.attachments && message.attachments.length > 0 ? `\n\nFiles:\n${message.attachments.map((attachment) => attachment.file.id).join('\n')}` : ''}`,
`${message.content}${message.attachments && message.attachments.length > 0 ? `\n\nFiles:\n${message.attachments.map((attachment) => (attachment as Loaded<Attachment, 'file'>).file.$.filename).join('\n')}` : ''}`,
{
createdAt: message.createdAt
}
Expand Down
6 changes: 3 additions & 3 deletions src/runs/execution/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export function createCodeLLM(backend: LLMBackend = LLM_BACKEND) {
});
return new IBMvLLM({
client: vllmClient,
modelId: 'meta-llama/llama-3-1-70b-instruct',
modelId: 'ibm/granite-34b-code-instruct',
parameters: {
method: 'GREEDY',
stopping: { include_stop_sequence: false, max_new_tokens: MAX_NEW_TOKENS }
Expand All @@ -188,7 +188,7 @@ export function createCodeLLM(backend: LLMBackend = LLM_BACKEND) {
bamClient ??= new BAMClient({ apiKey: BAM_API_KEY ?? undefined });
return new BAMLLM({
client: bamClient,
modelId: 'meta-llama/llama-3-1-70b-instruct',
modelId: 'ibm/granite-34b-code-instruct',
parameters: {
decoding_method: 'greedy',
include_stop_sequence: false,
Expand All @@ -200,7 +200,7 @@ export function createCodeLLM(backend: LLMBackend = LLM_BACKEND) {
if (!WATSONX_API_KEY) throw new Error('Missing WATSONX_API_KEY');
if (!WATSONX_PROJECT_ID) throw new Error('Missing WATSONX_PROJECT_ID');
return new WatsonXLLM({
modelId: 'meta-llama/llama-3-1-70b-instruct',
modelId: 'ibm/granite-34b-code-instruct',
apiKey: WATSONX_API_KEY,
projectId: WATSONX_PROJECT_ID,
region: WATSONX_REGION ?? undefined,
Expand Down
2 changes: 1 addition & 1 deletion src/runs/execution/tools/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export async function getTools(run: LoadedRun, context: AgentContext): Promise<F
llm: codeLLM,
promptTemplate: new PromptTemplate({
schema: z.object({ input: z.string() }),
template: `Your task is to fix the provided code that may or may not contain a syntax error.\nIMPORTANT: the output must not contain any additional comments or explanation.\n\nInput:\n{{input}}\n\nOutput:\n`
template: `Your task is to fix provided Python Code that may or may not contain a syntax error.\nIMPORTANT: the output must not contain any additional comments or explanation.\n\nInput:\n{{input}}\n\nOutput:\n`
})
}
: undefined
Expand Down
22 changes: 11 additions & 11 deletions src/runs/execution/tools/read-file-tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,25 @@ export class ReadFileTool extends Tool<StringToolOutput, ReadFileToolOptions> {
description = 'Retrieve file content.';
inputSchema() {
return z.object({
id:
filename:
this.options.files.length === 1
? z
.literal(this.options.files[0].id)
.describe(`Id of the file with name ${this.options.files[0].filename}`)
? z.literal(this.options.files[0].filename).describe(`Name of the file to read`)
: z
.union(
this.options.files.map((file) =>
z.literal(file.id).describe(`Id of the file with name ${file.filename}`)
) as [ZodLiteral<string>, ZodLiteral<string>, ...ZodLiteral<string>[]]
this.options.files.map((file) => z.literal(file.filename)) as [
ZodLiteral<string>,
ZodLiteral<string>,
...ZodLiteral<string>[]
]
)
.describe('File id.')
.describe('Name of the file to read.')
});
}

protected async _run({ id }: ToolInput<ReadFileTool>): Promise<StringToolOutput> {
const file = this.options.files.find((file) => file.id === id);
protected async _run({ filename }: ToolInput<ReadFileTool>): Promise<StringToolOutput> {
const file = this.options.files.find((file) => file.filename === filename);
if (!file) {
throw new ToolError(`File ${id} not found.`);
throw new ToolError(`File ${filename} not found.`);
}
try {
const fileObject = await getExtractedFileObject(file);
Expand Down
17 changes: 10 additions & 7 deletions src/tools/tools.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,8 @@ export async function listTools({
...searchTool,
inputSchema: searchTool.inputSchema,
isExternal: true,
userDescription: 'Retrieve real-time search results from across the internet.'
userDescription:
"Retrieve real-time search results from across the internet, including news, current events, or content from specific websites or domains. Leverages Google's indexing and search algorithms to provide relevant results, rather than functioning as a web scraper."
},
{
type: ToolType.SYSTEM,
Expand All @@ -492,7 +493,7 @@ export async function listTools({
inputSchema: wikipediaTool.inputSchema,
isExternal: true,
userDescription:
'Retrieve detailed information from Wikipedia.org on a wide range of topics.'
'Retrieve detailed information from Wikipedia.org on a wide range of topics, including famous individuals, locations, organizations, and historical events. Ideal for obtaining comprehensive overviews or specific details on well-documented subjects. May not be suitable for lesser-known or more recent topics. The information is subject to community edits which can be inaccurate.'
},
{
type: ToolType.SYSTEM,
Expand All @@ -502,7 +503,7 @@ export async function listTools({
inputSchema: weatherTool.inputSchema,
isExternal: true,
userDescription:
'Get real-time weather forecasts for up to 16 days and past data for 30 days.'
'Retrieve real-time weather forecasts including detailed information on temperature, wind speed, and precipitation. Access forecasts predicting weather up to 16 days in the future and archived forecasts for weather up to 30 days in the past. Ideal for obtaining up-to-date weather predictions and recent historical weather trends.'
},
{
type: ToolType.SYSTEM,
Expand All @@ -512,7 +513,7 @@ export async function listTools({
inputSchema: arXivTool.inputSchema,
isExternal: true,
userDescription:
'Retrieve abstracts of research articles published on ArXiv.org, along with their titles, authors, publication dates, and categories.'
'Retrieve abstracts of research articles published on ArXiv.org, along with their titles, authors, publication dates, and categories. Ideal for retrieving high-level information about academic papers. The full text of articles is not provided, making it unsuitable for full-text searches or advanced analytics.'
},
{
type: ToolType.SYSTEM,
Expand All @@ -521,7 +522,8 @@ export async function listTools({
...readFile,
inputSchema: readFile.inputSchema,
isExternal: false,
userDescription: 'Read and interpret basic files.'
userDescription:
'Read and interpret basic files to deliver summaries, highlight key points, and facilitate file comprehension. Ideal for straightforward tasks requiring access to raw data without any processing. Text (.txt, .md, .html) and JSON files (application/json) are supported up to 5 MB. PDF (.pdf) and text-based image files (.jpg, .jpeg, .png, .tiff, .bmp, .gif) are supported by the WDU text extraction service, limited to the content window of our base model, Llama 3.1 70B, which is 5 MB. The WDU text extraction service is used to extract text from image and PDF files, while text file types are handled by the LLM directly.'
}
]
: [];
Expand All @@ -546,7 +548,8 @@ export async function listTools({
...fileSearch,
inputSchema: fileSearch.inputSchema,
isExternal: false,
userDescription: 'Access and interpret file content by using advanced search techniques.'
userDescription:
'Read and interpret larger or more complex files using advanced search techniques where contextual understanding is required. Content parsing and chunking is used to break down large volumes of data into manageable pieces for effective analysis. Embeddings (numerical representations that capture the meaning and context of content) enable both traditional keyword and vector search. Vector search enhances the ability to identify similar content based on meaning, even if the exact words differ, improving the chances of identifying relevant information. Text (.txt, .md, .html) and JSON files (application/json) are supported up to 100 MB. PDF (.pdf) and text-based image files (.jpg, .jpeg, .png, .tiff, .bmp, .gif) are supported by the WDU text extraction service.'
});
}
if (pythonTool && (!type || type.includes(ToolType.CODE_INTERPRETER))) {
Expand All @@ -558,7 +561,7 @@ export async function listTools({
inputSchema: pythonTool.inputSchema,
isExternal: true,
userDescription:
'Execute Python code for various tasks, including data analysis, file processing, and visualizations.'
'Execute Python code for various tasks, including data analysis, file processing, and visualizations. Supports the installation of any library such as NumPy, Pandas, SciPy, and Matplotlib. Users can create new files or convert existing files, which are then made available for download.'
});
}

Expand Down

0 comments on commit 9a7f1c8

Please sign in to comment.