# Persist Chat History for Gradio APIand continue chatting

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fpersist-chat-history-for-gradio-apiand-continue-chatting%2F144034%3E%5C
**Category:** Models\
**Created:** [March 4, 2025, 4:00pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fpersist-chat-history-for-gradio-apiand-continue-chatting%2F144034 "2025-03-04T16:00:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![xetaverse](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/xetaverse/32/42331_2.png) [@xetaverse](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fxetaverse)%5C
**Post date:** [March 4, 2025, 4:00pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fpersist-chat-history-for-gradio-apiand-continue-chatting%2F144034%2F1 "2025-03-04T16:00:30Z")

</div>

I am interacting with the Gradio API using a chatbot, but I want to continue the chat on another device like chatgpt history where it continues the chatting. How can I achieve this?

```auto
const [chatHistory, setChatHistory] = useState([]);
  const [isLoading, setIsLoading] = useState(false);
  const [input, setInput] = useState("");
  const [previewMessage, setPreviewMessage] = useState("");
  const [clientt, setClientt] = useState(null);

  useEffect(() => {
    (async () => {
      const cli = await Client.connect("Qwen/Qwen2.5-VL-72B-Instruct");
      setClientt(cli);
    })();
  }, []);

  useEffect(() => {
    console.log('History:', JSON.stringify(chatHistory));
  }, [chatHistory])
  const sendMessage = async () => {
    if (!input.trim()) return;

    const newMessage = input;
    setInput('');
    setIsLoading(true);

    try {
      const a = await clientt.predict(
        "/add_text", {
        history: chatHistory,
        text: newMessage,
      });

      await clientt.predict(
        "/reset_user_input",
      );
      const data = await clientt.predict(
        "/predict", {
        _chatbot: [[newMessage, "null"]],
      });

      // console.log(JSON.stringify(data.data[0][0]));

      let botResponse = data.data[0][0] || "I couldn't understand that.";
      setChatHistory(prev => [...prev, botResponse]);
      // console.log('resp: ', JSON.stringify(data.data));
    } catch (error) {
      console.error("Error communicating with the model:", error);
      setChatHistory((prev) => [
        ...prev,
        [newMessage, "Sorry, there was an error processing your request."],
      ]);
    } finally {
      setIsLoading(false);
    }
  };

```

I have checked this discussion:  
[/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fimplementing-chatbot-history-like-chatgpt-on-gradio-gr-chatinterface%2F52186%5D(https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fimplementing-chatbot-history-like-chatgpt-on-gradio-gr-chatinterface%2F52186)

No, thats not the solution. It just stores the chat but i want to make model continue chat on other device on previous topic. How can i achieve that?

\*clientt is not typo
