|
5 | 5 |
|
6 | 6 | questions = client.collections.get("Question") |
7 | 7 |
|
| 8 | +print("=== DEBUG: Getting collection configuration ===") |
| 9 | +config = questions.config.get() |
| 10 | +print(f"DEBUG: Collection config type: {type(config)}") |
| 11 | +print(f"DEBUG: Collection config: {config}") |
| 12 | + |
| 13 | +# Print vector configuration |
| 14 | +if hasattr(config, "vector_config"): |
| 15 | + print(f"DEBUG: Vector config: {config.vector_config}") |
| 16 | + if hasattr(config.vector_config, "vectorizer"): |
| 17 | + print(f"DEBUG: Vectorizer: {config.vector_config.vectorizer}") |
| 18 | + if hasattr(config.vector_config.vectorizer, "config"): |
| 19 | + print(f"DEBUG: Vectorizer config: {config.vector_config.vectorizer.config}") |
| 20 | + |
| 21 | +# Print generative configuration |
| 22 | +if hasattr(config, "generative_config"): |
| 23 | + print(f"DEBUG: Generative config: {config.generative_config}") |
| 24 | + if hasattr(config.generative_config, "generative"): |
| 25 | + print(f"DEBUG: Generative: {config.generative_config.generative}") |
| 26 | + if hasattr(config.generative_config.generative, "config"): |
| 27 | + print( |
| 28 | + f"DEBUG: Generative config: {config.generative_config.generative.config}" |
| 29 | + ) |
| 30 | + |
| 31 | +print("=== DEBUG: Starting RAG query ===") |
| 32 | + |
8 | 33 | # highlight-start |
9 | 34 | response = questions.generate.near_text( |
10 | 35 | query="biology", |
11 | 36 | limit=2, |
12 | | - grouped_task="Write a tweet with emojis about these facts." |
| 37 | + grouped_task="Write a tweet with emojis about these facts.", |
13 | 38 | ) |
14 | 39 | # highlight-end |
15 | 40 |
|
16 | | -print(response.generative.text) # Inspect the generated text |
| 41 | +print(f"DEBUG: Response type: {type(response)}") |
| 42 | +print(f"DEBUG: Response object: {response}") |
| 43 | +print( |
| 44 | + f"DEBUG: Response attributes: {[attr for attr in dir(response) if not attr.startswith('_')]}" |
| 45 | +) |
| 46 | + |
| 47 | +# Check if response has generative attribute |
| 48 | +if hasattr(response, "generative"): |
| 49 | + print(f"DEBUG: response.generative type: {type(response.generative)}") |
| 50 | + print(f"DEBUG: response.generative value: {response.generative}") |
| 51 | + |
| 52 | + if response.generative is not None: |
| 53 | + print( |
| 54 | + f"DEBUG: generative attributes: {[attr for attr in dir(response.generative) if not attr.startswith('_')]}" |
| 55 | + ) |
| 56 | + |
| 57 | + if hasattr(response.generative, "text"): |
| 58 | + print(f"DEBUG: Generated text exists: {response.generative.text}") |
| 59 | + else: |
| 60 | + print("DEBUG: ERROR - response.generative has no 'text' attribute") |
| 61 | + else: |
| 62 | + print("DEBUG: ERROR - response.generative is None") |
| 63 | +else: |
| 64 | + print("DEBUG: ERROR - response has no 'generative' attribute") |
| 65 | + |
| 66 | +# Check if there are search results |
| 67 | +if hasattr(response, "objects"): |
| 68 | + print(f"DEBUG: Number of objects found: {len(response.objects)}") |
| 69 | + for i, obj in enumerate(response.objects): |
| 70 | + print(f"DEBUG: Object {i+1}: {obj.properties}") |
| 71 | +else: |
| 72 | + print("DEBUG: No objects found in response") |
| 73 | + |
| 74 | +# Only print the text if it exists |
| 75 | +if ( |
| 76 | + hasattr(response, "generative") |
| 77 | + and response.generative is not None |
| 78 | + and hasattr(response.generative, "text") |
| 79 | +): |
| 80 | + print(response.generative.text) # Inspect the generated text |
| 81 | +else: |
| 82 | + print("ERROR: Cannot access response.generative.text - it's None or doesn't exist") |
17 | 83 |
|
18 | 84 | client.close() # Free up resources |
19 | 85 | # END RAG |
0 commit comments