• Czas czytania ~1 min
  • 06.07.2023

Pakiet ChatGPT Mock API Generator dla Laravel generuje inteligentne makiety API w Laravel przy użyciu monitów ChatGPT:That would generate the following JSON response:

use YellowDigital\LaravelChatgptMockApi\Facades\ChatGPTMockApi;

Route::get("/mock-response", function() {
    return ChatGPTMockApi::generate(
        prompt: "European countries and their national food",
        keys: [
            "id",
            "name",
            "food",
            "food_description",
        ],
        count: 3,
    );
});

[
    {
        "id": 1,
        "name": "Italy",
        "food": "Pizza",
        "food_description": "A delicious round dough topped with tomato sauce, cheese and a variety of toppings."
    },
    {
        "id": 2,
        "name": "France",
        "food": "Croissants",
        "food_description": "A flaky, buttery pastry that is commonly eaten for breakfast or as a snack."
    },
    {
        "id": 3,
        "name": "Spain",
        "food": "Paella",
        "food_description": "A rice dish that originated in Valencia and is typically made with saffron, chicken, and shellfish."
    }
]

Aby uniknąć osiągnięcia limitów API (i być może poprawy wydajności przy kolejnych żądaniach), domyślnie ten pakiet buforuje wygenerowane odpowiedzi.

W chwili pisania tego tekstu pakiet ten oferuje również kilka innych funkcji, takich jak wyłączenie wspomnianej pamięci podręcznej i skonfigurowanie modelu ChatGPT używanego z monitem.

Możesz dowiedzieć się więcej o tym pakiecie, uzyskać pełne instrukcje instalacji i wyświetlić kod źródłowy w witrynie GitHub.You can learn more about this package, get full installation instructions, and view the source code on GitHub.

Comments

No comments yet
Yurij Finiv

Yurij Finiv

Full stack

O

Professional Fullstack Developer with extensive experience in website and desktop application development. Proficient in a wide range of tools and technologies, including Bootstrap, Tailwind, HTML5, CSS3, PUG, JavaScript, Alpine.js, jQuery, PHP, MODX, and Node.js. Skilled in website development using Symfony, MODX, and Laravel. Experience: Contributed to the development and translation of MODX3 i...

O autorze CrazyBoy49z
WORK EXPERIENCE
Kontakt
Ukraine, Lutsk
+380979856297