(text, engine="text-embedding-3-small")
| 40 | return np.dot(a, b) / (np.linalg.norm(a) * np.linalg.norm(b)) |
| 41 | |
| 42 | def get_embedding(text, engine="text-embedding-3-small"): |
| 43 | client = OpenAI() |
| 44 | |
| 45 | response = client.embeddings.create( |
| 46 | input=text, |
| 47 | model=engine |
| 48 | ) |
| 49 | |
| 50 | return response.data[0].embedding |
| 51 | |
| 52 | # search through the reviews for a specific product |
| 53 | def search_docs(df, user_query, top_n=3, to_print=False): |
no outgoing calls
no test coverage detected