Git Product home page Git Product logo

gpt4plugin's Introduction

GPT4Module for F#

This is a simple F# console application that uses the OpenAI API to generate text completions with the GPT-4 language model.

Features

  • Sends requests to the OpenAI API to generate text completions based on a given prompt.
  • Supports setting maximum tokens and number of generated text choices.
  • Reads the API key from an environment variable or command-line argument.
  • Handles API responses and displays generated text.

Dependencies

  • FSharp.Data: Used for the JSON type provider.
  • System.Net.Http: Used for making HTTP requests to the OpenAI API.
  • Argu: Used for command-line argument parsing.

Usage

Installing dependencies

  1. Install the .NET SDK for your operating system from the .NET download page.
  2. Run dotnet restore in the project directory to install the required F# libraries.

Setting the environment variable

  • Windows:

    setx OPENAI_API_KEY "your_api_key"
    
  • Linux and macOS:

    export OPENAI_API_KEY="your_api_key"
    

Replace "your_api_key" with your actual OpenAI API key.

Building and running the project

  1. Build the project with dotnet build.
  2. Run the application with the following command:
  • Windows:

    dotnet run -- --api-key %OPENAI_API_KEY% --prompt "your_prompt" [--max-tokens max_tokens] [--n n]
    
  • Linux and macOS:

    dotnet run -- --api-key $OPENAI_API_KEY --prompt "your_prompt" [--max-tokens max_tokens] [--n n]
    

Replace the following placeholders:

  • "your_prompt": The text prompt you want to use for the GPT-4 model.
  • max_tokens: The maximum number of tokens you want in the generated text (default is 50).
  • n: The number of generated text choices (default is 1).

Command-Line Arguments

Argument Description
--api-key Your OpenAI API key. Can be set as an environment variable (OPENAI_API_KEY).
--prompt The text prompt for the GPT-4 model.
--max-tokens The maximum number of tokens in the generated text. Default is 50.
--n The number of generated text choices. Default is 1.
--help Display help text for command-line arguments.

Example

To generate a text completion using the GPT-4 model with the prompt "Tell me something interesting about human life.", run:

dotnet run -- --api-key your_api_key --prompt "Tell me something interesting about human life."

Replace your_api_key with your actual OpenAI API key.

gpt4plugin's People

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.