Skip to content

Role w systemie OpenAi

1. System (system)

Opis:

Ta rola służy do ustawienia początkowego kontekstu dla modelu. Wiadomości z rolą "system" dostarczają informacji o ogólnym zachowaniu modelu, jego tonie oraz instrukcjach dotyczących interakcji z użytkownikiem.

Przykład:

{ "role": "system", "content": "You are a helpful assistant." }

2. Użytkownik (user)

Opis:

Wiadomości z rolą "user" reprezentują wejścia od użytkownika. Te wiadomości zawierają zapytania, polecenia lub inne treści, na które model powinien odpowiedzieć. Każde zapytanie użytkownika rozpoczyna nową wymianę informacji.

Przykład:

{ "role": "user", "content": "Write an article about renewable energy in the style of a scientific journal. The article should answer the following question: What are the benefits of renewable energy sources?" }

3. Asystent (assistant)

Opis:

Wiadomości z rolą "assistant" reprezentują odpowiedzi generowane przez model. Te wiadomości są odpowiedzią na zapytania użytkownika i są generowane na podstawie kontekstu dostarczonego przez wiadomości "system" i "user".

Przykład:

{ "role": "assistant", "content": "Renewable energy sources offer numerous benefits, including reducing greenhouse gas emissions, decreasing dependency on fossil fuels, and providing sustainable energy solutions." }
  prompt = f"Write an article about '{topic}' in the style of {style}. The article should answer the following question: {user_query}"

    response = openai.ChatCompletion.create(
        model="gpt-4",
        messages=[
            {"role": "system", "content": "You are a helpful assistant."},
            {"role": "user", "content": prompt}
        ],
        max_tokens=1500,  # Dostosuj liczbę tokenów w zależności od długości artykułu
        temperature=0.7  # Dostosuj kreatywność odpowiedzi (0-1)
    )