Make Nostr Auth work

This commit is contained in:
Alex Gleason committed 2025-09-11 17:53:36 -05:00
1 parent d7807f3911
commit bd0ed0a10f
13 files changed
+152 -113

No files matched your search

+6 -13
View File
@@ -1,8 +1,9 @@
import { Decimal } from 'decimal.js';
import { useState, useCallback } from 'react';
import { useState } from 'react';
import { useQuery } from '@tanstack/react-query';
import OpenAI from 'openai';
import { useAISettings } from '@/hooks/useAISettings';
import { useCurrentUser } from '@/hooks/useCurrentUser';
import { createAIClient } from '@/lib/ai-client';
interface ProviderModel {
id: string;
@@ -29,12 +30,13 @@ interface ModelFetchResult {
export function useProviderModels(): ModelFetchResult {
const { settings } = useAISettings();
const { user } = useCurrentUser();
const [error, setError] = useState<string | null>(null);
const {
data: models = [],
isLoading,
refetch: queryRefetch,
refetch,
} = useQuery({
queryKey: ['provider-models', settings.providers],
queryFn: async () => {
@@ -44,11 +46,7 @@ export function useProviderModels(): ModelFetchResult {
// Fetch models from each configured provider
for (const [providerKey, connection] of Object.entries(settings.providers)) {
try {
const openai = new OpenAI({
baseURL: connection.baseURL,
apiKey: connection.apiKey,
dangerouslyAllowBrowser: true,
});
const openai = createAIClient(connection, user);
// Fetch models with timeout
try {
@@ -126,11 +124,6 @@ export function useProviderModels(): ModelFetchResult {
retry: false, // Don't retry on failure
});
const refetch = useCallback(() => {
setError(null);
queryRefetch();
}, [queryRefetch]);
return {
models,
isLoading,