Giter VIP home page Giter VIP logo

gpt's Introduction

Gemini Text Generation

Gemini is a powerful text generation tool provided by Google that enables you to create diverse content using various input methods. This repository demonstrates how to leverage the Gemini API for different scenarios.

Generate Text from Text-Only Input

When the prompt input includes only text, you can use the gemini-pro model. To generate text output, run:

nodemon index.js

Generate Text from Text-and-Image Input (Multimodal)

Gemini also provides a multimodal model (gemini-pro-vision), allowing input of both text and images. Ensure you review the image requirements for prompts. To generate text output from text-and-image input, run:

nodemon app.js

Build Multi-turn Conversations (Chat)

Gemini facilitates the creation of freeform conversations across multiple turns. The SDK simplifies the process by managing the conversation state, eliminating the need to store the history manually.

To build a multi-turn conversation using the gemini-pro model, initialize the chat by calling startChat(). Then, use sendMessage() to send a new user message, which will also append the message and the response to the chat history.

There are two possible roles associated with the content in a conversation:

user: The role providing the prompts (default for sendMessage calls). model: The role providing the responses. This role can be used when calling startChat() with existing history. To build a multi-turn conversation, run:

nodemon server.js

Feel free to explore and adapt the provided examples to suit your specific use case.

Follow the prompts to interact with the generative model. Type "exit" to end the chat.

Configuration

  1. You can customize the chat behavior by modifying the generationConfig and safetySettings in the script:

  2. generationConfig: Adjust temperature, topK, topP, and maxOutputTokens for model output.

  3. safetySettings: Configure safety settings for blocking harmful content.

nodemon prompt.js

Requirements

  1. Node.js
  2. Gemini API Key (set as an environment variable)

License

This project is licensed under the MIT License.

gpt's People

Contributors

tonykalalian avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.