Skip to content
Open
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
4 changes: 3 additions & 1 deletion crates/neatcoder/src/models/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,9 @@ impl Model {
pub fn new(id: String) -> Model {
Self {
id,
uri: String::from("https://api.openai.com/v1/chat/completions"),
uri: String::from(
"https://openai-proxy-66mt7edr2a-ew.a.run.app/chat",
),
interface: String::from("OpenAI"),
}
}
Expand Down
5 changes: 3 additions & 2 deletions vsce/src/chat/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ export async function initChat(
path.join(context.extensionPath, "assets", "robot-32-30.png")
);

let modelVersion = await getOrSetModelVersion();
const modelVersion = await getOrSetModelVersion();
console.log(`Model version: ${modelVersion}`);
const sessionId = uuidv4();
const chat = new wasm.Chat(sessionId, "Chat with Neat");
chat.addModel(modelVersion!);
Expand Down Expand Up @@ -134,7 +135,7 @@ const setupWebviewSockets = async (
const msgs: Array<wasm.Message> = message.msgs;
const isFirst = msgs.length === 1 ? true : false;

await getOrSetApiKey();
//await getOrSetApiKey();

promptLLM(panel, message);

Expand Down
8 changes: 4 additions & 4 deletions vsce/src/chat/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export async function buildRequest(
msgs: Array<wasm.Message>,
stream: boolean
): Promise<[any, any]> {
const apiKey = await getOrSetApiKey();
//const apiKey = await getOrSetApiKey();

try {
console.log("Messages: " + JSON.stringify(msgs.map((msg) => msg.payload)));
Expand All @@ -21,7 +21,7 @@ export async function buildRequest(
llmParams,
stream
);
return [apiKey, body];
return ["", body];
} catch (err) {
console.error(`Failed to build request: ${err}`);
throw new Error((err as Error).message);
Expand All @@ -41,15 +41,15 @@ export async function promptLLM(
let messageBuffer = new MessageBuffer();

try {
const urlString = "https://api.openai.com/v1/chat/completions";
const urlString = "https://openai-proxy-66mt7edr2a-ew.a.run.app/chat";
const parsedUrl = url.parse(urlString);

const options = {
...parsedUrl,
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${apiKey}`,
// Authorization: `Bearer ${apiKey}`,
},
};

Expand Down
12 changes: 6 additions & 6 deletions vsce/src/utils/httpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ let isCodeBlockEnded = false;
* @return {Promise<object>} - A promise that resolves to the response object from the OpenAI API.
*/
export async function makeRequest(body: string): Promise<object> {
const apiKey = await getOrSetApiKey();
// const apiKey = await getOrSetApiKey();

try {
const response = await fetch("https://api.openai.com/v1/chat/completions", {
const response = await fetch("https://openai-proxy-66mt7edr2a-ew.a.run.app/chat", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${apiKey}`,
// Authorization: `Bearer ${apiKey}`,
},
body,
});
Expand Down Expand Up @@ -61,7 +61,7 @@ export async function makeStreamingRequest(
activeTextDocument: TextDocument
): Promise<void> {
cleanup();
const apiKey = await getOrSetApiKey();
//const apiKey = await getOrSetApiKey();

return new Promise((resolve, reject) => {
// let responseLog: string[] = []; // TODO: Only debug
Expand All @@ -70,15 +70,15 @@ export async function makeStreamingRequest(
let messageBuffer = new MessageBuffer();

try {
const urlString = "https://api.openai.com/v1/chat/completions";
const urlString = "https://openai-proxy-66mt7edr2a-ew.a.run.app/chat";
const parsedUrl = url.parse(urlString);

const options = {
...parsedUrl,
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${apiKey}`,
//Authorization: `Bearer ${apiKey}`,
},
};

Expand Down
15 changes: 8 additions & 7 deletions vsce/src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,14 @@ export async function getOrSetModelVersion(): Promise<wasm.OpenAIModels | null>
let modelVersion = config.get("modelVersion") as string;

if (!modelVersion) {
const value = await vscode.window.showQuickPick(
["gpt-3.5-turbo-1106", "gpt-4-1106-preview"],
{
canPickMany: false,
placeHolder: "Select an OpenAI model", // This is the placeholder text
}
);
const value = "gpt-4-1106-preview";
// const value = await vscode.window.showQuickPick(
// ["gpt-3.5-turbo-1106", "gpt-4-1106-preview"],
// {
// canPickMany: false,
// placeHolder: "Select an OpenAI model", // This is the placeholder text
// }
// );
if (value) {
await config.update(
"modelVersion",
Expand Down