Here's how you can chat with gpt4o.
from gradio_client import Client

# Initialize the client by pointing to the Gradio Space
client = Client("yuntian-deng/ChatGPT4")

# Persistent conversation history
chatbot_history = []  # Stores full chat history

def chat_with_model(inputs, top_p=1.0, temperature=1.0, chat_counter=0):
    """
    Interact with the Gradio chatbot while maintaining memory.

    Args:
        inputs (str): User input message to the chatbot.
        top_p (float): Top-p (nucleus sampling) parameter for response creativity (default = 1.0).
        temperature (float): Temperature for randomness in response (default = 1.0).
        chat_counter (int): The number of interactions so far (used internally).

    Returns:
        tuple: (response_text, new_chat_counter, updated_chatbot_history)
            - response_text (str): The assistant's most recent reply.
            - new_chat_counter (int): Updated chat count.
            - updated_chatbot_history (list): Updated conversation history.
    """
    global chatbot_history  # Modify the global chatbot history within the function

    # Call Gradio API endpoint /predict with history
    result = client.predict(
        inputs,            # User's input
        top_p,             # Sampling nucleus parameter
        temperature,       # Model sampling temperature
        chat_counter,      # Current step count of chat
        chatbot_history,   # Previous conversation history
        api_name="/predict"  # Gradio endpoint's function name
    )
    
    # Parse Gradio-provided outputs
    updated_history = result[0]  # Chat history list of tuples [(user, bot), ...]
    new_chat_counter = result[1]  # Updated chat counter
    status_code_from_server = result[2]  # Status from OpenAI's server (optional)
    response_textbox_value = result[3]  # String output of the assistant's reply

    # Update the persistent history
    chatbot_history = updated_history

    # Extract the latest assistant response from the updated chat history
    if updated_history:
        response_text = updated_history[-1][1]  # Final assistant's message
    else:
        response_text = "No response received."
    
    return response_text, new_chat_counter, updated_history


# Example interactive chat loop
if __name__ == "__main__":
    print("Starting a chat with GPT-4 on Hugging Face Spaces! Type 'exit' to end the chat.")
    
    chat_counter = 0  # Start at 0 interactions

    while True:
        user_input = input("You: ")
        if user_input.lower() in ["exit", "quit"]:
            print("Ending chat. Goodbye!")
            break

        # Call the chat function
        assistant_reply, chat_counter, chatbot_history = chat_with_model(
            inputs=user_input,
            top_p=1.0,             # Default settings; adjust for creativity!
            temperature=0.7,       # Slightly less randomness
            chat_counter=chat_counter
        )

        # Print the assistant's response
        print(f"Assistant: {assistant_reply}")

And here's how you can get google docs content from public url.
import requests

def fetch_public_google_doc(doc_id):
    # Public export URL for Google Docs
    export_url = f"https://docs.google.com/document/d/{doc_id}/export?format=txt"
    
    # Fetch the document content
    response = requests.get(export_url)
    
    # Check if the request was successful
    if response.status_code == 200:
        return response.text
    else:
        return f"Failed to fetch the document. Status code: {response.status_code}"

if __name__ == "__main__":
    # Replace with your Google Doc ID
    doc_id = "17fa1DmPUNw0ZUEf8eVJ2ZUF3trIbyi1Fi2r069SJAUU"
    
    content = fetch_public_google_doc(doc_id)
    print(content)

Mix these two codes and let user able to chat with google docs