Skip to content
Merged
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
2 changes: 2 additions & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: actions/configure-pages@v5
with:
enablement: true
- uses: actions/upload-pages-artifact@v3
with:
path: public/
Expand Down
7 changes: 6 additions & 1 deletion src/server/cliRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ function runProcess(binary, args, timeoutMs) {
const child = spawn(binary, args, {
shell: false,
windowsHide: true,
env: process.env
env: {
PATH: process.env.PATH,
HOME: process.env.HOME,
LANG: process.env.LANG,
TERM: process.env.TERM
}
});
Comment on lines +65 to 71

let stdout = '';
Expand Down
11 changes: 10 additions & 1 deletion src/server/gammaClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,16 @@ async function fetchJson(url) {
headers: { Accept: 'application/json' }
});
const text = await response.text();
const data = text ? JSON.parse(text) : {};
let data = {};
if (text) {
try {
data = JSON.parse(text);
} catch {
throw new Error(
`Gamma API returned non-JSON response (${response.status}): ${text.slice(0, 200)}`
);
}
}
Comment on lines +13 to +22

if (!response.ok) {
throw new Error(
Expand Down
11 changes: 10 additions & 1 deletion src/server/ollamaClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,16 @@ async function fetchJson(url, options = {}) {
try {
const response = await fetch(url, { ...options, signal: controller.signal });
const text = await response.text();
const data = text ? JSON.parse(text) : {};
let data = {};
if (text) {
try {
data = JSON.parse(text);
} catch {
throw new Error(
`Ollama returned non-JSON response (${response.status}): ${text.slice(0, 200)}`
);
}
}
Comment on lines +23 to +32

if (!response.ok) {
throw new Error(
Expand Down
11 changes: 10 additions & 1 deletion src/server/openAiCompatibleClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,16 @@ async function fetchJson(url, options = {}) {
try {
const response = await fetch(url, { ...options, signal: controller.signal });
const text = await response.text();
const payload = text ? JSON.parse(text) : {};
let payload = {};
if (text) {
try {
payload = JSON.parse(text);
} catch {
throw new Error(
`Provider returned non-JSON response (${response.status}): ${text.slice(0, 200)}`
);
}
Comment on lines +9 to +17
}

if (!response.ok) {
throw new Error(
Expand Down