From e0f5e837299aab9a6b398aa498dee5baeb177d61 Mon Sep 17 00:00:00 2001 From: kqlio67 <166700875+kqlio67@users.noreply.github.com> Date: Sat, 28 Dec 2024 19:11:48 +0000 Subject: Update docs/. etc/. g4f/. README.md (#2515) Co-authored-by: kqlio67 <> --- etc/examples/vision_images_reka.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 etc/examples/vision_images_reka.py (limited to 'etc/examples/vision_images_reka.py') diff --git a/etc/examples/vision_images_reka.py b/etc/examples/vision_images_reka.py new file mode 100755 index 00000000..6b3a88ab --- /dev/null +++ b/etc/examples/vision_images_reka.py @@ -0,0 +1,27 @@ +# Image Chat with Reca +# !! YOU NEED COOKIES / BE LOGGED IN TO chat.reka.ai +# download an image and save it as test.png in the same folder + +from g4f.client import Client +from g4f.Provider import Reka + +client = Client( + provider = Reka # Optional if you set model name to reka-core +) + +completion = client.chat.completions.create( + model = "reka-core", + messages = [ + { + "role": "user", + "content": "What can you see in the image ?" + } + ], + stream = True, + image = open("docs/images/cat.jpeg", "rb") # open("path", "rb"), do not use .read(), etc. it must be a file object +) + +for message in completion: + print(message.choices[0].delta.content or "") + + # >>> In the image there is ... -- cgit v1.2.3