Giter Club home page Giter Club logo

Comments (16)

acheong08 avatar acheong08 commented on July 18, 2024 3
chat_data = json.loads(resp.content.splitlines()[3])[0][2]
if not chat_data:
    return {"content": f"Google Bard encountered an error: {resp.content}."}
json_chat_data = json.loads(chat_data)
images = set()
if len(json_chat_data) >= 3:
    if len(json_chat_data[4][0]) >= 4:
        for img in json_chat_data[4][0][4]:
            images.add(img[0][0][0])
results = {
    "content": json_chat_data[0][0],
    "conversation_id": json_chat_data[1][0],
    "response_id": json_chat_data[1][1],
    "factualityQueries": json_chat_data[3],
    "textQuery": json_chat_data[2][0] if json_chat_data[2] is not None else "",
    "choices": [{"id": i[0], "content": i[1]} for i in json_chat_data[4]],
    "images": images,
}

from bard-api.

CatAnonymous avatar CatAnonymous commented on July 18, 2024 2

@dsdanielpark based on your code, I have converted it to PHP and support getting images
Bard AI PHP version

from bard-api.

dsdanielpark avatar dsdanielpark commented on July 18, 2024 1

acheong08

images = set()
        if len(json_chat_data) >= 3:
            if len(json_chat_data[4][0]) >= 3:
                for img in json_chat_data[4][0][4]:
                    images.add(img[0][0][0])

Could you kindly contribute by including this part and the part where "images" is the key?

from bard-api.

GordonLevy avatar GordonLevy commented on July 18, 2024 1

Please check this commit hash acbf3fba8453ea354a0b53e59230175a44500171

Was looking to have this feature in the official pip package - 'bardapi'

from bard-api.

dsdanielpark avatar dsdanielpark commented on July 18, 2024

Thank you for bringing up this interesting issue. While there is a high possibility that it may not work, I will investigate it further.

from bard-api.

GordonLevy avatar GordonLevy commented on July 18, 2024

Would really like it to have the links of generated images, maybe put a network interceptor to catch hold of these links - based on domain/sub-domain name maybe?

Edit : Found some libs like - mitmproxy (Man-in-the-Middle Proxy) that helps to intercept additional requests that the leading API req makes
So prob catch hold of t0.gstatic.com/images URI and acc append the response to the BARD API

from bard-api.

dsdanielpark avatar dsdanielpark commented on July 18, 2024
bard_links

Bard is a language model, not an image generation AI model. However, I have recently confirmed the addition of the image web search feature to Google Bard. As a temporary solution, it returns the links included in the response. Please note that this feature is temporary and is only deployed in the developer version. Please use it as follows.

pip install git+https://github.com/dsdanielpark/Bard-API.git
from bardapi import Bard
bard = Bard(token='xxxxxxxxxxx')
res = bard.get_answer("Find me an image of the main entrance of Stanford University.")
res['links']

from bard-api.

GordonLevy avatar GordonLevy commented on July 18, 2024

Yes, from the images response list - it looks the the uri for generated image is : t0.gstatic.com/images
which could be appended in the response string.

Any timelines around which this feature is deployed to prod?

from bard-api.

dsdanielpark avatar dsdanielpark commented on July 18, 2024

It is not desirable to continuously add specific functionalities to the developer deployment version. Therefore, we recommend post-processing and using the following approach instead.

token='xxxxxxxx'
bard = Bard(token=token)
link_list = bard.get_answer("Find me an image of the main entrance of Stanford University.")['links']
filtered_links = [link for link in link_list if "https://lh3.googleusercontent.com/" in link or "http://t0.gstatic.com/" in link]

print(filtered_links)

from bard-api.

GordonLevy avatar GordonLevy commented on July 18, 2024

Thanks for your detailed response, just have one final query : Any timelines around which this feature is deployed to prod?

from bard-api.

dsdanielpark avatar dsdanielpark commented on July 18, 2024

Please check this commit hash acbf3fba8453ea354a0b53e59230175a44500171

from bard-api.

acheong08 avatar acheong08 commented on July 18, 2024

I just added support in my repo
acheong08/Bard@1.0.3...1.1.0

You can parse for images

if len(json_chat_data) >= 3:
            for img in json_chat_data[4][0][4]:
                images.add(img[0][0][0])

from bard-api.

dsdanielpark avatar dsdanielpark commented on July 18, 2024

acheong08

Thank you, then I will modify and commit.

from bard-api.

dsdanielpark avatar dsdanielpark commented on July 18, 2024

GordonLevy

Use developer version or you can install via github tag. Refere this CoCoder package. https://github.com/dsdanielpark/Co-Coder/blob/main/requirements.txt

from bard-api.

MohitSM18 avatar MohitSM18 commented on July 18, 2024
bard_links

Bard is a language model, not an image generation AI model. However, I have recently confirmed the addition of the image web search feature to Google Bard. As a temporary solution, it returns the links included in the response. Please note that this feature is temporary and is only deployed in the developer version. Please use it as follows.

pip install git+https://github.com/dsdanielpark/Bard-API.git
from bardapi import Bard
bard = Bard(token='xxxxxxxxxxx')
res = bard.get_answer("Find me an image of the main entrance of Stanford University.")
res['links']

Hi Daniel, this works in Google colab and gives the links, but doesn't work on Jupyter notebook; why so?

from bard-api.

dsdanielpark avatar dsdanielpark commented on July 18, 2024

MohitSM18

There could be various reasons for the issue. If it continues to not work on your local Jupyter Notebook, please feel free to create a new issue. Thank you.

from bard-api.

Related Issues (20)

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.