|
@@ -0,0 +1,24 @@
|
|
|
+# -*- coding: utf-8 -*-
|
|
|
+"""
|
|
|
+@author: yq
|
|
|
+@time: 2025/1/14
|
|
|
+@desc:
|
|
|
+"""
|
|
|
+
|
|
|
+from cozepy import Coze, Stream, WorkflowEvent, WorkflowEventType, COZE_CN_BASE_URL
|
|
|
+from cozepy.auth import TokenAuth
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+coze = Coze(auth=TokenAuth("pat_NoyDg48ZoXd4swDSXeDXLrHaQR73G9Ygr8qjxxvRfvyITwIwL7dQUjqfgcL8hL6j"), base_url=COZE_CN_BASE_URL)
|
|
|
+stream: Stream[WorkflowEvent] = coze.workflows.runs.stream(
|
|
|
+ workflow_id='7483418763824693287', parameters={"query": "北京小米"})
|
|
|
+for event in stream:
|
|
|
+ if event.event == WorkflowEventType.MESSAGE:
|
|
|
+ print(event.message)
|
|
|
+ elif event.event == WorkflowEventType.ERROR:
|
|
|
+ print(event.error)
|
|
|
+
|
|
|
+
|
|
|
+if __name__ == "__main__":
|
|
|
+ pass
|