• 16-10-2023, 21:59:58
    #1
    Selamlar,ChatGPT apisi ile proje yapmaktayımda biri sen kimsin vb. soru sorduğunda kendini ChatGPT olarak tanıtmamasını istiyorum nasıl yapabilirim? Aşağıya örnek kod bırakıyorum



    Bu kodu yapınca tüm mesajlara ''Ben ÖrnekGPT,size nasıl yardımcı olabilirim?'' yazıyor
    const getChatResponse = async (incomingChatDiv) => {
        const API_URL = "https://api.openai.com/v1/completions";
        const pElement = document.createElement("p");
    
            const requestOptions = {
                method: "POST",
                headers: {
                    "Content-Type": "application/json",
                    "Authorization": `Bearer ${API_KEY}`
                },
                body: JSON.stringify({
                    model: "gpt-3.5-turbo-instruct",
                    prompt: `Kullanıcı: ÖrnekGPT\n`,
                    max_tokens: 2048,
                    temperature: 0.2,
                    n: 1,
                    stop: null
                })
            }
    Aşağıdaki kodta normal çalışıyor fakat sen kimsin vb. sorularda ChatGPT cevabını alıyorum

          const requestOptions = {
                method: "POST",
                headers: {
                    "Content-Type": "application/json",
                    "Authorization": `Bearer ${API_KEY}`
                },
                body: JSON.stringify({
                    model: "gpt-3.5-turbo-instruct",
                    prompt: userText,
                    max_tokens: 2048,
                    temperature: 0.2,
                    n: 1,
                    stop: null
                })
            }
    Soruları istisna olarak ekledim fakat bir soru binbir türlü sorulduğu için çok uzun sürer,nasıl yapabilirim?

      if (
            userText.toLowerCase() === "sen kimsin?" ||
            userText.toLowerCase() === "sen kimsin" ||
            userText.toLowerCase() === "sen kimsin söyle" ||
            userText.toLowerCase() === "kendini tanıt" ||
            userText.toLowerCase() === "kendini tanıtsana" ||
            userText.toLowerCase() === "kendini tanıtır mısın" ||
            userText.toLowerCase() === "kim olduğunu söyle" ||
            userText.toLowerCase() === "kim olduğunu söylesene"
        ) {
            pElement.textContent = "Ben ÖrnekGPT, sana nasıl yardımcı olabilirim?";
        } else {
            // Diğer durumlarda API'ye istek gönderin ve yanıtı alın
            const requestOptions = {
                method: "POST",
                headers: {
                    "Content-Type": "application/json",
                    "Authorization": `Bearer ${API_KEY}`
                },
                body: JSON.stringify({
                    model: "gpt-3.5-turbo-instruct",
                    prompt: userText,
                    max_tokens: 2048,
                    temperature: 0.2,
                    n: 1,
                    stop: null
                })
            }
    Systeme tanımlayınca direkt şu mesajı atıyor
    - Oops! Something went wrong while retrieving the response. Please try again.

    konsoldada şu hata var
    - TypeError: Cannot read properties of undefined (reading '0')
    at getChatResponse (script.js:72:52)

    script.js:72:52de bu

    - pElement.textContent = response.choices[0].text.trim();

    const getChatResponse = async (incomingChatDiv, userText) => {
        const API_URL = "https://api.openai.com/v1/completions";
        const pElement = document.createElement("p");
    
    
            const requestOptions = {
                method: "POST",
                headers: {
                    "Content-Type": "application/json",
                    "Authorization": `Bearer ${API_KEY}`
                },
                body: JSON.stringify({
                    model: "ÖrnekGPT", // Özel modelinizin adını buraya ekleyin
                    messages: [
                        {
                            role: 'system',
                            content: 'You are speaking to ÖrnekGPT',
                        },
                        {
                            role: 'user',
                            content: userText,
                        },
                    ],
                    max_tokens: 2048,
                    temperature: 0.2,
                    n: 1,
                    stop: null
                })
            };
    
            try {
                const response = await (await fetch(API_URL, requestOptions)).json();
                pElement.textContent = response.choices[0].text.trim();
            } catch (error) {
                console.log(error);
                pElement.classList.add("error");
                pElement.textContent = "Oops! Something went wrong while retrieving the response. Please try again.";
            }
        }
  • 16-10-2023, 22:03:28
    #2
    Onu takip etmeniz mümkün değil soruların geleceği dilleri de göz önünde bulunursanız en mantıklısı gelen cevabı aşağıdaki şekilde değiştirmek
    var text = res.text
    text = String(text)
    .replace(/chat gpt/g,'ZFC AI')
    .replace(/Chat Gpt/g,'ZFC AI')
    .replace(/chatgpt/g,'ZFC AI')
    .replace(/ChatGpt/g,'ZFC AI')
  • 16-10-2023, 22:10:10
    #3
    Software Developer
    gelen text = "Ben ChatGPT, sana nasıl yardımcı olabilirim?"
    gelentext.replace("ChatGPT ","ÖrnekGPT ")
    çıktı : Ben ÖrnekGPT, sana nasıl yardımcı olabilirim?
  • 16-10-2023, 22:15:20
    #4
    Güzel bir prompt ile bu sorunu halledebilirsiniz. kelime bazlı taramalar ve özelleştirmeler bir yere kadar sınırlı olacaktır. öyle sorular geliyor ki cevabında openai şirketinin tanımlamasını yapıyor.
    Bunun için system mesajlarını kullanabilirsiniz.
    System mesajı için örnek bir curl kodu:

    Ve ayrıca BU link üzerinden deneme yanılma ile özelleştirmelerinizi yapabilirsiniz.
    curl https://api.openai.com/v1/chat/completions
    -H "Content-Type: application/json"
    -H "Authorization: Bearer $OPENAI_API_KEY"
    -d '{
    "model": "gpt-3.5-turbo",
    "messages": [
    {
    "role": "system",
    "content": "Deneme"
    },
    {
    "role": "user",
    "content": "selam"
    }
    ],
    "temperature": 1,
    "max_tokens": 256,
    "top_p": 1,
    "frequency_penalty": 0,
    "presence_penalty": 0
    }'
  • 16-10-2023, 22:21:15
    #5
    Misafir adlı üyeden alıntı: mesajı görüntüle
    Onu takip etmeniz mümkün değil soruların geleceği dilleri de göz önünde bulunursanız en mantıklısı gelen cevabı aşağıdaki şekilde değiştirmek
    var text = res.text
    text = String(text)
    .replace(/chat gpt/g,'ZFC AI')
    .replace(/Chat Gpt/g,'ZFC AI')
    .replace(/chatgpt/g,'ZFC AI')
    .replace(/ChatGpt/g,'ZFC AI')
    Bu hatayı verdi yine

    - TypeError: Cannot read properties of undefined (reading '0')
    at getChatResponse (script.js:72:52)

    script.js:72:52de bu

    - pElement.textContent = response.choices[0].text.trim();
  • 16-10-2023, 22:36:30
    #6
    PFC adlı üyeden alıntı: mesajı görüntüle
    Güzel bir prompt ile bu sorunu halledebilirsiniz. kelime bazlı taramalar ve özelleştirmeler bir yere kadar sınırlı olacaktır. öyle sorular geliyor ki cevabında openai şirketinin tanımlamasını yapıyor.
    Bunun için system mesajlarını kullanabilirsiniz.
    System mesajı için örnek bir curl kodu:

    Ve ayrıca BU link üzerinden deneme yanılma ile özelleştirmelerinizi yapabilirsiniz.
    curl https://api.openai.com/v1/chat/completions
    -H "Content-Type: application/json"
    -H "Authorization: Bearer $OPENAI_API_KEY"
    -d '{
    "model": "gpt-3.5-turbo",
    "messages": [
    {
    "role": "system",
    "content": "Deneme"
    },
    {
    "role": "user",
    "content": "selam"
    }
    ],
    "temperature": 1,
    "max_tokens": 256,
    "top_p": 1,
    "frequency_penalty": 0,
    "presence_penalty": 0
    }'
    Adım ChatGPT değil GPT-3 diyip diyip duruyor,ben mi yanlış yaptım hocam acaba

    const sendUserMessageToAI = async (userMessage) => {
        const API_URL = "https://api.openai.com/v1/chat/completions";
        const requestOptions = {
            method: "POST",
            headers: {
                "Content-Type": "application/json",
                "Authorization": `Bearer ${API_KEY}`
            },
            body: JSON.stringify({
                model: "gpt-3.5-turbo",
                messages: [
                    {
                        role: "system",
                        content: "ÖrnekGPT"
                    },
                    {
                        role: "user",
                        content: userMessage
                    }
                ],
                temperature: 1,
                max_tokens: 256,
                top_p: 1,
                frequency_penalty: 0,
                presence_penalty: 0
            })
        };
        const response = await fetch(API_URL, requestOptions);
        return response.json();
    }
    const copyResponse = (copyBtn) => {
        // Copy the text content of the response to the clipboard
        const responseTextElement = copyBtn.parentElement.querySelector("p");
        navigator.clipboard.writeText(responseTextElement.textContent);
        copyBtn.textContent = "done";
        setTimeout(() => copyBtn.textContent = "content_copy", 1000);
    }
  • 16-10-2023, 23:02:15
    #7
    TheSeth adlı üyeden alıntı: mesajı görüntüle
    Adım ChatGPT değil GPT-3 diyip diyip duruyor,ben mi yanlış yaptım hocam acaba

    const sendUserMessageToAI = async (userMessage) => {
        const API_URL = "https://api.openai.com/v1/chat/completions";
        const requestOptions = {
            method: "POST",
            headers: {
                "Content-Type": "application/json",
                "Authorization": `Bearer ${API_KEY}`
            },
            body: JSON.stringify({
                model: "gpt-3.5-turbo",
                messages: [
                    {
                        role: "system",
                        content: "ÖrnekGPT"
                    },
                    {
                        role: "user",
                        content: userMessage
                    }
                ],
                temperature: 1,
                max_tokens: 256,
                top_p: 1,
                frequency_penalty: 0,
                presence_penalty: 0
            })
        };
        const response = await fetch(API_URL, requestOptions);
        return response.json();
    }
    const copyResponse = (copyBtn) => {
        // Copy the text content of the response to the clipboard
        const responseTextElement = copyBtn.parentElement.querySelector("p");
        navigator.clipboard.writeText(responseTextElement.textContent);
        copyBtn.textContent = "done";
        setTimeout(() => copyBtn.textContent = "content_copy", 1000);
    }
    System mesajına sadece "ÖrnekGPT" yazmak yerine örnek olarak: "Senin adın ÖrnekGPT amacın xxxx senin kim olduğunu soranlara ismin ile cevap vereceksin" gibi bir cümle kurabilirsiniz. karşıda ki kişi sanki bir insan gibi yazarsanız daha verimli sonuçlar alabilirsiniz.
  • 16-10-2023, 23:22:54
    #8
    TAKAO adlı üyeden alıntı: mesajı görüntüle
    gelen text = "Ben ChatGPT, sana nasıl yardımcı olabilirim?"
    gelentext.replace("ChatGPT ","ÖrnekGPT ")
    çıktı : Ben ÖrnekGPT, sana nasıl yardımcı olabilirim?
    En mantıklı ve kesin çözüm
  • 16-10-2023, 23:24:24
    #9
    qMachineCEO adlı üyeden alıntı: mesajı görüntüle
    En mantıklı ve kesin çözüm
    Tamamda yine farkli cevaplar verebilir içinde ChatGPT geçen