Giter Site home page Giter Site logo

lexnewgate / palmnettest Goto Github PK

View Code? Open in Web Editor NEW

This project forked from doggy8088/palm.net

0.0 0.0 0.0 12 KB

A PaLM API wrapper for .NET that supports .NET Standard 2.0.

Home Page: https://www.nuget.org/packages/PaLM.NET/

License: MIT License

C# 100.00%

palmnettest's Introduction

PaLM.NET

A PaLM API (in Generative AI) wrapper for .NET that supports .NET Standard 2.0.

Usage

Get an API key

You have to get an API key from MakerSuite first.

Get PaLMClient instance

var apikey = Environment.GetEnvironmentVariable("GOOGLE_PALM_APIKEY");
var palm = new PaLMClient(apikey);

Text Prompt

var textPromptOptions = new TextOption()
{
    Temperature = 0.9,
    TopK = 40,
    TopP = 0.95,
    CandidateCount = 1,
    MaxOutputTokens = 1024
};

textPromptOptions.Prompt.Text = "I love Taipei because ";

var text_result = await palm.GenerateTextAsync(textPromptOptions);
Console.WriteLine(text_result.Candidates[0].Output);

Message Prompt (Chat)

var chatPromptOptions = new MessageOption()
{
    Temperature = 0.9,
    TopK = 40,
    TopP = 0.95,
    CandidateCount = 1
};

// Optional
chatPromptOptions.Context = "Be an alien that lives on one of Jupiter's moons";

// Optional
chatPromptOptions.AddExample(
    input: "How's it going?",
    output: "I am doing well, thank you for asking. I am currently enjoying the beautiful view of Jupiter from my home on Europa. The atmosphere is very thin here, so I can see the stars very clearly. The surface of Europa is also very interesting. It is covered in ice, but there are cracks in the ice that reveal a liquid ocean below. Scientists believe that this ocean may contain life, so I am very excited to learn more about it.\n\nHow are you doing today?"
);

// Required
chatPromptOptions.AddMessage("I'd like to visit, what should I do?");

var chat_result = await palm.GenerateMessageAsync(chatPromptOptions);
Console.WriteLine(chat_result.Candidates[0].Content);

Embeddings

var embeddingsOptions = new EmbeddingOption()
{
    Text = "Be an alien that lives on one of Jupiter's moons"
};

var embeddings_result = await palm.GenerateEmbeddingsAsync(embeddingsOptions);
foreach (double value in embeddings_result.Embedding.Values)
{
    Console.WriteLine(value);
}

palmnettest's People

Contributors

doggy8088 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.