Comments (16)
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.
@dsdanielpark based on your code, I have converted it to PHP and support getting images
Bard AI PHP version
from bard-api.
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.
Please check this commit hash
acbf3fba8453ea354a0b53e59230175a44500171
Was looking to have this feature in the official pip package - 'bardapi'
from bard-api.
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.
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.
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.
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.
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.
Thanks for your detailed response, just have one final query : Any timelines around which this feature is deployed to prod?
from bard-api.
Please check this commit hash acbf3fba8453ea354a0b53e59230175a44500171
from bard-api.
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.
Thank you, then I will modify and commit.
from bard-api.
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.
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.
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)
- ChatBard: token_from_browser HOT 9
- ImportError: cannot import name 'BardCookies' from partially initialized module 'bardapi' (most likely due to a circular import) HOT 6
- Some code errors in README examples , os module import HOT 4
- Bard __SECURE-1PSID does not match HOT 2
- Exception: SNlM0e value not found. Double-check __Secure-1PSID value or pass it as Bard(token='xxxxx') HOT 1
- Google changed the the way "__Secure-1PSID" looks, how to use this package effectively,the cookie values does not end in '.' period now HOT 8
- Multiple-Cookies has been changed. HOT 15
- Image generation HOT 4
- Google renames its chatbot Bard to Gemini HOT 40
- Gemini Ultra? HOT 4
- TooManyRedirects: Exceeded 30 redirects. HOT 1
- Check out this Bard/Gemini project. HOT 2
- Google changed their __Secure-1PSID value stracture HOT 2
- ask_about_image Not working HOT 2
- Cookies refreshing very often and getting 429 all the time HOT 2
- How can automaticly get cookies value in no gui servers? HOT 2
- Please, go to Gemini-API `https://github.com/dsdanielpark/Gemini-API`
- a conversation towards getting advance AI HOT 1
- Reflection on the Bard API Project
- Connecting Geminei to Ads HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bard-api.