|
1 | 1 | import json |
2 | 2 |
|
3 | 3 | import pytest |
4 | | -import logging |
5 | 4 | import time |
6 | 5 |
|
7 | 6 | from openai.lib.streaming import AssistantEventHandler |
8 | 7 | from typing_extensions import override |
9 | 8 |
|
10 | | -logger = logging.getLogger(__name__) |
11 | | - |
12 | 9 | def run_with_assistant(assistant, client): |
13 | | - logger.info(f"using assistant: {assistant}") |
14 | | - logger.info("Uploading file:") |
| 10 | + print(f"using assistant: {assistant}") |
| 11 | + print("Uploading file:") |
15 | 12 | # Upload the file |
16 | 13 | file = client.files.create( |
17 | 14 | file=open( |
@@ -48,21 +45,21 @@ def run_with_assistant(assistant, client): |
48 | 45 | #print(file_batch.file_counts) |
49 | 46 |
|
50 | 47 |
|
51 | | - logger.info("adding vector_store id to assistant") |
| 48 | + print("adding vector_store id to assistant") |
52 | 49 | # Update Assistant |
53 | 50 | assistant = client.beta.assistants.update( |
54 | 51 | assistant.id, |
55 | 52 | tools=[{"type": "file_search"}], |
56 | 53 | tool_resources={"file_search": {"vector_store_ids": [vector_store.id]}}, |
57 | 54 | ) |
58 | | - logger.info(f"updated assistant: {assistant}") |
| 55 | + print(f"updated assistant: {assistant}") |
59 | 56 | user_message = "What are some cool math concepts behind this ML paper pdf? Explain in two sentences." |
60 | | - logger.info("creating persistent thread and message") |
| 57 | + print("creating persistent thread and message") |
61 | 58 | thread = client.beta.threads.create() |
62 | 59 | client.beta.threads.messages.create( |
63 | 60 | thread_id=thread.id, role="user", content=user_message |
64 | 61 | ) |
65 | | - logger.info(f"> {user_message}") |
| 62 | + print(f"> {user_message}") |
66 | 63 |
|
67 | 64 | class EventHandler(AssistantEventHandler): |
68 | 65 | def __init__(self): |
@@ -93,7 +90,7 @@ def on_text_delta(self, delta, snapshot): |
93 | 90 |
|
94 | 91 | event_handler = EventHandler() |
95 | 92 |
|
96 | | - logger.info(f"creating run") |
| 93 | + print(f"creating run") |
97 | 94 | with client.beta.threads.runs.create_and_stream( |
98 | 95 | thread_id=thread.id, |
99 | 96 | assistant_id=assistant.id, |
|
0 commit comments