Skip to content

Commit 5f11308

Browse files
committed
update code
1 parent da0eb6b commit 5f11308

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

articles/ai-services/openai/tutorials/embeddings.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,16 +369,17 @@ df_bills['ada_v2'] = df_bills["text"].apply(lambda x : get_embedding(x, engine =
369369

370370
# [OpenAI Python 1.x](#tab/python-new)
371371

372+
```python
372373
client = AzureOpenAI(
373374
api_key = os.getenv("AZURE_OPENAI_API_KEY"),
374375
api_version = "2023-05-15",
375376
azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT")
376377
)
377378

378-
def generate_embeddings(text, model="text-embedding-ada-002"):
379+
def generate_embeddings(text, model="text-embedding-ada-002"): # model = "deployment_name"
379380
return client.embeddings.create(input = [text], model=model).data[0].embedding
380381

381-
df_bills['ada_v2'] = df_bills["text"].apply(lambda x : generate_embeddings (x, model = 'text-embedding-ada-002')) # engine should be set to the deployment name you chose when you deployed the text-embedding-ada-002 (Version 2) model
382+
df_bills['ada_v2'] = df_bills["text"].apply(lambda x : generate_embeddings (x, model = 'text-embedding-ada-002')) # model should be set to the deployment name you chose when you deployed the text-embedding-ada-002 (Version 2) model
382383

383384
---
384385

@@ -421,7 +422,7 @@ res = search_docs(df_bills, "Can I get information on cable company tax revenue?
421422
def cosine_similarity(a, b):
422423
return np.dot(a, b) / (np.linalg.norm(a) * np.linalg.norm(b))
423424

424-
def get_embedding(text, model="text-embedding-ada-002"):
425+
def get_embedding(text, model="text-embedding-ada-002"): # model = "deployment_name"
425426
return client.embeddings.create(input = [text], model=model).data[0].embedding
426427

427428
def search_docs(df, user_query, top_n=3, to_print=True):

0 commit comments

Comments
 (0)