Skip to content

Commit 941b512

Browse files
committed
Remove openai assistant id, simplify code by removing typing
1 parent 77a9a53 commit 941b512

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

sources/platform/integrations/ai/openai_assistants.md

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,10 @@ Import all required packages:
3939

4040
import json
4141
import time
42-
from typing import TYPE_CHECKING
4342

4443
from apify_client import ApifyClient
4544
from openai import OpenAI, Stream
4645
from openai.types.beta.threads.run_submit_tool_outputs_params import ToolOutput
47-
48-
if TYPE_CHECKING:
49-
from openai.types.beta import AssistantStreamEvent
50-
from openai.types.beta.threads import Run
5146
```
5247

5348
Find your [Apify API token](https://console.apify.com/account/integrations) and [OpenAI API key](https://platform.openai.com/account/api-keys) and initialize OpenAI and Apify clients:
@@ -134,7 +129,7 @@ This function will trigger the RAG-Web-Browser to fetch the search data and subm
134129
Let's implement the `submit_tool_outputs` function:
135130

136131
```python
137-
def submit_tool_outputs(run_: Run) -> Run | Stream[AssistantStreamEvent]:
132+
def submit_tool_outputs(run_):
138133
""" Submit tool outputs to continue the run """
139134
tool_output = []
140135
for tool in run_.required_action.submit_tool_outputs.tool_calls:
@@ -178,15 +173,11 @@ The latest news on LLM is as follows:
178173

179174
```python
180175
import json
181-
from typing import TYPE_CHECKING
182176

183177
from apify_client import ApifyClient
184178
from openai import OpenAI, Stream
185179
from openai.types.beta.threads.run_submit_tool_outputs_params import ToolOutput
186180

187-
if TYPE_CHECKING:
188-
from openai.types.beta import AssistantStreamEvent
189-
from openai.types.beta.threads import Run
190181

191182
client = OpenAI(api_key="YOUR-OPENAI-API-KEY")
192183
apify_client = ApifyClient("YOUR-APIFY-API-TOKEN")
@@ -215,8 +206,6 @@ rag_web_browser_function = {
215206
}
216207
}
217208

218-
my_assistant = client.beta.assistants.retrieve("asst_7GXx3q9lWLmhSf9yexA7J1WX")
219-
220209

221210
def call_rag_web_browser(query: str, max_results: int) -> list[dict]:
222211
"""
@@ -227,7 +216,7 @@ def call_rag_web_browser(query: str, max_results: int) -> list[dict]:
227216
return apify_client.dataset(actor_call["defaultDatasetId"]).list_items().items
228217

229218

230-
def submit_tool_outputs(run_: Run) -> Run | Stream[AssistantStreamEvent]:
219+
def submit_tool_outputs(run_):
231220
""" Submit tool outputs to continue the run """
232221
tool_output = []
233222
for tool in run_.required_action.submit_tool_outputs.tool_calls:

0 commit comments

Comments
 (0)