summaryrefslogtreecommitdiffstats
path: root/etc/examples/image_chat_reka.py
diff options
context:
space:
mode:
authorEien Mojiki 🍕 <95165750+eienmojiki206@users.noreply.github.com>2024-04-25 06:31:01 +0200
committerGitHub <noreply@github.com>2024-04-25 06:31:01 +0200
commitf0cf7a2dae4747e3d3debfa64ebd9a874c25dc4a (patch)
tree64db4af058f3f3a2364216cbade5762791c5e370 /etc/examples/image_chat_reka.py
parentAdd `microsoft/Phi-3-mini-4k-instruct` model (diff)
parentUpdate README.md (diff)
downloadgpt4free-f0cf7a2dae4747e3d3debfa64ebd9a874c25dc4a.tar
gpt4free-f0cf7a2dae4747e3d3debfa64ebd9a874c25dc4a.tar.gz
gpt4free-f0cf7a2dae4747e3d3debfa64ebd9a874c25dc4a.tar.bz2
gpt4free-f0cf7a2dae4747e3d3debfa64ebd9a874c25dc4a.tar.lz
gpt4free-f0cf7a2dae4747e3d3debfa64ebd9a874c25dc4a.tar.xz
gpt4free-f0cf7a2dae4747e3d3debfa64ebd9a874c25dc4a.tar.zst
gpt4free-f0cf7a2dae4747e3d3debfa64ebd9a874c25dc4a.zip
Diffstat (limited to 'etc/examples/image_chat_reka.py')
-rw-r--r--etc/examples/image_chat_reka.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/etc/examples/image_chat_reka.py b/etc/examples/image_chat_reka.py
new file mode 100644
index 00000000..954960db
--- /dev/null
+++ b/etc/examples/image_chat_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("test.png", "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 ... \ No newline at end of file