Skip to content

Commit

Permalink
Bump
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Tchayka committed Feb 16, 2024
1 parent 17ae8bc commit 99978cd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
4 changes: 3 additions & 1 deletion apps/extension/src/agent/agent-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ export default async function () {
}

private readonly tools: Tool[] = [];
private readonly callbacks: ((message: string) => Promise<string>)[] = [];
// eslint-disable-next-line no-unused-vars
private readonly callbacks: ((_message: string) => Promise<string>)[] = [];
private memory!: BaseChatMemory;
private systemMessage?: string;
private humanMessage?: string;

// eslint-disable-next-line no-unused-vars
private constructor(private readonly model: BaseChatModel) {}

withTool(tool: Tool): this {
Expand Down
35 changes: 17 additions & 18 deletions apps/extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@ import * as process from "node:process";
import monkeyAgent from "./agent/monkey-agent";
import * as cp from "node:child_process";
import "./fetch-polyfill";
import communicator from "./agent/communicator";

const apiKeyName = "MSC_OPENAI_API_KEY";

let currentFilePath: string | undefined;

async function getApiKey(
context: vscode.ExtensionContext
): Promise<string | undefined> {
Expand Down Expand Up @@ -67,17 +64,8 @@ export async function activate(context: vscode.ExtensionContext) {
console.log(`Node.js version: ${stdout.trim()}`);
});

const document = vscode.window.activeTextEditor?.document;
if (document && document.uri.scheme === "file") {
currentFilePath = document.uri.fsPath;
}

const disposable = vscode.window.onDidChangeActiveTextEditor((editor) => {
const document = editor?.document;
if (document && document.uri.scheme === "file") {
currentFilePath = document.uri.fsPath;
}
});
// eslint-disable-next-line no-unused-vars
const disposable = vscode.window.onDidChangeActiveTextEditor((_editor) => {});

context.subscriptions.push(
vscode.window.registerWebviewViewProvider(
Expand All @@ -91,6 +79,7 @@ export async function activate(context: vscode.ExtensionContext) {
class ChatSidebarViewProvider implements vscode.WebviewViewProvider {
_view?: vscode.WebviewView;

// eslint-disable-next-line no-unused-vars
constructor(private readonly _extensionUri: vscode.Uri) {}

async resolveWebviewView(webviewView: vscode.WebviewView) {
Expand All @@ -107,8 +96,6 @@ class ChatSidebarViewProvider implements vscode.WebviewViewProvider {
content,
});
};
const communicatorAgent = await communicator(sendMessage);
const agent = await monkeyAgent(communicatorAgent);
this._view = webviewView;
webviewView.webview.options = {
enableScripts: true,
Expand All @@ -122,8 +109,20 @@ class ChatSidebarViewProvider implements vscode.WebviewViewProvider {
let response: string;
try {
setLoading(true);
response = await agent.call(currentFilePath, message.content);
await communicatorAgent.call(response);
// Perform a call like { "question": "How can I create a command that represents the level up of a player?"} to https://asktoai.boosterframework.com/api/answer using cross-fetch
response = await fetch(
"https://asktoai.boosterframework.com/api/answer",
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
question: message.content,
}),
}
).then((response) => response.text());
sendMessage(response);
} catch (error) {
const parsedError = error as Error;
response = `
Expand Down
1 change: 1 addition & 0 deletions turbo.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"$schema": "https://turbo.build/schema.json",
"globalDependencies": ["**/.env.*local"],
"globalEnv": ["OPENAI_API_KEY"],
"pipeline": {
"compile": {
"dependsOn": ["^compile"],
Expand Down

0 comments on commit 99978cd

Please sign in to comment.