♻️ Reproduction Steps
I have a LangGraph node with the following code
async def exercise_request(
state: State, config: RunnableConfig
):
state['exercise_is_generating'] = True
await copilotkit_emit_state(config, state)
exercise_type = _get_exercise_type(state)
topic = _get_topic(state)
prompt = PROMPT.format(topic=topic)
response = await _generate_task(prompt, config)
ids = state.get("exercise_messages_ids", [])
ids.append(response.id)
state["exercise_messages_ids"] = ids
state["requested_exercise"] = ""
state["messages"].append(response)
state['exercise_is_generating'] = False
return state
async def _generate_task(prompt: str, config: RunnableConfig) -> str:
gpt4o_mini = "gpt-4o-mini"
temperature = 0.3
model = ChatOpenAI(
model=gpt4o_mini, temperature=temperature)
response = await model.ainvoke(prompt, config=config)
return response
When the node execution starts I set exercise_is_generating in state to True and set it to False at the end function.
On the UI I use hook to read the state.
const { state } = useCoAgent<AgentState>({
name: "language_agent",
initialState: {
language: language,
level: level,
conversation_language: conversationLanguage,
predefined_topics: topics,
exercise_is_generating: false
},
});
exercise_is_generating has a true value once the state is emitted with copilotkit_emit_state. But it is immediately has false after. It has already a false value before a new message is streaming (see _generate_task function).
What is the right way to emit the state in such case? Thank you!
CoAgents is the best thing I found out recently. Awesome work!
✅ Expected Behavior
❌ Actual Behavior
𝌚 CopilotKit Version
📄 Logs (Optional)
No response
♻️ Reproduction Steps
I have a LangGraph node with the following code
When the node execution starts I set
exercise_is_generatingin state toTrueand set it toFalseat the end function.On the UI I use hook to read the state.
exercise_is_generatinghas atruevalue once the state is emitted withcopilotkit_emit_state. But it is immediately hasfalseafter. It has already afalsevalue before a new message is streaming (see_generate_taskfunction).What is the right way to emit the state in such case? Thank you!
CoAgents is the best thing I found out recently. Awesome work!
✅ Expected Behavior
❌ Actual Behavior
𝌚 CopilotKit Version
📄 Logs (Optional)
No response