Spaces:
Build error
Build error
Mohammad Shahid commited on
Commit ·
b32e0ee
1
Parent(s): 0f100cf
Fix: Replace private submodule with HF-compatible stubs
Browse files- .gitmodules +0 -3
- src/shared +0 -1
- src/shared/3rd-party/cloud-flare.ts +6 -0
- src/shared/3rd-party/internal-serp.ts +9 -0
- src/shared/3rd-party/jina-embeddings.ts +6 -0
- src/shared/3rd-party/serper-search.ts +53 -0
- src/shared/db/api-roll.ts +16 -0
- src/shared/db/jina-embeddings-token-account.ts +24 -0
- src/shared/index.ts +3 -0
- src/shared/lib/errors.ts +28 -0
- src/shared/services/async-context.ts +16 -0
- src/shared/services/common-llm.ts +15 -0
- src/shared/services/firebase-storage-bucket.ts +16 -0
- src/shared/services/proxy-provider.ts +11 -0
- src/shared/services/secrets.ts +12 -0
- src/shared/utils/audition.ts +7 -0
- src/shared/utils/openai.ts +5 -0
- thinapps-shared +0 -1
.gitmodules
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
[submodule "thinapps-shared"]
|
| 2 |
-
path = thinapps-shared
|
| 3 |
-
url = https://github.com/jina-ai/thinapps-shared.git
|
|
|
|
|
|
|
|
|
|
|
|
src/shared
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
../thinapps-shared/backend
|
|
|
|
|
|
src/shared/3rd-party/cloud-flare.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// HF-compatible stub for CloudFlare
|
| 2 |
+
export class CloudFlareHTTP {
|
| 3 |
+
static async request(options: any): Promise<any> {
|
| 4 |
+
return { data: null };
|
| 5 |
+
}
|
| 6 |
+
}
|
src/shared/3rd-party/internal-serp.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// HF-compatible stub for Internal SERP API
|
| 2 |
+
export class JinaSerpApiHTTP {
|
| 3 |
+
static async search(params: any): Promise<any> {
|
| 4 |
+
return {
|
| 5 |
+
results: [],
|
| 6 |
+
total: 0
|
| 7 |
+
};
|
| 8 |
+
}
|
| 9 |
+
}
|
src/shared/3rd-party/jina-embeddings.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// HF-compatible stub for Jina Embeddings
|
| 2 |
+
export class JinaEmbeddingsDashboardHTTP {
|
| 3 |
+
static async request(options: any): Promise<any> {
|
| 4 |
+
return { data: [] };
|
| 5 |
+
}
|
| 6 |
+
}
|
src/shared/3rd-party/serper-search.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// HF-compatible stubs for Serper Search
|
| 2 |
+
export interface SerperSearchQueryParams {
|
| 3 |
+
q: string;
|
| 4 |
+
gl?: string;
|
| 5 |
+
hl?: string;
|
| 6 |
+
num?: number;
|
| 7 |
+
page?: number;
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
export interface SerperWebSearchResponse {
|
| 11 |
+
searchParameters: any;
|
| 12 |
+
organic: Array<{
|
| 13 |
+
title: string;
|
| 14 |
+
link: string;
|
| 15 |
+
snippet: string;
|
| 16 |
+
}>;
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
export interface SerperImageSearchResponse {
|
| 20 |
+
images: Array<{
|
| 21 |
+
title: string;
|
| 22 |
+
imageUrl: string;
|
| 23 |
+
imageWidth: number;
|
| 24 |
+
imageHeight: number;
|
| 25 |
+
}>;
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
export interface SerperNewsSearchResponse {
|
| 29 |
+
news: Array<{
|
| 30 |
+
title: string;
|
| 31 |
+
link: string;
|
| 32 |
+
snippet: string;
|
| 33 |
+
date: string;
|
| 34 |
+
}>;
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
export class SerperGoogleHTTP {
|
| 38 |
+
static async search(params: SerperSearchQueryParams): Promise<SerperWebSearchResponse> {
|
| 39 |
+
return {
|
| 40 |
+
searchParameters: params,
|
| 41 |
+
organic: []
|
| 42 |
+
};
|
| 43 |
+
}
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
export class SerperBingHTTP {
|
| 47 |
+
static async search(params: SerperSearchQueryParams): Promise<SerperWebSearchResponse> {
|
| 48 |
+
return {
|
| 49 |
+
searchParameters: params,
|
| 50 |
+
organic: []
|
| 51 |
+
};
|
| 52 |
+
}
|
| 53 |
+
}
|
src/shared/db/api-roll.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// HF-compatible stub for API Roll
|
| 2 |
+
export enum API_CALL_STATUS {
|
| 3 |
+
SUCCESS = 'success',
|
| 4 |
+
FAILED = 'failed',
|
| 5 |
+
PENDING = 'pending'
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
export class ApiCallRecord {
|
| 9 |
+
static async create(data: any): Promise<any> {
|
| 10 |
+
return { id: 'stub-id', ...data };
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
static async updateStatus(id: string, status: API_CALL_STATUS): Promise<void> {
|
| 14 |
+
// Stub implementation
|
| 15 |
+
}
|
| 16 |
+
}
|
src/shared/db/jina-embeddings-token-account.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// HF-compatible stub for Jina Embeddings Token Account
|
| 2 |
+
export interface JinaEmbeddingsTokenAccount {
|
| 3 |
+
id: string;
|
| 4 |
+
token: string;
|
| 5 |
+
userId: string;
|
| 6 |
+
createdAt: Date;
|
| 7 |
+
updatedAt: Date;
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
export class JinaEmbeddingsTokenAccountService {
|
| 11 |
+
static async findByUserId(userId: string): Promise<JinaEmbeddingsTokenAccount | null> {
|
| 12 |
+
return null;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
static async create(data: Partial<JinaEmbeddingsTokenAccount>): Promise<JinaEmbeddingsTokenAccount> {
|
| 16 |
+
return {
|
| 17 |
+
id: 'stub-id',
|
| 18 |
+
token: 'stub-token',
|
| 19 |
+
userId: data.userId || 'stub-user',
|
| 20 |
+
createdAt: new Date(),
|
| 21 |
+
updatedAt: new Date()
|
| 22 |
+
} as JinaEmbeddingsTokenAccount;
|
| 23 |
+
}
|
| 24 |
+
}
|
src/shared/index.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// HF-compatible stub for shared module entry
|
| 2 |
+
export * from './lib/errors';
|
| 3 |
+
export { SecretExposer } from './services/secrets';
|
src/shared/lib/errors.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// HF-compatible stub for error handling
|
| 2 |
+
export class ServiceBadAttemptError extends Error {
|
| 3 |
+
constructor(message: string) {
|
| 4 |
+
super(message);
|
| 5 |
+
this.name = 'ServiceBadAttemptError';
|
| 6 |
+
}
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
export class SecurityCompromiseError extends Error {
|
| 10 |
+
constructor(message: string) {
|
| 11 |
+
super(message);
|
| 12 |
+
this.name = 'SecurityCompromiseError';
|
| 13 |
+
}
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
export class ServiceCrashedError extends Error {
|
| 17 |
+
constructor(message: string) {
|
| 18 |
+
super(message);
|
| 19 |
+
this.name = 'ServiceCrashedError';
|
| 20 |
+
}
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
export class ServiceNodeResourceDrainError extends Error {
|
| 24 |
+
constructor(message: string) {
|
| 25 |
+
super(message);
|
| 26 |
+
this.name = 'ServiceNodeResourceDrainError';
|
| 27 |
+
}
|
| 28 |
+
}
|
src/shared/services/async-context.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// HF-compatible stub for Async Context
|
| 2 |
+
export class AsyncContext {
|
| 3 |
+
static get<T>(key: string): T | undefined {
|
| 4 |
+
// Stub implementation
|
| 5 |
+
return undefined;
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
static set<T>(key: string, value: T): void {
|
| 9 |
+
// Stub implementation
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
static run<T>(fn: () => T): T {
|
| 13 |
+
// Stub implementation
|
| 14 |
+
return fn();
|
| 15 |
+
}
|
| 16 |
+
}
|
src/shared/services/common-llm.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// HF-compatible stub for LLM Manager
|
| 2 |
+
export class LLMManager {
|
| 3 |
+
static async generate(options: any): Promise<string> {
|
| 4 |
+
// Stub implementation - returns empty for HF compatibility
|
| 5 |
+
return '';
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
static async generateStream(options: any): Promise<AsyncIterable<string>> {
|
| 9 |
+
// Stub implementation
|
| 10 |
+
async function* emptyGenerator() {
|
| 11 |
+
yield '';
|
| 12 |
+
}
|
| 13 |
+
return emptyGenerator();
|
| 14 |
+
}
|
| 15 |
+
}
|
src/shared/services/firebase-storage-bucket.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// HF-compatible stub for Firebase Storage
|
| 2 |
+
export class FirebaseStorageBucketControl {
|
| 3 |
+
static async upload(data: any, path: string): Promise<string> {
|
| 4 |
+
// Stub implementation - returns empty URL for HF compatibility
|
| 5 |
+
return '';
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
static async download(path: string): Promise<Buffer | null> {
|
| 9 |
+
// Stub implementation
|
| 10 |
+
return null;
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
static async delete(path: string): Promise<void> {
|
| 14 |
+
// Stub implementation
|
| 15 |
+
}
|
| 16 |
+
}
|
src/shared/services/proxy-provider.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// HF-compatible stub for Proxy Provider
|
| 2 |
+
export class ProxyProviderService {
|
| 3 |
+
static async getProxy(): Promise<string | null> {
|
| 4 |
+
// Stub implementation - returns no proxy for HF compatibility
|
| 5 |
+
return null;
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
static async releaseProxy(proxy: string): Promise<void> {
|
| 9 |
+
// Stub implementation
|
| 10 |
+
}
|
| 11 |
+
}
|
src/shared/services/secrets.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// HF-compatible stub for secrets management
|
| 2 |
+
export class SecretExposer {
|
| 3 |
+
static get(key: string): string {
|
| 4 |
+
return process.env[key] || '';
|
| 5 |
+
}
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
const envConfig = {
|
| 9 |
+
get: (key: string) => process.env[key] || ''
|
| 10 |
+
};
|
| 11 |
+
|
| 12 |
+
export default envConfig;
|
src/shared/utils/audition.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// HF-compatible stub for audition middleware
|
| 2 |
+
export function getAuditionMiddleware() {
|
| 3 |
+
return (req: any, res: any, next: any) => {
|
| 4 |
+
// Stub implementation - just pass through
|
| 5 |
+
next();
|
| 6 |
+
};
|
| 7 |
+
}
|
src/shared/utils/openai.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// HF-compatible stub for OpenAI utils
|
| 2 |
+
export function countGPTToken(text: string): number {
|
| 3 |
+
// Simple stub - estimate tokens as words / 0.75
|
| 4 |
+
return Math.ceil(text.split(/\s+/).length / 0.75);
|
| 5 |
+
}
|
thinapps-shared
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
Subproject commit 02279d88bc3940a08a92cb18cf8877d57cb49b82
|
|
|
|
|
|