Created
July 10, 2023 13:13
-
-
Save mertcanaltin/52664095500aba537d4c98240122e3f1 to your computer and use it in GitHub Desktop.
This code demonstrates a simple chat interface with ChatGPT using Python. It utilizes the Transformers library and the ChatGPT model. The code prompts the user for input, processes it with the model, and generates a response. The model used in this example is "gpt3.5-turbo," but you can choose a different model if desired. By adjusting the `max_…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from transformers import ChatGPT | |
| # ChatGPT modelini yükleyin | |
| model = ChatGPT("gpt3.5-turbo") | |
| # Başlamak için bir "sohbet" fonksiyonu oluşturun | |
| def sohbet_et(): | |
| while True: | |
| kullanici_girdisi = input("Kullanıcı: ") | |
| # Kullanıcı girdisini modelle işleyin | |
| model_girdisi = f"Kullanıcı: {kullanici_girdisi}\nChatGPT:" | |
| # Modelden cevap alın | |
| cevap = model.generate(model_girdisi, max_length=100, num_return_sequences=1)[0] | |
| # Modelin cevabını yazdırın | |
| print("ChatGPT:", cevap["generated_text"][len(model_girdisi) :].strip()) | |
| # Sohbeti başlatın | |
| sohbet_et() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment