Google Gemini Pro 发布,暂时免费使用,提供一个傻瓜式网页工具调用

智能语音交互云存储智能应用

“ 暂时免费使用,如下图,抓紧白嫖把picture.image


        
          
https://blog.google/technology/ai/gemini-api-developers-cloud/  

      

如果只是测试,可以用本文提供的这个小工具,如下图,点击1对应的地址可以跳转到申请key的地方。 当然你可以直接访问下链接。


        
          
https://makersuite.google.com/app/apikey  

      

picture.image

申请了key,可以自己用curl请求,也可以粘贴到工具里

工具源码,复制到记事本里,另存为.html ,双击浏览器打开即可


        
          
<!DOCTYPE html>  
<html lang="en">  
  
<head>  
    <meta charset="UTF-8">  
    <meta name="viewport" content="width=device-width, initial-scale=1.0">  
    <title>Gemini demo</title>  
</head>  
  
<body>  
    <div style="display: flex; gap: 0.25rem; padding: 0.5rem;">  
        <div style="display: flex; flex-direction: column; gap: 0.25rem;">  
            <h3 style="margin: 0;">How to use:</h3>  
            <ol style="margin-top:0">  
                <li>申请AK: <a href="https://makersuite.google.com/app/apikey" style="color: #3b82f6;">Google AI Suite</a> </li>  
                <li>复制到下面第一个文本框</li>  
                <li>在下面 <b style="font-weight: bold;">文本框</b>输入提示词</li>  
                <li>点击 <b style="font-weight: bold;">generate</b></li>  
            </ol>  
            <input type="text" placeholder="Paste API key here" id="apiKeyInput" style="border: 1px solid; padding: 0.125rem; border-radius: 0.125rem;"></input>  
            <textarea placeholder="Prompt goes here" id="inputText" style="margin-top: 0.125rem; padding: 0.125rem; border: 1px solid; border-radius: 0.125rem;"></textarea>  
            <button id="generate" style="margin-top: 0.125rem; background-color: #3b82f6; color: white; padding: 0.125rem; border-radius: 0.125rem;">Generate</button>  
        </div>  
        <div id="resultText" style="white-space: pre-line; margin-left: auto; margin-right:auto; width: 32rem; ">Result will be here</div>  
    </div>  
  
  
    <script type="importmap">  
      {  
        "imports": {  
          "@google/generative-ai": "https://esm.run/@google/generative-ai"  
        }  
      }  
    </script>  
    <script type="module">  
        import { GoogleGenerativeAI } from "@google/generative-ai";  
        import { HarmBlockThreshold, HarmCategory } from "@google/generative-ai";  
  
  
  
        // ...  
        const inputText = document.querySelector("#inputText");  
        const resultText = document.querySelector("#resultText");  
  
        const safetySettings = [  
  
            {  
                category: HarmCategory.HARM_CATEGORY_HARASSMENT,  
                threshold: HarmBlockThreshold.BLOCK_NONE,  
            },  
            {  
                category: HarmCategory.HARM_CATEGORY_HATE_SPEECH,  
                threshold: HarmBlockThreshold.BLOCK_NONE,  
            },  
            {  
                category: HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT,  
                threshold: HarmBlockThreshold.BLOCK_NONE,  
            },  
            {  
                category: HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT,  
                threshold: HarmBlockThreshold.BLOCK_NONE,  
            }  
        ];  
        const generationConfig = {  
            maxOutputTokens: 16000,  
            temperature: 0.9  
        };  
  
  
  
        async function run() {  
  
            resultText.innerHTML = '';  
  
            // Access your API key (see "Set up your API key" above)  
  
            const API_KEY = document.querySelector("#apiKeyInput");  
            const genAI = new GoogleGenerativeAI(API_KEY.value);  
  
            // For text-only input, use the gemini-pro model  
            const model = genAI.getGenerativeModel({ model: "gemini-pro", generationConfig, safetySettings });  
  
            const prompt = inputText.value;  
  
            const result = await model.generateContentStream(prompt);  
  
            for await (const chunk of result.stream) {  
                const chunkText = chunk.text();  
                resultText.innerHTML += chunkText;  
            }  
        }  
  
        // Call the run function when the generate button is clicked  
        const generateButton = document.querySelector("#generate");  
        generateButton.addEventListener("click", run);  
  
        // ...  
    </script>  
</body>  
  
</html>  
  
  

      

picture.image

0
0
0
0
关于作者
关于作者

文章

0

获赞

0

收藏

0

相关资源
vivo 容器化平台架构与核心能力建设实践
为了实现规模化降本提效的目标,vivo 确定了基于云原生理念构建容器化生态的目标。在容器化生态发展过程中,平台架构不断演进,并针对业务的痛点和诉求,持续完善容器化能力矩阵。本次演讲将会介绍 vivo 容器化平台及主要子系统的架构设计,并分享重点建设的容器化核心能力。
相关产品
评论
未登录
看完啦,登录分享一下感受吧~
暂无评论