Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support ChatGPT 5 lib w GPT-4 #58

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Update agent files
kristianmandrup committed Jun 13, 2023
commit 2302e6260caf2a9e44ec821c3062aece8caa7b46
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -133,7 +133,6 @@ We will need an agent running in the project root directory in the background to

It should only take into account files that are "source files" of the project. To achieve this, we can use `.gitignore` or `.npmignore` files along with a custom configuration.


### Chokidar agent with ignore files

We can use [chokidar](https://github.com/paulmillr/chokidar) as a battle-tested agent to monitor the file system for changes using file, dir, glob, or array of files to match.
@@ -167,6 +166,7 @@ The `file_agent.js` can be found in `src` and can be run simply via node:
Copy the `agent` folder of this repo to the root of your project folder:
- `file-agent.js`
- `agent-sync.js`
- `run-agent`
- `package.json`

The programming language will be detected based on the [languagemap](https://github.com/blakeembrey/language-map/blob/main/languages.json) based on Github's [linguist yaml language file](https://github.com/github-linguist/linguist/blob/master/lib/linguist/languages.yml)
15 changes: 9 additions & 6 deletions agent/agent-sync.js
Original file line number Diff line number Diff line change
@@ -2,6 +2,10 @@ const path = require("path");
const axios = require("axios");
const baseApiUrl = process.env.BASE_API_URL || 'http://0.0.0.0:8000';

const envProjPath = process.env.PROJECT_PATH;
const defaultPath = getPath.join(__dirname, '..');
const projPath = envProjPath || defaultPath;

const requestUpsertFile = async (filePath, fileOpts = {}, headers = {}) => {
try {
const file = fs.createReadStream(filePath);
@@ -70,12 +74,10 @@ const headers = {
"Authorization": "Bearer " + accessToken // token
};

const projectPath = process.env.PROJECT_PATH;

async function upsertFile (filePath) {
const opts = {};
if (projectPath) {
const relativePath = path.relative(projectPath, filePath);
if (projPath) {
const relativePath = path.relative(projPath, filePath);
opts = {relativePath};
}
const response = await requestUpsertFile(filePath, opts, headers);
@@ -89,5 +91,6 @@ async function deleteFile (filePath) {

module.exports = {
upsertFile,
deleteFile
}
deleteFile,
projPath
};
10 changes: 3 additions & 7 deletions agent/file-agent.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@


const sync = require("./agent-sync");
const getPath = require("path");
const watcher = require('ignoring-watcher');
const getProgrammingLanguage = requie("detect-programming-language");
const getProgrammingLanguage = require("detect-programming-language");

function getMeta(path) {
const ext = getPath.extname(path);
@@ -96,11 +94,11 @@ function getMeta(path) {
return meta;
}


function startWatcher(dir) {

const ignoringWatcher = watcher.createWatcher({
// Directory to watch. Defaults to process.cwd()
dir: dir || getPath.join(__dirname, '..'),
dir: dir || sync.projPath,

// Watch multiple directories instead of a single dir
dirs: ['some/dir', 'another/dir'],
@@ -161,8 +159,6 @@ function startWatcher(dir) {
sync.deleteFile(filePath);
});



ignoringWatcher.startWatching();
}

4 changes: 1 addition & 3 deletions agent/run-agent
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/usr/bin/env node

const projPath = process.env.PROJECT_PATH;

const { startWatcher } = require("./file-agent");
startWatcher(projPath);
startWatcher();