mirror of
https://github.com/geoffsee/open-gsio.git
synced 2025-09-08 22:56:46 +00:00
Refactor project: remove unused code, clean up logs, streamline error handling, update TypeScript configs, and enhance message streaming.
- Deployed
This commit is contained in:
@@ -19,7 +19,6 @@ export default types
|
||||
headers: Headers,
|
||||
env: Vike.PageContext.env,
|
||||
) {
|
||||
console.log("handleSsr");
|
||||
const pageContextInit = {
|
||||
urlOriginal: url,
|
||||
headersOriginal: headers,
|
||||
@@ -39,7 +38,6 @@ export default types
|
||||
}
|
||||
},
|
||||
async handleStaticAssets(request: Request, env) {
|
||||
console.log("handleStaticAssets");
|
||||
try {
|
||||
return await env.ASSETS.fetch(request);
|
||||
} catch (error) {
|
||||
|
@@ -151,7 +151,6 @@ const ChatService = types
|
||||
const providerRepo = new ProviderRepository(self.env);
|
||||
const providers = providerRepo.getProviders();
|
||||
|
||||
console.log({ providers })
|
||||
const providerModels = new Map<string, any[]>();
|
||||
const modelMeta = new Map<string, any>();
|
||||
|
||||
@@ -269,10 +268,9 @@ const ChatService = types
|
||||
}
|
||||
|
||||
const handler = useModelHandler();
|
||||
|
||||
|
||||
|
||||
if (handler) {
|
||||
console.log(`Using provider: ${modelFamily}`);
|
||||
try {
|
||||
await handler(streamParams, handleStreamData(controller, encoder));
|
||||
|
||||
@@ -330,7 +328,6 @@ const ChatService = types
|
||||
streamId,
|
||||
});
|
||||
} catch (e) {
|
||||
console.log("error caught at runModelHandler")
|
||||
throw e;
|
||||
}
|
||||
|
||||
@@ -362,8 +359,6 @@ const ChatService = types
|
||||
|
||||
|
||||
handleSseStream: flow(function* (streamId: string): Generator<Promise<string>, Response, unknown> {
|
||||
console.log(`chatService::handleSseStream::enter::${streamId}`);
|
||||
|
||||
// Check if a stream is already active for this ID
|
||||
if (self.activeStreams.has(streamId)) {
|
||||
return new Response('Stream already active', {status: 409});
|
||||
|
@@ -1,12 +1,8 @@
|
||||
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
||||
import { getSnapshot, applySnapshot } from 'mobx-state-tree';
|
||||
import ChatService, { ClientError } from '../ChatService.ts';
|
||||
import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
|
||||
import {getSnapshot} from 'mobx-state-tree';
|
||||
import ChatService, {ClientError} from '../ChatService.ts';
|
||||
import OpenAI from 'openai';
|
||||
import ChatSdk from '../../lib/chat-sdk.ts';
|
||||
import Message from '../../models/Message.ts';
|
||||
import { SUPPORTED_MODELS } from '@open-gsio/ai/supported-models';
|
||||
import handleStreamData from '../../lib/handleStreamData.ts';
|
||||
|
||||
// Create mock OpenAI instance
|
||||
const mockOpenAIInstance = {
|
||||
models: {
|
||||
|
Reference in New Issue
Block a user