Skip to content

Commit 7fc3c5d

Browse files
authored
Merge pull request #192 from ks6088ts-labs/feature/issue-191_ai-foundry
use ai foundry sdk
2 parents b09cfaa + b951ea3 commit 7fc3c5d

File tree

4 files changed

+70
-1
lines changed

4 files changed

+70
-1
lines changed

.env.template

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,6 @@ BING_SEARCH_URL="https://api.bing.microsoft.com/v7.0/search"
4040
# LangSmith
4141
LANGCHAIN_TRACING_V2="true"
4242
LANGCHAIN_API_KEY="<langchain-api-key>"
43+
44+
# Azure AI Foundry
45+
AZURE_AI_FOUNDRY_PROJECT_CONNECTION_STRING="<YOUR_CONNECTION_STRING>"
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from os import getenv
2+
3+
from azure.ai.projects import AIProjectClient
4+
from azure.identity import DefaultAzureCredential
5+
from dotenv import load_dotenv
6+
7+
if __name__ == "__main__":
8+
# Parse .env file and set environment variables
9+
load_dotenv(override=True)
10+
11+
project = AIProjectClient.from_connection_string(
12+
conn_str=getenv("AZURE_AI_FOUNDRY_PROJECT_CONNECTION_STRING"),
13+
credential=DefaultAzureCredential(),
14+
)
15+
16+
chat = project.inference.get_chat_completions_client()
17+
response = chat.complete(
18+
model=getenv("AZURE_OPENAI_GPT_MODEL"),
19+
messages=[
20+
{
21+
"role": "system",
22+
"content": "You are an AI assistant",
23+
},
24+
{"role": "user", "content": "Hello, how are you?"},
25+
],
26+
)
27+
28+
print(response.choices[0].message.content)

poetry.lock

Lines changed: 37 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ azure-cognitiveservices-speech = "^1.40.0"
4141
openai-whisper = "^20240930"
4242
pymupdf = "^1.24.14"
4343
pydantic = "^2.10.2"
44+
azure-ai-projects = "^1.0.0b2"
45+
azure-ai-inference = "^1.0.0b6"
4446

4547
[tool.poetry.group.dev.dependencies]
4648
pre-commit = "^4.0.0"

0 commit comments

Comments
 (0)