Connecting Data source to Chat Completion Playground does not return results
Mohamed Hussein
650
Reputation points
Good Day,
I'm not sure if this related to Azure Open Ai or Azure Ai serach
I tried to follow steps to connect a basic arabic FAQ PDF file as a data source to gpt-4o-mini
and tried all possible search types.. vector, keyword, hybrid, etc, nothing worked
Having that said, when i used the same file at Azure Open Ai Assistants, it worked very well
File and configurations attached
import os
import base64
from openai import AzureOpenAI
endpoint = os.getenv("ENDPOINT_URL", "https://HusWABAGPTSwed.openai.azure.com/")
deployment = os.getenv("DEPLOYMENT_NAME", "gpt-4o-mini-Hajj")
search_endpoint = os.getenv("SEARCH_ENDPOINT", "https://husazaisearchhajj.search.windows.net/")
search_key = os.getenv("SEARCH_KEY", "put your Azure AI Search admin key here")
subscription_key = os.getenv("AZURE_OPENAI_API_KEY", "REPLACE_WITH_YOUR_KEY_VALUE_HERE")
# Initialize Azure OpenAI Service client with key-based authentication
client = AzureOpenAI(
azure_endpoint=endpoint,
api_key=subscription_key,
api_version="2024-05-01-preview",
)
# IMAGE_PATH = "YOUR_IMAGE_PATH"
# encoded_image = base64.b64encode(open(IMAGE_PATH, 'rb').read()).decode('ascii')
#Prepare the chat prompt
chat_prompt = [
{
"role": "system",
"content": [
{
"type": "text",
"text": "You are an AI assistant that helps people find information."
}
]
},
{
"role": "user",
"content": [
{
"type": "text",
"text": " الخصائص الحيوية"
}
]
},
{
"role": "assistant",
"content": [
{
"type": "text",
"text": "The requested information is not found in the retrieved data. Please try another query or topic."
}
]
},
{
"role": "user",
"content": [
{
"type": "text",
"text": "ماهي آلية تسجيل الخصائص الحيوية لإصدار تأشيرات العمرة إلكترونيا ؟"
}
]
},
{
"role": "assistant",
"content": [
{
"type": "text",
"text": "The requested information is not found in the retrieved data. Please try another query or topic."
}
]
},
{
"role": "user",
"content": [
{
"type": "text",
"text": " الخصائص الحيوية"
}
]
},
{
"role": "assistant",
"content": [
{
"type": "text",
"text": "The requested information is not found in the retrieved data. Please try another query or topic."
}
]
}
]
# Include speech result if speech is enabled
messages = chat_prompt
# Generate the completion
completion = client.chat.completions.create(
model=deployment,
messages=messages,
max_tokens=10599,
temperature=0.89,
top_p=0.73,
frequency_penalty=0,
presence_penalty=0,
stop=None,
stream=False,
extra_body={
"data_sources": [{
"type": "azure_search",
"parameters": {
"filter": None,
"endpoint": f"{search_endpoint}",
"index_name": "husazvectorindexhajjtwo",
"semantic_configuration": "azureml-default",
"authentication": {
"type": "api_key",
"key": f"{search_key}"
},
"embedding_dependency": {
"type": "endpoint",
"endpoint": "https://HusWABAGPTSwed.openai.azure.com/openai/deployments/text-embedding-ada-002-sweden/embeddings?api-version=2023-07-01-preview",
"authentication": {
"type": "api_key",
"key": "DpRrYpFOdNg846Vu2gOuW7h3Owu78OlYRlHFjqDgWicf3c32daJcJQQJ99AKACfhMk5XJ3w3AAABACOGUHHW"
}
},
"query_type": "vector_simple_hybrid",
"in_scope": True,
"role_information": "You are an AI assistant that helps people find information.",
"strictness": 3,
"top_n_documents": 6
}
}]
}
)
print(completion.to_json())
Sign in to answer