Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ BING_SEARCH_URL="https://api.bing.microsoft.com/v7.0/search"
# LangSmith
LANGCHAIN_TRACING_V2="true"
LANGCHAIN_API_KEY="<langchain-api-key>"

# Azure AI Foundry
AZURE_AI_FOUNDRY_PROJECT_CONNECTION_STRING="<YOUR_CONNECTION_STRING>"
28 changes: 28 additions & 0 deletions apps/1_call_azure_openai_chat/ai_foundry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from os import getenv

from azure.ai.projects import AIProjectClient
from azure.identity import DefaultAzureCredential
from dotenv import load_dotenv

if __name__ == "__main__":
# Parse .env file and set environment variables
load_dotenv(override=True)

project = AIProjectClient.from_connection_string(
conn_str=getenv("AZURE_AI_FOUNDRY_PROJECT_CONNECTION_STRING"),
credential=DefaultAzureCredential(),
)

chat = project.inference.get_chat_completions_client()
response = chat.complete(
model=getenv("AZURE_OPENAI_GPT_MODEL"),
messages=[
{
"role": "system",
"content": "You are an AI assistant",
},
{"role": "user", "content": "Hello, how are you?"},
],
)

print(response.choices[0].message.content)
38 changes: 37 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ azure-cognitiveservices-speech = "^1.40.0"
openai-whisper = "^20240930"
pymupdf = "^1.24.14"
pydantic = "^2.10.2"
azure-ai-projects = "^1.0.0b2"
azure-ai-inference = "^1.0.0b6"

[tool.poetry.group.dev.dependencies]
pre-commit = "^4.0.0"
Expand Down
Loading