Интеграция ИИ для оценки текста на наличие опр. темы

Заказать скрипт
  • Доброго времени суток, ищу разработчика, который сможет реализовать задачу:

    Имеем текст в переменной TEXT, нужно оценить с помощью любой нейронки насколько этот текст соответствует тематике, например, психологии
    Ответ нужно положить в процентах, в переменную ANSWER

    ОЧЕНЬ ЖЕЛАТЕЛЬНО делать всё это дело через АПИ, без развёртывания модели на рабочей машине

    С офферами в ЛС, дальше перейдём в мессенджер

  • @vasenko said in Интеграция ИИ для оценки текста на наличие опр. темы:

    С офферами в ЛС,

    Могу и тут, бесплатно.

    Код не проверял:

    #!/usr/bin/env node
    
    /**
     * Google Privacy Sandbox Topics Classifier using OpenAI API
     * 
     * Purpose:
     * - Classifies input text into one of Google's Privacy Sandbox Topics (advertising categories)
     * - Uses OpenAI's GPT model to determine relevance and returns a confidence score (0-100%)
     * 
     * Dependencies:
     * - openai@^5.0.0 (npm install openai)
     * - Node.js v18+
     * 
     * Usage:
     * 1. Replace `your-api-key-here` with your OpenAI API key
     * 2. Set the `TEXT` variable to your input text
     * 3. Run: `node script.js`
     * 
     * References:
     * - Google Topics API: https://privacysandbox.google.com/private-advertising/topics
     * - Full Topics Taxonomy: https://github.com/patcg-individual-drafts/topics/blob/main/taxonomy_v2.md
     * - OpenAI API: https://platform.openai.com/docs/api-reference
     */
    
    import OpenAI from 'openai';
    
    // Initialize with environment variable (recommended)
    const openai = new OpenAI({
      apiKey: process.env.OPENAI_API_KEY || 'your-api-key-here' // Always use env vars in production
    });
    
    // Google's Topics Taxonomy (v2) - Simplified
    const GOOGLE_TOPICS = [
      'Arts & Entertainment', 'Autos & Vehicles', 'Beauty & Fitness',
      'Books & Literature', 'Business & Industrial', 'Finance',
      'Food & Drink', 'Health', 'Hobbies & Leisure', 'Home & Garden',
      'Internet & Telecom', 'Jobs & Education', 'Law & Government',
      'News', 'Online Communities', 'People & Society', 'Pets & Animals',
      'Real Estate', 'Reference', 'Science', 'Shopping', 'Sports',
      'Technology', 'Travel'
    ];
    
    // Example text for classification
    const TEXT = 'Meditation techniques for stress reduction...';
    
    /**
     * Classifies text into Google Topics with confidence score
     * @param {string} text - Input text to analyze
     * @returns {Promise<{topic: string, score: number, requestId: string}>}
     */
    async function classifyText(text) {
      try {
        const completion = await openai.chat.completions.create({
          model: 'o4-mini', # https://platform.openai.com/docs/models/o4-mini
          messages: [
            {
              role: 'system',
              content: `Classify this text into ONE Google Privacy Sandbox Topic. 
                       Strictly use: ${GOOGLE_TOPICS.join(', ')}.
                       Respond EXACTLY as: "TOPIC|SCORE%". Example: "Health|87%"`
            },
            { role: 'user', content: text }
          ],
          temperature: 0.3,
          max_tokens: 10
        });
    
        // Parse and validate response
        const response = completion.choices[0]?.message?.content;
        if (!response) throw new Error('No response from API');
    
        const [topic, score] = response.split('|');
        if (!topic || !score) throw new Error('Invalid response format');
    
        return {
          topic: topic.trim(),
          score: parseInt(score.replace('%', '')) || 0,
          requestId: completion._request_id || 'unknown'
        };
    
      } catch (error) {
        console.error(`Classification failed: ${error.message}`);
        return { topic: 'Error', score: 0, requestId: 'none' };
      }
    }
    
    // Execute with proper error handling
    (async () => {
      const { topic, score, requestId } = await classifyText(TEXT);
      
      console.log(`
      📊 Classification Result:
      Topic: ${topic}
      Confidence: ${score}%
      Request ID: ${requestId}
      
      🔗 References:
      - OpenAI npm: https://www.npmjs.com/package/openai
      - Google Topics: https://privacysandbox.google.com/private-advertising/topics
      `);
    })();
    
  • @andrwork said in Интеграция ИИ для оценки текста на наличие опр. темы:

    @vasenko said in Интеграция ИИ для оценки текста на наличие опр. темы:

    лс

    не советую данного кандидата, в лучим случаи получите через месяц и то мб получите.

  • @smedvedev87 said in Интеграция ИИ для оценки текста на наличие опр. темы:

    не советую данного кандидата, в лучим случаи получите через месяц и то мб получите.

    Я дал бесплатный вариант выше, немного шлифануть и все готово. Вроде бы задача стандартная, месяца работы тут нет, пропадать нет причин.