Skip to content

Commit

Permalink
Merge pull request #23 from LangStream/21-handle-the-decision-of-name…
Browse files Browse the repository at this point in the history
…-id-unknown-better

Added decision of name, id, or unknown
  • Loading branch information
ddieruf authored Aug 22, 2023
2 parents 6dccae0 + 08d3b39 commit 1b6ac58
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 3 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.2.1]

### Changed

For pipeline and agent, created a decision hierarchy to display either its name, id, or "unknown"

Contributors: ddieruf

## [0.2.0]

### Added
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "langstream",
"displayName": "LangStream AI",
"description": "Develop streaming generative AI applications with LangStream",
"version": "0.2.0",
"version": "0.2.1",
"publisher": "DataStax",
"engines": {
"vscode": "^1.77.0"
Expand Down
31 changes: 30 additions & 1 deletion src/providers/controlPlaneTreeData/nodes/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ export interface IAgentNode extends vscode.TreeItem {

export class AgentNode extends vscode.TreeItem implements IAgentNode {
constructor(readonly agent: lsModels.AgentConfiguration) {
super(agent.name ?? "unknown", vscode.TreeItemCollapsibleState.None);
super("unknown", vscode.TreeItemCollapsibleState.None);
this.description = `Agent`;
this.contextValue = Constants.CONTEXT_VALUES.agent;
this.label = this.decideLabel(agent);

switch(agent.errors?.retries ?? 0) {
case 0:
Expand All @@ -32,6 +33,34 @@ export class AgentNode extends vscode.TreeItem implements IAgentNode {
break;
}
}

private decideLabel(agent: lsModels.AgentConfiguration): string {
const name: string | undefined | null = agent.name?.trim()
.replace(/'null'/g, "")
.replace(/"null"/g, "")
.replace(/^\bnull\b$/i, "")
.replace(/"/g, "")
.replace(/'/g, "")
.replace(/`/g, "");

const id: string | undefined | null = agent.id?.trim()
.replace(/'null'/g, "")
.replace(/"null"/g, "")
.replace(/^\bnull\b$/i, "")
.replace(/"/g, "")
.replace(/'/g, "")
.replace(/`/g, "");

if(name !== undefined && name !== null && name.length > 0){
return name;
}

if(id !== undefined && id !== null && id.length > 0){
return id;
}

return "unknown";
}
}

export default class AgentTree {
Expand Down
31 changes: 30 additions & 1 deletion src/providers/controlPlaneTreeData/nodes/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,38 @@ export interface IPipelineNode extends vscode.TreeItem {

export class PipelineNode extends vscode.TreeItem implements IPipelineNode {
constructor(readonly pipeline: lsModels.Pipeline) {
super(pipeline.name ?? "unknown", vscode.TreeItemCollapsibleState.Collapsed);
super("unknown", vscode.TreeItemCollapsibleState.Collapsed);
this.description = `Pipeline`;
this.contextValue = `${Constants.CONTEXT_VALUES.pipeline}.${(pipeline.errors?.retries ?? 0) > 0 ? "errors" : "healthy"}`;
this.label = this.decideLabel(pipeline);
}

private decideLabel(pipeline: lsModels.Pipeline): string {
const name: string | undefined | null = pipeline.name?.trim()
.replace(/'null'/g, "")
.replace(/"null"/g, "")
.replace(/^\bnull\b$/i, "")
.replace(/"/g, "")
.replace(/'/g, "")
.replace(/`/g, "");

const id: string | undefined | null = pipeline.id?.trim()
.replace(/'null'/g, "")
.replace(/"null"/g, "")
.replace(/^\bnull\b$/i, "")
.replace(/"/g, "")
.replace(/'/g, "")
.replace(/`/g, "");

if(name !== undefined && name !== null && name.length > 0){
return name;
}

if(id !== undefined && id !== null && id.length > 0){
return id;
}

return "unknown";
}
}

Expand Down

0 comments on commit 1b6ac58

Please sign in to comment.