-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Fetch times out on low end devices serving OLLAMA #612
Comments
Thanks @ManuXD32 - we have a fully new networking stack for Big Agi 2 which in principles would allow to send ping packets to keep the connection alive. This may help, we'd need to test it. |
Ollama and big-AGI (server and client) are running on the phone. Thank you so much for your answer and work, I'm really loving it and truly enjoy running it on my server :) |
@ManuXD32 Oh wow thanks for the answer. How did you manage to run big-AGI fully on the phone? I want to try that out. |
Cool, I think ping is a nice approach. Here is a little guide on how to install it on android. Honestly it is so straight forward that I thought it was supported and I just didn't know it hahahah. I used proot-distro and termux:
|
@enricoros Hi there! this seems to be an issue when running on local hardware - ie., not just phones. Maybe adding in a setting to change the timeouts? This tells me, as a fellow developer (Appreciate your work, btw!) that the interface (Big-AGI) is timing out and reporting an error before the AI programs are finished processing the input stream. Additional info: I have had this issue with v1 Dev, v1 Stable, and v2 Dev. |
Hi @michieal was this with the latest v2-dev branch? It's the backend part of big-AGI (nodejs) timing out after 5 minutes of not receiving the headers of the http request. This happens in the deep of the network library (undici) of nodejs: nodejs/node#46375 Some people say it can be fixed other don't. I'd welcome a patch that tries to raise the network timeouts of the upstream fetch operation (src/modules/aix library, search for the "fetch("). |
The News page says that it's version "Big-AGI has been updated to version 1.16.8" though, when I used git to grab it, I swear that I was grabbing the V2 Dev branch.
I would love to be able to create a patch for this... but, it would be me blindly following what the AI said. I'm more of a desktop application / game development guy. I'll look at the code, but... I am probably gonna look like a monkey scratching his head. 🤣 |
It looks like that fetch could be changed... Since that has a hard coded timeout, maybe change it to use something that has the ability to specify a time out. I saw |
@michieal I took a quick look (trpc.router.fetchers.ts line 74 "response = await fetch(url, request);") This is a quick patch I put together: Index: src/server/trpc/trpc.router.fetchers.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/server/trpc/trpc.router.fetchers.ts b/src/server/trpc/trpc.router.fetchers.ts
--- a/src/server/trpc/trpc.router.fetchers.ts (revision 79c71a174088449776fef140d6841a444bca80dc)
+++ b/src/server/trpc/trpc.router.fetchers.ts (date 1734598201566)
@@ -2,6 +2,7 @@
import { debugGenerateCurlCommand, safeErrorString, SERVER_DEBUG_WIRE } from '~/server/wire';
+import { Agent as UndiciAgent, fetch, RequestInit, Response } from 'undici';
//
// NOTE: This file is used in the server-side code, and not in the client-side code.
@@ -13,7 +14,7 @@
// JSON fetcher
export async function fetchJsonOrTRPCThrow<TOut extends object = object, TBody extends object | undefined = undefined>(config: RequestConfig<TBody>): Promise<TOut> {
- return _fetchFromTRPC<TBody, TOut>(config, async (response) => await response.json(), 'json');
+ return _fetchFromTRPC<TBody, TOut>(config, async (response) => await response.json() as Promise<TOut>, 'json');
}
// Text fetcher
@@ -68,6 +69,11 @@
headers: headers !== undefined ? headers : undefined,
body: body !== undefined ? JSON.stringify(body) : undefined,
signal: signal !== undefined ? signal : undefined,
+ dispatcher: new UndiciAgent({
+ connectTimeout: 15 * 60 * 1000, // 15 min
+ headersTimeout: 15 * 60 * 1000, // 15 min
+ bodyTimeout: 15 * 60 * 1000, // 15 min
+ }),
};
// upstream fetch
Unfortunately I don't have time to test this thoroughly for now (as it impacts 15 model providers and more functions, this is core logic). The patch could also break in some other type conversations. Leaving this here for reference, but for now I think we'll need to tolerate the 5 min timeout unless someone else wants to take a stab at this. |
@enricoros How do I install the support for Undici? when I made the code changes, it gave me an error that it wasn't found... I figured that the least that I could do was to try this out and test it for Ollama and LocalAI for you. @ everyone - if you make a pr for this, tag me in the comments, so that I can help test it. TIA! |
Description
big-AGI uses fetch to retrieve API responses, the timeout is around 5 minutes so when low end devices like a phone serves ollama and has to process a big context, it just times out.
Device and browser
Android Redmagic 9 pro serving ollama and big-AGI, browser: Brave
Screenshots and more
No response
Willingness to Contribute
The text was updated successfully, but these errors were encountered: