You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
swarms/docs/examples/bingchat.md

1.8 KiB

BingChat User Guide

Welcome to the BingChat user guide! This document provides a step-by-step tutorial on how to leverage the BingChat class, an interface to the EdgeGPT model by OpenAI.

Table of Contents

  1. Installation & Prerequisites
  2. Setting Up BingChat
  3. Interacting with BingChat
  4. Generating Images
  5. Managing Cookies

Installation & Prerequisites

Before initializing the BingChat model, ensure you have the necessary dependencies installed:

pip install EdgeGPT

Additionally, you must have a cookies.json file which is necessary for authenticating with EdgeGPT.

Setting Up BingChat

To start, import the BingChat class:

from bing_chat import BingChat

Initialize BingChat with the path to your cookies.json:

chat = BingChat(cookies_path="./path/to/cookies.json")

Interacting with BingChat

You can obtain text responses from the EdgeGPT model by simply calling the instantiated object:

response = chat("Hello, my name is ChatGPT")
print(response)

You can also specify the conversation style:

from bing_chat import ConversationStyle
response = chat("Tell me a joke", style=ConversationStyle.creative)
print(response)

Generating Images

BingChat allows you to generate images based on text prompts:

image_path = chat.create_img("Sunset over mountains", auth_cookie="YOUR_AUTH_COOKIE")
print(f"Image saved at: {image_path}")

Ensure you provide the required auth_cookie for image generation.

Managing Cookies

You can set a directory path for managing cookies using the set_cookie_dir_path method:

BingChat.set_cookie_dir_path("./path/to/cookies_directory")