Skip to content

Commit

Permalink
vscode use npx (#584)
Browse files Browse the repository at this point in the history
* use npx from vscode extension

* command file?

* typo

* support configurable server location

* setup cli location

* fix package script

* use constants

* slimming vscode host

* more splitting

* breaking down dependencies

* more splitting

* breaking dependencies

* drop more deps

* break more dependencies

* weird docs errors

* fix packaging
  • Loading branch information
pelikhan authored Jul 18, 2024
1 parent 8d3d122 commit 4be19c9
Show file tree
Hide file tree
Showing 54 changed files with 1,054 additions and 1,353 deletions.
3 changes: 2 additions & 1 deletion demo/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"cSpell.enabled": false
"cSpell.enabled": false,
"genaiscript.cli.path": "../packages/cli/built/genaiscript.cjs"
}
3 changes: 2 additions & 1 deletion docs/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"cSpell.words": [
"genaiscript",
"openai"
]
],
"genaiscript.cli.path": "../packages/cli/built/genaiscript.cjs"
}
1 change: 1 addition & 0 deletions docs/src/content/docs/slides.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ sidebar:
description: Slides
---

- [eng-july2024](/genaiscript/slides/eng-july2024/)
- [msr-eng-may2024](/genaiscript/slides/msr-eng-may2024/)
- [networking-apr2024](/genaiscript/slides/networking-apr2024/)
- [overview-june2024](/genaiscript/slides/overview-june2024/)
Expand Down
25 changes: 8 additions & 17 deletions packages/cli/src/nodehost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import { join } from "node:path"
import { createNodePath } from "./nodepath"
import { DockerManager } from "./docker"
import { DefaultAzureCredential, AccessToken } from "@azure/identity"
import { LanguageModel } from "../../core/src/chat"
import { createFileSystem } from "../../core/src/filesystem"
import { filterGitIgnore } from "../../core/src/gitignore"
import {
parseDefaultsFromEnv,
parseTokenFromEnv,
Expand All @@ -27,7 +28,7 @@ import {
TOOL_ID,
DEFAULT_EMBEDDINGS_MODEL,
} from "../../core/src/constants"
import { createFileSystem, filterGitIgnore } from "../../core/src/fs"
import { tryReadText } from "../../core/src/fs"
import {
ServerManager,
ModelService,
Expand All @@ -39,13 +40,10 @@ import {
setRuntimeHost,
ResponseStatus,
} from "../../core/src/host"
import {
parseModelIdentifier,
resolveLanguageModel,
} from "../../core/src/models"
import { createBundledParsers } from "../../core/src/pdf"
import { AbortSignalOptions, TraceOptions } from "../../core/src/trace"
import { logVerbose, unique } from "../../core/src/util"
import { parseModelIdentifier } from "../../core/src/models"

class NodeServerManager implements ServerManager {
async start(): Promise<void> {
Expand Down Expand Up @@ -166,16 +164,6 @@ export class NodeHost implements RuntimeHost {
return tok
}

async resolveLanguageModel(
options: {
model?: string
languageModel?: LanguageModel
},
configuration: LanguageModelConfiguration
): Promise<LanguageModel> {
return resolveLanguageModel(options, configuration)
}

log(level: LogLevel, msg: string): void {
if (msg === undefined) return
switch (level) {
Expand Down Expand Up @@ -231,7 +219,10 @@ export class NodeHost implements RuntimeHost {
windowsPathsNoEscape: true,
ignore,
})
if (applyGitIgnore) files = await filterGitIgnore(files)
if (applyGitIgnore) {
const gitignore = await tryReadText(".gitignore")
files = await filterGitIgnore(gitignore, files)
}
return unique(files)
}
async writeFile(name: string, content: Uint8Array): Promise<void> {
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { buildProject } from "./build"
import { createProgressSpinner } from "./spinner"
import { diagnosticsToCSV } from "../../core/src/ast"
import { CancellationOptions } from "../../core/src/cancellation"
import { ChatCompletionsProgressReport } from "../../core/src/chat"
import { Fragment, runTemplate } from "../../core/src/promptrunner"
import { ChatCompletionsProgressReport } from "../../core/src/chattypes"
import { runTemplate } from "../../core/src/promptrunner"
import {
githubCreateIssueComment,
githubCreatePullRequestReviews,
Expand All @@ -27,7 +27,7 @@ import {
GENAI_ANY_REGEX,
} from "../../core/src/constants"
import { isCancelError, errorMessage } from "../../core/src/error"
import { GenerationResult } from "../../core/src/expander"
import { Fragment, GenerationResult } from "../../core/src/generation"
import { parseKeyValuePairs } from "../../core/src/fence"
import { filePathOrUrlToWorkspaceFile, writeText } from "../../core/src/fs"
import { host, runtimeHost } from "../../core/src/host"
Expand Down
20 changes: 6 additions & 14 deletions packages/core/src/aici.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import {
ChatCompletionContentPartText,
ChatCompletionHandler,
ChatCompletionResponse,
LanguageModel,
LanguageModelInfo,
} from "./chat"
import { ChatCompletionHandler, LanguageModel, LanguageModelInfo } from "./chat"
import { PromptNode, visitNode } from "./promptdom"
import { fromHex, logError, normalizeInt, utf8Decode } from "./util"
import { AICI_CONTROLLER, TOOL_ID } from "./constants"
import { LanguageModelConfiguration, host } from "./host"
import { NotSupportedError, RequestError } from "./error"
import { createFetch } from "./fetch"
import { parseModelIdentifier } from "./models"
import {
AICIRequest,
ChatCompletionContentPartText,
ChatCompletionResponse,
} from "./chattypes"

function renderAICINode(node: AICINode) {
const { name } = node
Expand All @@ -32,13 +31,6 @@ function escapeJavascriptString(s: string) {
return s.replace(/`/g, "\\`")
}

export interface AICIRequest {
role: "aici"
content?: string
error?: unknown
functionName: string
}

export async function renderAICI(functionName: string, root: PromptNode) {
const notSupported = (reason: string) => () => {
throw new NotSupportedError(reason)
Expand Down
Loading

0 comments on commit 4be19c9

Please sign in to comment.