image_chat_reka.py 732 B

123456789101112131415161718192021222324252627
  1. # Image Chat with Reca
  2. # !! YOU NEED COOKIES / BE LOGGED IN TO chat.reka.ai
  3. # download an image and save it as test.png in the same folder
  4. from g4f.client import Client
  5. from g4f.Provider import Reka
  6. client = Client(
  7. provider = Reka # Optional if you set model name to reka-core
  8. )
  9. completion = client.chat.completions.create(
  10. model = "reka-core",
  11. messages = [
  12. {
  13. "role": "user",
  14. "content": "What can you see in the image ?"
  15. }
  16. ],
  17. stream = True,
  18. image = open("test.png", "rb") # open("path", "rb"), do not use .read(), etc. it must be a file object
  19. )
  20. for message in completion:
  21. print(message.choices[0].delta.content or "")
  22. # >>> In the image there is ...