開發了一個Java庫的Google Bard API,可以自動化與AI對話了

来源:https://www.cnblogs.com/larrydpk/archive/2023/03/25/17254753.html
-Advertisement-
Play Games

開發了一個Java庫的Google Bard API,可以自動化與AI對話了 Google Bard是Google提供的還在實驗階段的人工智慧對話服務。這明顯是對標ChatGPT來的,它可以提供更實時的答案,會基於Google強大的網頁數據。 為了更方便的使用並實現自動化,我寫了一個Java類庫,G ...


開發了一個Java庫的Google Bard API,可以自動化與AI對話了

Google Bard是Google提供的還在實驗階段的人工智慧對話服務。這明顯是對標ChatGPT來的,它可以提供更實時的答案,會基於Google強大的網頁數據。

為了更方便的使用並實現自動化,我寫了一個Java類庫,GitHub倉庫地址為:https://github.com/LarryDpk/Google-Bard

歡迎大家STAR...

如何使用

使用是非常簡單的,只要網路通就可以了。

引入依賴

<dependencies>
    <dependency>
        <groupId>com.pkslow</groupId>
        <artifactId>google-bard</artifactId>
        <version>0.0.1</version>
    </dependency>
</dependencies>

拿到驗證Token

目前沒有用戶名密碼的方式,直接有Token就行。但這個要從網頁上拿。它其實就是一個Cookie,名為__Secure-1PSID

據說Google未來會開放API介面,拭目以待吧。

Java代碼

兩行代碼即可:

AIClient client = new GoogleBardClient(token);
List<String> answers = client.ask("How to be a good father?");

返回的是一個列表:
如果Google Bard能夠回答問題,一般會給出三個答案。第一個是推薦的答案。

for (int i = 0; i < answers.size(); i++) {
    if (i == 0) {
        System.out.println("### Recommended Answer");
        System.out.println(answers.get(i));
    } else {
        System.out.println("### Answer " + i);
        System.out.println(answers.get(i));
    }
}

Google Bard目前還是實驗階段,只在美國英國可用,所以你懂的:

NetworkUtils.setUpProxy("localhost", "7890");

這個要在程式最開始設置。

我嘗試的問題如答案

我問了一個問題:How to be a good father?
答案是Markdown格式的,我獲得的答案如下:

Here are some tips on how to be a good father:

  • Spend time with your child. Quality time is essential for building a strong relationship with your child. Make time for activities that you both enjoy, such as playing games, going to the park, or reading stories.
  • Be a good role model. Children learn by watching the adults in their lives. Set a good example by being honest, kind, and respectful.
  • Be supportive. Let your child know that you are there for them, no matter what. Offer them your support and encouragement, especially when they are going through tough times.
  • Be a good communicator. Talk to your child about their day, their feelings, and their hopes and dreams. Let them know that they can come to you with anything.
  • Be patient. Parenting is a journey, not a destination. There will be times when you feel frustrated or overwhelmed. Remember to be patient with yourself and your child.
  • Be loving. The most important thing a father can do is to love his child unconditionally. Let your child know that you love them every day.

Being a good father is a lifelong journey. There is no one right way to do it. Just remember to be there for your child, be a good role model, and show them love.

Answer 1

Here are some tips on how to be a good father:

  • Spend time with your child. Quality time is essential for building a strong relationship with your child. Make time for activities that you both enjoy, such as playing games, going to the park, or reading stories.
  • Be a good role model. Children learn by watching the adults in their lives. Set a good example by being honest, kind, and respectful.
  • Be supportive. Let your child know that you are there for them, no matter what. Offer them your support and encouragement, especially when they are going through tough times.
  • Be a good communicator. Talk to your child about their day, their feelings, and their hopes and dreams. Let them know that they can come to you with anything.
  • Be patient. Parenting is a journey, not a destination. There will be times when you feel frustrated or overwhelmed. Remember to be patient with yourself and your child.
  • Be loving. The most important thing a father can do is to love his child unconditionally. Let your child know that you love them every day.

Being a good father is a lifelong journey. There is no one right way to do it. Just remember to be there for your child, be a good role model, and show them love.

Answer 2

Here are some tips on how to be a good father:

  • Spend time with your children. Make time for them, even if it's just for a few minutes each day. Talk to them, listen to them, and play with them.
  • Discipline with love and positive parenting. Set rules and boundaries, but be fair and consistent. Use positive reinforcement, such as praise and rewards, to encourage good behavior.
  • Be your child's role model. Show them what it means to be a good person by being honest, trustworthy, and kind.
  • Earn the right to be heard. Be a good listener and take your children's concerns seriously. When you give them advice, make sure it's based on your own experience and wisdom.
  • Be your child's teacher. Teach them about the world around them and help them to grow into responsible, independent adults.
  • Be there for your children, no matter what. Love them unconditionally and support them through thick and thin.

Being a good father is a lifelong journey. There will be times when you make mistakes, but that's okay. The important thing is to learn from your mistakes and keep trying to be the best father you can be.

Answer 3

Here are some tips on how to be a good father:

  • Spend time with your child. This is one of the most important things you can do as a father. Make time for your child every day, even if it's just for a few minutes. Play with them, read to them, or just talk to them.
  • Discipline with love and positive parenting. Discipline is important, but it should be done in a loving and positive way. Avoid yelling or hitting your child. Instead, try to explain why they are being disciplined and what they can do to avoid being disciplined in the future.
  • Be your child's role model. Children learn by watching the adults in their lives. Show your child what it means to be a good person by being someone they can look up to.
  • Earn the right to be heard. Children are more likely to listen to their parents if they respect them. Earn your child's respect by being a good role model and by being fair and consistent with your discipline.
  • Be your child's teacher. Teach your child about right and wrong and encourage them to do their best. Use everyday examples to help them learn the basic lessons of life.
  • Be there for your child. Your child needs to know that you are there for them, no matter what. Be supportive and loving, and let them know that you will always be there for them.

Being a good father is one of the most important things you can do in life. By following these tips, you can help your child grow into a happy, healthy, and successful adult.


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 電腦編程說到底還是程式員的思維體現,人情世故也會反映在代碼的邏輯上, 寫代碼就如學做人一樣,從哪裡來到哪裡去 ...
  • SpringBoot整合MyBatis/Plus 1.SpringBoot整合MyBatis 1.1整合案例 需求:整合SpringBoot和Mybatis,向資料庫中查詢數據。 項目結構: 1.1.1創建資料庫和表 -- 創建資料庫 DROP DATABASE IF EXISTS springbo ...
  • 概述 JWT,Java Web Token,通過 JSON 形式作為 Web 應用中的令牌,用於在各方之間安全地將信息作為 JSON 對象傳輸,在數據傳輸過程中還可以完成數據加密、簽名等相關處理 JWT 的作用如下: 授權:一旦用戶登錄,每個後續請求將包括 JWT,從而允許用戶訪問該令牌允許的路由, ...
  • 題目:數組反轉 要求: 把數組的內容反轉。 如:arr{ 11 , 22 , 33 , 44 , 55 , 66 } --> { 66 , 55 , 44 , 33 , 22 , 11 }。 思路-1 通過具體實例得,每一次都是將 arr[i] 和 arr[arr.length - 1 -i] 交換 ...
  • 原創:扣釘日記(微信公眾號ID:codelogs),歡迎分享,非公眾號轉載保留此聲明。 問題發生 上上周,看到一位老哥找我們組同事聯調介面,不知道是什麼問題,兩人坐一起搞了快1個小時,看起來好像有點複雜。 突然,老哥發出一聲卧槽,"我傳參里的+號,到你這怎麼變成了空格!",這個聲音很大,我明顯的聽到 ...
  • 一些用戶界面 數據文件 (XML) 參考: 該主題關聯文檔可以查看Data Files. 上一章,我們通過CSV文件添加了數據。當需要添加數據格式簡單時,用CSV格式還是很方便的,當數據格式更複雜時(比如視圖架構或者一個郵件模板),我們使用XML格式。比如包含HTML tags的 help fiel ...
  • 使用 VLD 記憶體泄漏檢測工具輔助開發時整理的學習筆記。本篇介紹在 QT 中使用 VLD 時,無記憶體泄漏時的輸出報告解析。 ...
  • 之前瞭解到通過UFUN函數UF_UGMGR_invoke_pdm_server可以調用Teamcenter ITK函數,從而可以獲取及編輯Teamcenter對象。UFUN中有樣例代碼,但是就是不知道怎麼使用,今天下午看了幫助文檔,想到需要把ITK的USER_invoke_pdm_server函數進 ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...