Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ shell.nix
**/.jekyll-cache

.beaker.conf
.beaker/session-attachments/
beaker_config.py
beaker_*_config.py
src/beaker_notebook/**/ui/*
Expand Down
21 changes: 20 additions & 1 deletion beaker-ts/src/notebook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,22 @@ export type BeakerQueryEvent =
export interface IQueryCell extends nbformat.IBaseCell {
cell_type: 'query';
events: BeakerQueryEvent[];
session_attachments?: ISessionAttachment[];
}

export interface ISessionAttachment extends PartialJSONObject {
id: string;
name: string;
mimetype: string;
size: number;
kind: "file" | "archive";
path?: string | null;
root_path: string;
original_path?: string | null;
archive_status?: "extracted" | "failed" | null;
archive_error?: string | null;
file_count: number;
files: string[];
}

export class BeakerRawCell extends BeakerBaseCell implements nbformat.IRawCell {
Expand Down Expand Up @@ -335,6 +351,8 @@ export class BeakerMarkdownCell extends BeakerBaseCell implements nbformat.IMark
export class BeakerQueryCell extends BeakerBaseCell implements IQueryCell {
cell_type: "query" = "query";
events: BeakerQueryEvent[] = [];
/** Live-session chat attachments. Intentionally omitted from notebook serialization. */
session_attachments: ISessionAttachment[] = [];
_current_input_request_message?: messages.IInputRequestMsg;
_toolCallIndex: Map<string, {eventIndex: number; slot: number}> = new Map();

Expand Down Expand Up @@ -564,7 +582,8 @@ export class BeakerQueryCell extends BeakerBaseCell implements IQueryCell {
const future = session.sendBeakerMessage(
"llm_request",
{
request: this.source
request: this.source,
attachments: this.session_attachments.map((attachment) => attachment.id),
},
undefined,
metadata,
Expand Down
5 changes: 3 additions & 2 deletions beaker-ts/src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as nbformat from '@jupyterlab/nbformat';
import type { ConnectionStatus as JupyterConnectionStatus, IAnyMessageArgs } from '@jupyterlab/services/lib/kernel/kernel';

import { createMessageId, IBeakerAvailableContexts, IBeakerFuture, IActiveContextInfo } from './util';
import { BeakerNotebook, IBeakerShellMessage, IBeakerAnyMessage, BeakerRawCell, BeakerCodeCell, BeakerMarkdownCell, BeakerQueryCell, IBeakerIOPubMessage } from './notebook';
import { BeakerNotebook, IBeakerShellMessage, IBeakerAnyMessage, BeakerRawCell, BeakerCodeCell, BeakerMarkdownCell, BeakerQueryCell, IBeakerIOPubMessage, ISessionAttachment } from './notebook';
import { BeakerHistory } from './history';
import { BeakerRenderer, type IBeakerRendererOptions } from './render';
import { ChatHistory, type IChatHistory } from './chatHistory';
Expand Down Expand Up @@ -390,12 +390,13 @@ export class BeakerSession {
* @param metadata - (Optional) Any metadata to be associated with the cell.
* @returns - A reference to the generated cell
*/
public addQueryCell(source: string, metadata={}) {
public addQueryCell(source: string, metadata={}, sessionAttachments: ISessionAttachment[] = []) {
const cell = new BeakerQueryCell({
cell_type: "query",
source,
metadata,
});
cell.session_attachments = sessionAttachments;
this.notebook.addCell(cell);
return cell;
};
Expand Down
Loading