├── .editorconfig
├── .github
└── ISSUE_TEMPLATE
│ ├── func-ai-bugs-report.yml
│ └── func-ai-feature-report.yml
├── .gitignore
├── .vscode
└── extensions.json
├── CHANGELOG.md
├── CODEOWNERS
├── CODE_OF_CONDUCT.md
├── LICENSE
├── OpenAI-Extension.sln
├── README.md
├── SECURITY.md
├── SUPPORT.md
├── eng
├── cd
│ ├── official-release.yml
│ └── templates
│ │ ├── javapublish.yml
│ │ ├── nugetpublish.yml
│ │ └── release-variables.yml
└── ci
│ ├── code-mirror.yml
│ ├── integration-tests.yml
│ ├── official-build.yml
│ ├── public-build-java.yml
│ ├── public-build.yml
│ └── templates
│ ├── build-java-library.yml
│ ├── build-java-samples.yml
│ ├── build-local.yml
│ ├── build-nuget.yml
│ ├── build-variables.yml
│ └── run-integration-tests.yml
├── env
├── .gitignore
├── README.md
└── dotenvtoenvars.ps1
├── java-library
├── CHANGELOG.md
├── README.md
├── pom.xml
└── src
│ └── main
│ └── java
│ └── com
│ └── microsoft
│ └── azure
│ └── functions
│ └── openai
│ ├── annotation
│ ├── assistant
│ │ ├── AssistantCreate.java
│ │ ├── AssistantCreateRequest.java
│ │ ├── AssistantMessage.java
│ │ ├── AssistantPost.java
│ │ ├── AssistantQuery.java
│ │ ├── AssistantSkillTrigger.java
│ │ └── AssistantState.java
│ ├── embeddings
│ │ ├── EmbeddingsContext.java
│ │ ├── EmbeddingsInput.java
│ │ ├── EmbeddingsStoreOutput.java
│ │ └── InputType.java
│ ├── search
│ │ ├── ConnectionInfo.java
│ │ ├── SearchableDocument.java
│ │ ├── SemanticSearch.java
│ │ └── SemanticSearchContext.java
│ └── textcompletion
│ │ ├── TextCompletion.java
│ │ └── TextCompletionResponse.java
│ └── constants
│ └── ModelDefaults.java
├── nuget.config
├── samples
├── Directory.Build.props
├── assistant
│ ├── README.md
│ ├── csharp-legacy
│ │ ├── AssistantApis.cs
│ │ ├── AssistantSample.csproj
│ │ ├── AssistantSkills.cs
│ │ ├── Properties
│ │ │ └── launchSettings.json
│ │ ├── Startup.cs
│ │ ├── TodoManager.cs
│ │ ├── host.json
│ │ └── local.settings.json
│ ├── csharp-ooproc
│ │ ├── AssistantApis.cs
│ │ ├── AssistantSample.csproj
│ │ ├── AssistantSkills.cs
│ │ ├── Dockerfile
│ │ ├── Program.cs
│ │ ├── TodoManager.cs
│ │ ├── host.json
│ │ └── local.settings.json
│ ├── demo.http
│ ├── java
│ │ ├── .funcignore
│ │ ├── extensions.csproj
│ │ ├── host.json
│ │ ├── local.settings.json
│ │ ├── pom.xml
│ │ └── src
│ │ │ └── main
│ │ │ └── java
│ │ │ └── com
│ │ │ └── azfs
│ │ │ ├── AssistantApis.java
│ │ │ ├── AssistantSkills.java
│ │ │ └── TodoManager.java
│ ├── javascript
│ │ ├── .funcignore
│ │ ├── host.json
│ │ ├── local.settings.json
│ │ ├── package-lock.json
│ │ ├── package.json
│ │ └── src
│ │ │ ├── functions
│ │ │ ├── assistantApis.js
│ │ │ └── assistantSkills.js
│ │ │ └── services
│ │ │ └── todoManager.js
│ ├── powershell
│ │ ├── .funcignore
│ │ ├── AddTodo
│ │ │ ├── function.json
│ │ │ └── run.ps1
│ │ ├── CreateAssistant
│ │ │ ├── function.json
│ │ │ └── run.ps1
│ │ ├── GetChatState
│ │ │ ├── function.json
│ │ │ └── run.ps1
│ │ ├── GetTodos
│ │ │ ├── function.json
│ │ │ └── run.ps1
│ │ ├── PostUserQuery
│ │ │ ├── function.json
│ │ │ └── run.ps1
│ │ ├── TodoManager
│ │ │ └── TodoManager.ps1
│ │ ├── host.json
│ │ ├── local.settings.json
│ │ ├── profile.ps1
│ │ └── requirements.psd1
│ ├── python
│ │ ├── .funcignore
│ │ ├── assistant_apis.py
│ │ ├── assistant_skills.py
│ │ ├── function_app.py
│ │ ├── host.json
│ │ ├── local.settings.json
│ │ ├── requirements.txt
│ │ └── todo_manager.py
│ └── typescript
│ │ ├── .funcignore
│ │ ├── host.json
│ │ ├── local.settings.json
│ │ ├── package-lock.json
│ │ ├── package.json
│ │ ├── src
│ │ ├── functions
│ │ │ ├── assistantApis.ts
│ │ │ └── assistantSkills.ts
│ │ └── services
│ │ │ └── todoManager.ts
│ │ └── tsconfig.json
├── chat
│ ├── README.md
│ ├── csharp-legacy
│ │ ├── ChatBot.cs
│ │ ├── ChatBotSample.csproj
│ │ ├── Dockerfile
│ │ ├── host.json
│ │ └── local.settings.json
│ ├── csharp-ooproc
│ │ ├── ChatBot.cs
│ │ ├── ChatBot.csproj
│ │ ├── Dockerfile
│ │ ├── Program.cs
│ │ ├── host.json
│ │ └── local.settings.json
│ ├── demo.http
│ ├── java
│ │ ├── .funcignore
│ │ ├── extensions.csproj
│ │ ├── host.json
│ │ ├── local.settings.json
│ │ ├── pom.xml
│ │ └── src
│ │ │ └── main
│ │ │ └── java
│ │ │ └── com
│ │ │ └── azfs
│ │ │ └── ChatBot.java
│ ├── javascript
│ │ ├── .funcignore
│ │ ├── host.json
│ │ ├── local.settings.json
│ │ ├── package-lock.json
│ │ ├── package.json
│ │ └── src
│ │ │ └── app.js
│ ├── powershell
│ │ ├── .funcignore
│ │ ├── .gitignore
│ │ ├── CreateChatBot
│ │ │ ├── function.json
│ │ │ └── run.ps1
│ │ ├── GetChatState
│ │ │ ├── function.json
│ │ │ └── run.ps1
│ │ ├── PostUserResponse
│ │ │ ├── function.json
│ │ │ └── run.ps1
│ │ ├── extensions.csproj
│ │ ├── host.json
│ │ ├── local.settings.json
│ │ ├── profile.ps1
│ │ └── requirements.psd1
│ ├── python
│ │ ├── .funcignore
│ │ ├── function_app.py
│ │ ├── host.json
│ │ ├── local.settings.json
│ │ └── requirements.txt
│ └── typescript
│ │ ├── .funcignore
│ │ ├── host.json
│ │ ├── local.settings.json
│ │ ├── package-lock.json
│ │ ├── package.json
│ │ ├── src
│ │ └── functions
│ │ │ └── app.ts
│ │ └── tsconfig.json
├── embeddings
│ ├── README.md
│ ├── csharp-legacy
│ │ ├── EmbeddingsLegacy.cs
│ │ ├── EmbeddingsLegacy.csproj
│ │ ├── host.json
│ │ └── local.settings.json
│ ├── csharp-ooproc
│ │ └── Embeddings
│ │ │ ├── Embeddings.csproj
│ │ │ ├── EmbeddingsGenerator.cs
│ │ │ ├── Program.cs
│ │ │ ├── Properties
│ │ │ ├── launchSettings.json
│ │ │ ├── serviceDependencies.json
│ │ │ └── serviceDependencies.local.json
│ │ │ ├── host.json
│ │ │ └── local.settings.json
│ ├── demo.http
│ ├── java
│ │ ├── .funcignore
│ │ ├── extensions.csproj
│ │ ├── host.json
│ │ ├── local.settings.json
│ │ ├── pom.xml
│ │ └── src
│ │ │ └── main
│ │ │ └── java
│ │ │ └── com
│ │ │ └── azfs
│ │ │ └── EmbeddingsGenerator.java
│ ├── javascript
│ │ ├── .funcignore
│ │ ├── host.json
│ │ ├── local.settings.json
│ │ ├── package-lock.json
│ │ ├── package.json
│ │ └── src
│ │ │ └── app.js
│ ├── powershell
│ │ ├── .funcignore
│ │ ├── GenerateEmbeddings
│ │ │ ├── function.json
│ │ │ └── run.ps1
│ │ ├── GetEmbeddingsFilePath
│ │ │ ├── function.json
│ │ │ └── run.ps1
│ │ ├── GetEmbeddingsURL
│ │ │ ├── function.json
│ │ │ └── run.ps1
│ │ ├── extensions.csproj
│ │ ├── host.json
│ │ ├── local.settings.json
│ │ ├── profile.ps1
│ │ └── requirements.psd1
│ ├── python
│ │ ├── .funcignore
│ │ ├── function_app.py
│ │ ├── host.json
│ │ ├── local.settings.json
│ │ └── requirements.txt
│ └── typescript
│ │ ├── .funcignore
│ │ ├── host.json
│ │ ├── local.settings.json
│ │ ├── package-lock.json
│ │ ├── package.json
│ │ ├── src
│ │ └── app.ts
│ │ └── tsconfig.json
├── rag-aisearch
│ ├── README.md
│ ├── csharp-legacy
│ │ ├── FilePrompt.cs
│ │ ├── SemanticAISearchEmbeddingsLegacy.csproj
│ │ ├── host.json
│ │ └── local.settings.json
│ ├── csharp-ooproc
│ │ ├── FilePrompt.cs
│ │ ├── Program.cs
│ │ ├── SemanticAISearchEmbeddings.csproj
│ │ ├── host.json
│ │ └── local.settings.json
│ ├── demo.http
│ ├── java
│ │ ├── .funcignore
│ │ ├── extensions.csproj
│ │ ├── host.json
│ │ ├── local.settings.json
│ │ ├── pom.xml
│ │ └── src
│ │ │ └── main
│ │ │ └── java
│ │ │ └── com
│ │ │ └── azfs
│ │ │ └── FilePrompt.java
│ ├── javascript
│ │ ├── .funcignore
│ │ ├── host.json
│ │ ├── local.settings.json
│ │ ├── package-lock.json
│ │ ├── package.json
│ │ └── src
│ │ │ └── app.js
│ ├── powershell
│ │ ├── .funcignore
│ │ ├── IngestFile
│ │ │ ├── function.json
│ │ │ └── run.ps1
│ │ ├── PromptFile
│ │ │ ├── function.json
│ │ │ └── run.ps1
│ │ ├── extensions.csproj
│ │ ├── host.json
│ │ ├── local.settings.json
│ │ ├── profile.ps1
│ │ └── requirements.psd1
│ ├── python
│ │ ├── .funcignore
│ │ ├── function_app.py
│ │ ├── host.json
│ │ ├── local.settings.json
│ │ └── requirements.txt
│ └── typescript
│ │ ├── .funcignore
│ │ ├── host.json
│ │ ├── local.settings.json
│ │ ├── package-lock.json
│ │ ├── package.json
│ │ ├── src
│ │ └── app.ts
│ │ └── tsconfig.json
├── rag-cosmosdb-nosql
│ ├── README.md
│ ├── csharp-legacy
│ │ ├── CosmosDBNoSQLSearchLegacy.csproj
│ │ ├── FilePrompt.cs
│ │ ├── host.json
│ │ └── local.settings.json
│ ├── csharp-ooproc
│ │ ├── CosmosDBNoSqlSearch.csproj
│ │ ├── FilePrompt.cs
│ │ ├── Program.cs
│ │ ├── host.json
│ │ └── local.settings.json
│ ├── demo.http
│ ├── java
│ │ ├── .funcignore
│ │ ├── extensions.csproj
│ │ ├── host.json
│ │ ├── local.settings.json
│ │ ├── pom.xml
│ │ └── src
│ │ │ └── main
│ │ │ └── java
│ │ │ └── com
│ │ │ └── azfs
│ │ │ └── FilePrompt.java
│ ├── javascript
│ │ ├── .funcignore
│ │ ├── extensions.csproj
│ │ ├── host.json
│ │ ├── local.settings.json
│ │ ├── package-lock.json
│ │ ├── package.json
│ │ └── src
│ │ │ └── app.js
│ ├── powershell
│ │ ├── .funcignore
│ │ ├── IngestFile
│ │ │ ├── function.json
│ │ │ └── run.ps1
│ │ ├── PromptFile
│ │ │ ├── function.json
│ │ │ └── run.ps1
│ │ ├── extensions.csproj
│ │ ├── host.json
│ │ ├── local.settings.json
│ │ ├── profile.ps1
│ │ └── requirements.psd1
│ ├── python
│ │ ├── extensions.csproj
│ │ ├── function_app.py
│ │ ├── host.json
│ │ ├── local.settings.json
│ │ └── requirements.txt
│ └── typescript
│ │ ├── .funcignore
│ │ ├── extensions.csproj
│ │ ├── host.json
│ │ ├── local.settings.json
│ │ ├── package-lock.json
│ │ ├── package.json
│ │ ├── src
│ │ └── app.ts
│ │ └── tsconfig.json
├── rag-cosmosdb
│ ├── README.md
│ ├── csharp-legacy
│ │ ├── CosmosDBSearchLegacy.csproj
│ │ ├── FilePrompt.cs
│ │ ├── host.json
│ │ └── local.settings.json
│ ├── csharp-ooproc
│ │ ├── FilePrompt.cs
│ │ ├── Program.cs
│ │ ├── SemanticCosmosDBSearchEmbeddings.csproj
│ │ ├── host.json
│ │ └── local.settings.json
│ ├── demo.http
│ ├── java
│ │ ├── .funcignore
│ │ ├── extensions.csproj
│ │ ├── host.json
│ │ ├── local.settings.json
│ │ ├── pom.xml
│ │ └── src
│ │ │ └── main
│ │ │ └── java
│ │ │ └── com
│ │ │ └── azfs
│ │ │ └── FilePrompt.java
│ ├── javascript
│ │ ├── .funcignore
│ │ ├── host.json
│ │ ├── local.settings.json
│ │ ├── package-lock.json
│ │ ├── package.json
│ │ └── src
│ │ │ └── app.js
│ ├── powershell
│ │ ├── .funcignore
│ │ ├── IngestFile
│ │ │ ├── function.json
│ │ │ └── run.ps1
│ │ ├── PromptFile
│ │ │ ├── function.json
│ │ │ └── run.ps1
│ │ ├── extensions.csproj
│ │ ├── host.json
│ │ ├── local.settings.json
│ │ ├── profile.ps1
│ │ └── requirements.psd1
│ ├── python
│ │ ├── .funcignore
│ │ ├── extensions.csproj
│ │ ├── function_app.py
│ │ ├── host.json
│ │ ├── local.settings.json
│ │ └── requirements.txt
│ └── typescript
│ │ ├── .funcignore
│ │ ├── host.json
│ │ ├── local.settings.json
│ │ ├── package-lock.json
│ │ ├── package.json
│ │ ├── src
│ │ └── app.ts
│ │ └── tsconfig.json
├── rag-kusto
│ ├── README.md
│ ├── csharp-legacy
│ │ ├── FilePrompt.cs
│ │ ├── KustoSearchLegacy.csproj
│ │ ├── host.json
│ │ └── local.settings.json
│ ├── csharp-ooproc
│ │ ├── EmailPromptDemo.cs
│ │ ├── Program.cs
│ │ ├── Properties
│ │ │ └── launchSettings.json
│ │ ├── SemanticSearchEmbeddings.csproj
│ │ ├── host.json
│ │ └── local.settings.json
│ ├── demo.http
│ ├── java
│ │ ├── .funcignore
│ │ ├── extensions.csproj
│ │ ├── host.json
│ │ ├── local.settings.json
│ │ ├── pom.xml
│ │ └── src
│ │ │ └── main
│ │ │ └── java
│ │ │ └── com
│ │ │ └── azfs
│ │ │ └── EmailPromptDemo.java
│ ├── javascript
│ │ ├── .funcignore
│ │ ├── host.json
│ │ ├── local.settings.json
│ │ ├── package-lock.json
│ │ ├── package.json
│ │ └── src
│ │ │ └── app.js
│ ├── powershell
│ │ ├── .funcignore
│ │ ├── IngestEmail
│ │ │ ├── function.json
│ │ │ └── run.ps1
│ │ ├── PromptEmail
│ │ │ ├── function.json
│ │ │ └── run.ps1
│ │ ├── extensions.csproj
│ │ ├── host.json
│ │ ├── local.settings.json
│ │ ├── profile.ps1
│ │ └── requirements.psd1
│ ├── python
│ │ ├── .funcignore
│ │ ├── extensions.csproj
│ │ ├── function_app.py
│ │ ├── host.json
│ │ ├── local.settings.json
│ │ └── requirements.txt
│ └── typescript
│ │ ├── .funcignore
│ │ ├── host.json
│ │ ├── local.settings.json
│ │ ├── package-lock.json
│ │ ├── package.json
│ │ ├── src
│ │ └── app.ts
│ │ └── tsconfig.json
└── textcompletion
│ ├── README.md
│ ├── csharp-legacy
│ ├── TextCompletionLegacy.cs
│ ├── TextCompletionLegacy.csproj
│ ├── host.json
│ └── local.settings.json
│ ├── csharp-ooproc
│ ├── Program.cs
│ ├── Properties
│ │ └── launchSettings.json
│ ├── TextCompletion.csproj
│ ├── TextCompletions.cs
│ ├── host.json
│ └── local.settings.json
│ ├── demo.http
│ ├── java
│ ├── .funcignore
│ ├── extensions.csproj
│ ├── host.json
│ ├── local.settings.json
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── java
│ │ └── com
│ │ └── azfs
│ │ └── TextCompletions.java
│ ├── javascript
│ ├── .funcignore
│ ├── host.json
│ ├── local.settings.json
│ ├── package-lock.json
│ ├── package.json
│ └── src
│ │ └── functions
│ │ └── whois.js
│ ├── powershell
│ ├── .funcignore
│ ├── .gitignore
│ ├── WhoIs
│ │ ├── function.json
│ │ └── run.ps1
│ ├── extensions.csproj
│ ├── host.json
│ ├── local.settings.json
│ ├── profile.ps1
│ └── requirements.psd1
│ ├── python
│ ├── .funcignore
│ ├── function_app.py
│ ├── host.json
│ ├── local.settings.json
│ └── requirements.txt
│ └── typescript
│ ├── .funcignore
│ ├── host.json
│ ├── local.settings.json
│ ├── package-lock.json
│ ├── package.json
│ ├── src
│ └── functions
│ │ └── whois.ts
│ └── tsconfig.json
├── src
├── Directory.Build.props
├── Directory.Build.targets
├── Functions.Worker.Extensions.OpenAI.AzureAISearch
│ └── Functions.Worker.Extensions.OpenAI.AzureAISearch.csproj
├── Functions.Worker.Extensions.OpenAI.CosmosDBNoSqlSearch
│ └── Functions.Worker.Extensions.OpenAI.CosmosDBNoSqlSearch.csproj
├── Functions.Worker.Extensions.OpenAI.CosmosDBSearch
│ └── Functions.Worker.Extensions.OpenAI.CosmosDBSearch.csproj
├── Functions.Worker.Extensions.OpenAI.Kusto
│ └── Functions.Worker.Extensions.OpenAI.Kusto.csproj
├── Functions.Worker.Extensions.OpenAI
│ ├── Assistants
│ │ ├── AssistantCreateOutputAttribute.cs
│ │ ├── AssistantCreateRequest.cs
│ │ ├── AssistantMessage.cs
│ │ ├── AssistantPostInputAttribute.cs
│ │ ├── AssistantQueryInputAttribute.cs
│ │ ├── AssistantSkillTriggerAttribute.cs
│ │ ├── AssistantState.cs
│ │ └── ChatCompletionJsonConverter.cs
│ ├── Embeddings
│ │ ├── EmbeddingsContext.cs
│ │ ├── EmbeddingsInputAttribute.cs
│ │ ├── EmbeddingsJsonConverter.cs
│ │ ├── EmbeddingsOptionsJsonConverter.cs
│ │ ├── EmbeddingsStoreOutputAttribute.cs
│ │ ├── InputType.cs
│ │ └── JsonModelListWrapper.cs
│ ├── Functions.Worker.Extensions.OpenAI.csproj
│ ├── OpenAIModels.cs
│ ├── Search
│ │ ├── ConnectionInfo.cs
│ │ ├── SearchableDocument.cs
│ │ ├── SearchableDocumentJsonConverter.cs
│ │ ├── SemanticSearchContext.cs
│ │ └── SemanticSearchInputAttribute.cs
│ ├── Startup.cs
│ └── TextCompletion
│ │ ├── TextCompletionInputAttribute.cs
│ │ └── TextCompletionResponse.cs
├── WebJobs.Extensions.OpenAI.AzureAISearch
│ ├── AzureAISearchConfigOptions.cs
│ ├── AzureAISearchProvider.cs
│ ├── CHANGELOG.md
│ ├── OpenAIAzureAISearch.cs
│ └── WebJobs.Extensions.OpenAI.AzureAISearch.csproj
├── WebJobs.Extensions.OpenAI.CosmosDBNoSqlSearch
│ ├── CHANGELOG.md
│ ├── CosmosDBNoSqlSearchConfigOptions.cs
│ ├── CosmosDBNoSqlSearchProvider.cs
│ ├── CosmosSystemTextJsonSerializer.cs
│ ├── OpenAICosmosDBNoSqlSearch.cs
│ └── WebJobs.Extensions.OpenAI.CosmosDBNoSqlSearch.csproj
├── WebJobs.Extensions.OpenAI.CosmosDBSearch
│ ├── CHANGELOG.md
│ ├── CosmosDBSearchConfigOptions.cs
│ ├── CosmosDBSearchProvider.cs
│ ├── OpenAICosmosDBSearch.cs
│ └── WebJobs.Extensions.OpenAI.CosmosDBSearch.csproj
├── WebJobs.Extensions.OpenAI.Kusto
│ ├── CHANGELOG.md
│ ├── KustoSearchProvider.cs
│ ├── OpenAIKusto.cs
│ └── WebJobs.Extensions.OpenAI.Kusto.csproj
└── WebJobs.Extensions.OpenAI
│ ├── Assistants
│ ├── AssistantBaseAttribute.cs
│ ├── AssistantBindingConverter.cs
│ ├── AssistantCreateAttribute.cs
│ ├── AssistantPostAttribute.cs
│ ├── AssistantQueryAttribute.cs
│ ├── AssistantRuntimeState.cs
│ ├── AssistantService.cs
│ ├── AssistantSkillTriggerAttribute.cs
│ ├── AssistantSkillTriggerBindingProvider.cs
│ ├── ChatCompletionsJsonConverter.cs
│ └── IAssistantSkillInvoker.cs
│ ├── Embeddings
│ ├── EmbeddingsAttribute.cs
│ ├── EmbeddingsBaseAttribute.cs
│ ├── EmbeddingsContext.cs
│ ├── EmbeddingsContextConverter.cs
│ ├── EmbeddingsConverter.cs
│ ├── EmbeddingsHelper.cs
│ ├── EmbeddingsOptionsJsonConverter.cs
│ ├── EmbeddingsStoreAttribute.cs
│ ├── EmbeddingsStoreConverter.cs
│ ├── InputType.cs
│ └── JsonModelListWrapper.cs
│ ├── Models
│ ├── AssistantMessage.cs
│ ├── AssistantState.cs
│ ├── AssistantStateEntity.cs
│ ├── ChatMessageTableEntity.cs
│ ├── OpenAIModels.cs
│ └── TextCompletionResponse.cs
│ ├── OpenAIClientFactory.cs
│ ├── OpenAIConfigOptions.cs
│ ├── OpenAIExtension.cs
│ ├── OpenAIServiceAttribute.cs
│ ├── OpenAIWebJobsBuilderExtensions.cs
│ ├── OpenAIWebJobsStartup.cs
│ ├── Search
│ ├── ISearchProvider.cs
│ ├── SearchResult.cs
│ ├── SearchableDocumentJsonConverter.cs
│ ├── SemanticSearchAttribute.cs
│ ├── SemanticSearchContext.cs
│ └── SemanticSearchConverter.cs
│ ├── TableBindingOptions.cs
│ ├── TextCompletionAttribute.cs
│ ├── TextCompletionConverter.cs
│ ├── WebJobs.Extensions.OpenAI.csproj
│ └── _CSharpLanguageHelpers.cs
└── tests
├── SampleValidation
├── AssistantTests.cs
├── Chat.cs
├── Common.cs
├── EmbeddingsTests.cs
├── FilePromptsTests.cs
├── SampleValidation.csproj
└── TextCompletionTests.cs
└── UnitTests
├── AssistantServiceTests.cs
├── OpenAIClientFactoryTests.cs
└── WebJobsOpenAIUnitTests.csproj
/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | "recommendations": [
3 | "ms-azuretools.vscode-azurefunctions",
4 | "ms-dotnettools.csharp"
5 | ]
6 | }
--------------------------------------------------------------------------------
/CODEOWNERS:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/about-codeowners/
2 | # for more info about CODEOWNERS file
3 | #
4 | # It uses the same pattern rule for gitignore file
5 | # https://git-scm.com/docs/gitignore#_pattern_format
6 |
7 |
8 |
9 | # AZURE FUNCTIONS TEAM
10 | # For all file changes, github would automatically
11 | # include the following people in the PRs.
12 |
13 | * @vrdmr @manvkaur @aishwaryabh @cgillum @gavin-aguiar
14 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Microsoft Open Source Code of Conduct
2 |
3 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
4 |
5 | Resources:
6 |
7 | - [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/)
8 | - [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
9 | - Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns
10 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) Microsoft Corporation.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE
22 |
--------------------------------------------------------------------------------
/eng/cd/templates/release-variables.yml:
--------------------------------------------------------------------------------
1 | variables:
2 | - name: WebJobsVersion
3 | value: '0.19.0-alpha'
4 | - name: KustoVersion
5 | value: '0.17.0-alpha'
6 | - name: AzureAISearchVersion
7 | value: '0.5.0-alpha'
8 | - name: CosmosDBSearchVersion
9 | value: '0.4.0-alpha'
10 | - name: CosmosDBNoSQLSearchVersion
11 | value: '0.1.0-alpha'
12 |
--------------------------------------------------------------------------------
/eng/ci/code-mirror.yml:
--------------------------------------------------------------------------------
1 | trigger:
2 | branches:
3 | include:
4 | - main
5 |
6 | resources:
7 | repositories:
8 | - repository: eng
9 | type: git
10 | name: engineering
11 | ref: refs/tags/release
12 |
13 | variables:
14 | - template: ci/variables/cfs.yml@eng
15 |
16 | extends:
17 | template: ci/code-mirror.yml@eng
18 |
--------------------------------------------------------------------------------
/eng/ci/integration-tests.yml:
--------------------------------------------------------------------------------
1 | trigger: none # ensure this is not ran as a CI build
2 |
3 | pr:
4 | branches:
5 | include:
6 | - main
7 |
8 | resources:
9 | repositories:
10 | - repository: 1es
11 | type: git
12 | name: 1ESPipelineTemplates/1ESPipelineTemplates
13 | ref: refs/tags/release
14 | - repository: eng
15 | type: git
16 | name: engineering
17 | ref: refs/tags/release
18 |
19 | variables:
20 | - template: /eng/ci/templates/build-variables.yml@self
21 | - template: /ci/variables/cfs.yml@eng
22 |
23 | extends:
24 | template: v1/1ES.Unofficial.PipelineTemplate.yml@1es
25 | parameters:
26 | pool:
27 | name: 1es-pool-azfunc
28 | image: 1es-windows-2022
29 | os: windows
30 |
31 | stages:
32 | - stage: Build
33 | displayName: 'Build And Test'
34 | dependsOn: []
35 | jobs:
36 | - template: /eng/ci/templates/run-integration-tests.yml@self
37 |
--------------------------------------------------------------------------------
/eng/ci/templates/build-variables.yml:
--------------------------------------------------------------------------------
1 | variables:
2 | - name: config
3 | value: Release
4 | - name: fakeWebJobsPackageVersion
5 | value: 99.99.99-test
6 |
--------------------------------------------------------------------------------
/env/.gitignore:
--------------------------------------------------------------------------------
1 | # User secrets files
2 | *.env
3 |
--------------------------------------------------------------------------------
/env/README.md:
--------------------------------------------------------------------------------
1 | # Setting up Environment Variables
2 |
3 | 1. Create a file in this folder called `.env`. **Security Note** `.env` file must never check in to github repos, and it is excluded in .gitignore. Add these contents and fill in values. Choose either the AZURE* values or the OPENAI_API_KEY, but not both.
4 |
5 | .env contents (keep secure)
6 |
7 | ```text
8 | OPENAI_API_KEY=""
9 | AZURE_OPENAI_KEY=""
10 | AZURE_OPENAI_ENDPOINT="https://***.openai.azure.com/"
11 | AZURE_DEPLOYMENT_NAME=""
12 | ```
13 |
14 | 1. Export the environment variables from `.env` to your machine
15 |
16 | Windows:
17 |
18 | ```ps
19 | .\dotenvtoenvars.ps1 .\.env -Verbose -RemoveQuotes
20 | ```
21 |
22 | Mac/Linux:
23 |
24 | ```sh
25 | set -o allexport; source ./.env; set +o allexport
26 | ```
27 |
--------------------------------------------------------------------------------
/env/dotenvtoenvars.ps1:
--------------------------------------------------------------------------------
1 | param(
2 | [string]$Path,
3 | [switch]$Verbose,
4 | [switch]$Remove,
5 | [switch]$RemoveQuotes
6 | )
7 |
8 | $variables = Select-String -Path $Path -Pattern '^\s*[^\s=#]+=[^\s]+$' -Raw
9 |
10 | foreach($var in $variables) {
11 | $keyVal = $var -split '=', 2
12 | $key = $keyVal[0].Trim()
13 | $val = $RemoveQuotes ? $keyVal[1].Trim("'").Trim('"') : $keyVal[1]
14 | [Environment]::SetEnvironmentVariable($key, $Remove ? '' : $val, "User")
15 | if ($Verbose) {
16 | "$key=$([Environment]::GetEnvironmentVariable($key))"
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/java-library/src/main/java/com/microsoft/azure/functions/openai/annotation/assistant/AssistantCreate.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) Microsoft Corporation. All rights reserved.
3 | * Licensed under the MIT License. See License.txt in the project root for
4 | * license information.
5 | */
6 |
7 | package com.microsoft.azure.functions.openai.annotation.assistant;
8 |
9 | import com.microsoft.azure.functions.annotation.CustomBinding;
10 |
11 | import java.lang.annotation.ElementType;
12 | import java.lang.annotation.Retention;
13 | import java.lang.annotation.RetentionPolicy;
14 | import java.lang.annotation.Target;
15 |
16 | /**
17 | *
18 | * Assistant create output binding attribute which is used to create a assistant.
19 | *
20 | *
21 | * @since 1.0.0
22 | */
23 | @Retention(RetentionPolicy.RUNTIME)
24 | @Target(ElementType.PARAMETER)
25 | @CustomBinding(direction = "out", name = "", type = "assistantCreate")
26 | public @interface AssistantCreate {
27 | /**
28 | * The variable name used in function.json.
29 | *
30 | * @return The variable name used in function.json.
31 | */
32 | String name();
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/java-library/src/main/java/com/microsoft/azure/functions/openai/annotation/embeddings/InputType.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) Microsoft Corporation. All rights reserved.
3 | * Licensed under the MIT License. See License.txt in the project root for
4 | * license information.
5 | */
6 |
7 | package com.microsoft.azure.functions.openai.annotation.embeddings;
8 |
9 |
10 | /**
11 | *
12 | * Options for interpreting embeddings input binding data.
13 | *
14 | */
15 | public enum InputType {
16 | /**
17 | * The input data is raw text.
18 | */
19 | RawText,
20 |
21 | /**
22 | * The input data is a file path that contains the text.
23 | */
24 | FilePath,
25 |
26 | /**
27 | * The input data is a URL.
28 | */
29 | Url
30 | }
31 |
--------------------------------------------------------------------------------
/java-library/src/main/java/com/microsoft/azure/functions/openai/constants/ModelDefaults.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) Microsoft Corporation. All rights reserved.
3 | * Licensed under the MIT License. See License.txt in the project root for
4 | * license information.
5 | */
6 |
7 | package com.microsoft.azure.functions.openai.constants;
8 |
9 | /**
10 | * Constants for default model values used throughout the library.
11 | * Centralizing these values makes it easier to update them across the codebase.
12 | *
13 | * @since 1.0.0
14 | */
15 | public final class ModelDefaults {
16 |
17 | /**
18 | * Private constructor to prevent instantiation.
19 | */
20 | private ModelDefaults() {
21 | // Utility class should not be instantiated
22 | }
23 |
24 | /**
25 | * The default chat completion model used for text generation.
26 | */
27 | public static final String DEFAULT_CHAT_MODEL = "gpt-3.5-turbo";
28 |
29 | /**
30 | * The default embeddings model used for vector embeddings.
31 | */
32 | public static final String DEFAULT_EMBEDDINGS_MODEL = "text-embedding-ada-002";
33 | }
34 |
--------------------------------------------------------------------------------
/nuget.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/samples/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 | false
4 | false
5 |
6 |
--------------------------------------------------------------------------------
/samples/assistant/csharp-legacy/AssistantSample.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net8.0
4 | v4
5 | enable
6 | 11.0
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | PreserveNewest
18 |
19 |
20 | PreserveNewest
21 | Never
22 |
23 |
24 |
--------------------------------------------------------------------------------
/samples/assistant/csharp-legacy/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "AssistantLegacySample": {
4 | "commandName": "Project",
5 | "commandLineArgs": "--port 7071",
6 | "launchBrowser": false
7 | }
8 | }
9 | }
--------------------------------------------------------------------------------
/samples/assistant/csharp-legacy/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | }
8 | }
--------------------------------------------------------------------------------
/samples/assistant/csharp-legacy/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "FUNCTIONS_WORKER_RUNTIME": "dotnet",
6 | "FUNCTIONS_INPROC_NET8_ENABLED": "1",
7 | "CosmosDbConnectionString": "Local Cosmos DB emulator or Cosmos DB in Azure connection string",
8 | "CosmosDatabaseName": "todoDB",
9 | "CosmosContainerName": "myTasks",
10 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
11 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo"
12 | }
13 | }
--------------------------------------------------------------------------------
/samples/assistant/csharp-ooproc/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | }
8 | }
--------------------------------------------------------------------------------
/samples/assistant/csharp-ooproc/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
6 | "CosmosDbConnectionString": "Local Cosmos DB emulator or Cosmos DB in Azure connection string",
7 | "CosmosDatabaseName": "todoDB",
8 | "CosmosContainerName": "myTasks",
9 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
10 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo"
11 | }
12 | }
--------------------------------------------------------------------------------
/samples/assistant/demo.http:
--------------------------------------------------------------------------------
1 | ### Create a new assistant - instructions are hardcoded in the function
2 | PUT http://localhost:7071/api/assistants/assistant123
3 |
4 |
5 | ### Reminder #1 - Remind me to call my dad
6 | POST http://localhost:7071/api/assistants/assistant123?message=Remind%20me%20to%20call%20my%20dad
7 |
8 |
9 | ### Reminder #2 - Oh, and to take out the trash
10 | POST http://localhost:7071/api/assistants/assistant123?message=Oh,%20and%20to%20take%20out%20the%20trash
11 |
12 |
13 | ### Get the list of tasks - What do I need to do today?
14 | POST http://localhost:7071/api/assistants/assistant123?message=What%20do%20I%20need%20to%20do%20today%3F
15 |
16 |
17 | ### Query the chat history
18 | GET http://localhost:7071/api/assistants/assistant123?timestampUTC=2023-01-01T00:00:00Z
19 | Accept: application/json
20 |
--------------------------------------------------------------------------------
/samples/assistant/java/.funcignore:
--------------------------------------------------------------------------------
1 | local.settings.json
--------------------------------------------------------------------------------
/samples/assistant/java/extensions.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net80
4 |
5 | **
6 | target/azure-functions/azfs-java-openai-sample/bin
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/samples/assistant/java/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | }
8 | }
--------------------------------------------------------------------------------
/samples/assistant/java/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "FUNCTIONS_WORKER_RUNTIME": "java",
6 | "CosmosDbConnectionEndpoint": "Local Cosmos DB emulator or Cosmos DB in Azure Cosmos end point",
7 | "CosmosDatabaseName": "todoDB",
8 | "CosmosContainerName": "myTasks",
9 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
10 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo"
11 | }
12 | }
--------------------------------------------------------------------------------
/samples/assistant/javascript/.funcignore:
--------------------------------------------------------------------------------
1 | *.js.map
2 | *.ts
3 | .git*
4 | .vscode
5 | __azurite_db*__.json
6 | __blobstorage__
7 | __queuestorage__
8 | local.settings.json
9 | test
10 | tsconfig.json
--------------------------------------------------------------------------------
/samples/assistant/javascript/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | },
8 | "extensionBundle": {
9 | "id": "Microsoft.Azure.Functions.ExtensionBundle.Preview",
10 | "version": "[4.*, 5.0.0)"
11 | }
12 | }
--------------------------------------------------------------------------------
/samples/assistant/javascript/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "AzureWebJobsFeatureFlags": "EnableWorkerIndexing",
6 | "FUNCTIONS_WORKER_RUNTIME": "node",
7 | "CosmosDbConnectionString": "Local Cosmos DB emulator or Cosmos DB in Azure connection string",
8 | "CosmosDatabaseName": "",
9 | "CosmosContainerName": "",
10 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
11 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo"
12 | }
13 | }
--------------------------------------------------------------------------------
/samples/assistant/javascript/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "assistant",
3 | "version": "1.0.0",
4 | "description": "",
5 | "scripts": {
6 | "start": "func start",
7 | "test": "echo \"No tests yet...\""
8 | },
9 | "dependencies": {
10 | "@azure/cosmos": "^4.0.0",
11 | "@azure/functions": "^4.0.0"
12 | },
13 | "devDependencies": {
14 | },
15 | "main": "src/functions/*.js"
16 | }
17 |
--------------------------------------------------------------------------------
/samples/assistant/powershell/.funcignore:
--------------------------------------------------------------------------------
1 | .git*
2 | .vscode
3 | __azurite_db*__.json
4 | __blobstorage__
5 | __queuestorage__
6 | local.settings.json
7 | test
--------------------------------------------------------------------------------
/samples/assistant/powershell/AddTodo/function.json:
--------------------------------------------------------------------------------
1 | {
2 | "bindings": [
3 | {
4 | "name": "TaskDescription",
5 | "type": "assistantSkillTrigger",
6 | "dataType": "string",
7 | "direction": "in",
8 | "functionDescription": "Create a new todo task"
9 | }
10 | ]
11 | }
--------------------------------------------------------------------------------
/samples/assistant/powershell/AddTodo/run.ps1:
--------------------------------------------------------------------------------
1 | using namespace System.Net
2 |
3 | param($TaskDescription, $TriggerMetadata)
4 | $ErrorActionPreference = "Stop"
5 |
6 | if (-not $TaskDescription) {
7 | throw "Task description cannot be empty"
8 | }
9 |
10 | Write-Information "Adding todo: $TaskDescription"
11 | $todoID = [Guid]::NewGuid().ToString().Substring(0, 5)
12 | Add-Todo $todoId $TaskDescription
--------------------------------------------------------------------------------
/samples/assistant/powershell/CreateAssistant/function.json:
--------------------------------------------------------------------------------
1 | {
2 | "bindings": [
3 | {
4 | "authLevel": "function",
5 | "type": "httpTrigger",
6 | "direction": "in",
7 | "name": "Request",
8 | "route": "assistants/{assistantId}",
9 | "methods": [
10 | "put"
11 | ]
12 | },
13 | {
14 | "type": "http",
15 | "direction": "out",
16 | "name": "Response"
17 | },
18 | {
19 | "type": "assistantCreate",
20 | "direction": "out",
21 | "dataType": "string",
22 | "name": "Requests"
23 | }
24 | ]
25 | }
--------------------------------------------------------------------------------
/samples/assistant/powershell/CreateAssistant/run.ps1:
--------------------------------------------------------------------------------
1 | using namespace System.Net
2 |
3 | param($Request, $TriggerMetadata)
4 |
5 | $assistantId = $Request.params.assistantId
6 |
7 | $instructions = "Don't make assumptions about what values to plug into functions."
8 | $instructions += "\nAsk for clarification if a user request is ambiguous."
9 |
10 | $create_request = @{
11 | "id" = $assistantId
12 | "instructions" = $instructions
13 | "chatStorageConnectionSetting" = "AzureWebJobsStorage"
14 | "collectionName" = "ChatState"
15 | }
16 |
17 | Push-OutputBinding -Name Requests -Value (ConvertTo-Json $create_request)
18 |
19 | Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
20 | StatusCode = [HttpStatusCode]::Accepted
21 | Body = (ConvertTo-Json @{ "assistantId" = $assistantId})
22 | Headers = @{
23 | "Content-Type" = "application/json"
24 | }
25 | })
--------------------------------------------------------------------------------
/samples/assistant/powershell/GetChatState/function.json:
--------------------------------------------------------------------------------
1 | {
2 | "bindings": [
3 | {
4 | "authLevel": "function",
5 | "type": "httpTrigger",
6 | "direction": "in",
7 | "name": "Request",
8 | "route": "assistants/{assistantId}",
9 | "methods": [
10 | "get"
11 | ]
12 | },
13 | {
14 | "type": "http",
15 | "direction": "out",
16 | "name": "Response"
17 | },
18 | {
19 | "name": "State",
20 | "type": "assistantQuery",
21 | "direction": "in",
22 | "dataType": "string",
23 | "id": "{assistantId}",
24 | "timestampUtc": "{Query.timestampUTC}",
25 | "chatStorageConnectionSetting": "AzureWebJobsStorage",
26 | "collectionName": "ChatState"
27 | }
28 | ]
29 | }
--------------------------------------------------------------------------------
/samples/assistant/powershell/GetChatState/run.ps1:
--------------------------------------------------------------------------------
1 | using namespace System.Net
2 |
3 | param($Request, $TriggerMetadata, $State)
4 |
5 | Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
6 | StatusCode = [HttpStatusCode]::OK
7 | Body = $State
8 | Headers = @{
9 | "Content-Type" = "application/json"
10 | }
11 | })
--------------------------------------------------------------------------------
/samples/assistant/powershell/GetTodos/function.json:
--------------------------------------------------------------------------------
1 | {
2 | "bindings": [
3 | {
4 | "name": "InputIgnored",
5 | "type": "assistantSkillTrigger",
6 | "dataType": "string",
7 | "direction": "in",
8 | "functionDescription": "Fetch the list of previously created todo tasks"
9 | }
10 | ]
11 | }
--------------------------------------------------------------------------------
/samples/assistant/powershell/GetTodos/run.ps1:
--------------------------------------------------------------------------------
1 | using namespace System.Net
2 |
3 | param($InputIgnored, $TriggerMetadata)
4 |
5 | $ErrorActionPreference = "Stop"
6 |
7 | Write-Information "Fetching list of todos"
8 |
9 | Get-Todos
--------------------------------------------------------------------------------
/samples/assistant/powershell/PostUserQuery/function.json:
--------------------------------------------------------------------------------
1 | {
2 | "bindings": [
3 | {
4 | "authLevel": "function",
5 | "type": "httpTrigger",
6 | "direction": "in",
7 | "name": "Request",
8 | "route": "assistants/{assistantId}",
9 | "methods": [
10 | "post"
11 | ]
12 | },
13 | {
14 | "type": "http",
15 | "direction": "out",
16 | "name": "Response"
17 | },
18 | {
19 | "name": "State",
20 | "type": "assistantPost",
21 | "direction": "in",
22 | "dataType": "string",
23 | "id": "{assistantId}",
24 | "userMessage": "{Query.message}",
25 | "chatModel": "%CHAT_MODEL_DEPLOYMENT_NAME%",
26 | "chatStorageConnectionSetting": "AzureWebJobsStorage",
27 | "collectionName": "ChatState"
28 | }
29 | ]
30 | }
--------------------------------------------------------------------------------
/samples/assistant/powershell/PostUserQuery/run.ps1:
--------------------------------------------------------------------------------
1 | using namespace System.Net
2 |
3 | param($Request, $TriggerMetadata, $State)
4 |
5 | $recent_message_content = "No recent messages!"
6 |
7 | if ($State.recentMessages.Count -gt 0) {
8 | $recent_message_content = $State.recentMessages[0].content
9 | }
10 |
11 | Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
12 | StatusCode = [HttpStatusCode]::OK
13 | Body = $recent_message_content
14 | Headers = @{
15 | "Content-Type" = "text/plain"
16 | }
17 | })
--------------------------------------------------------------------------------
/samples/assistant/powershell/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "managedDependency": {
4 | "enabled": true
5 | },
6 | "logging": {
7 | "logLevel": {
8 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
9 | }
10 | },
11 | "extensionBundle": {
12 | "id": "Microsoft.Azure.Functions.ExtensionBundle.Preview",
13 | "version": "[4.*, 5.0.0)"
14 | }
15 | }
--------------------------------------------------------------------------------
/samples/assistant/powershell/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "FUNCTIONS_WORKER_RUNTIME": "powershell",
6 | "FUNCTIONS_WORKER_RUNTIME_VERSION": "7.2",
7 | "CosmosDbConnectionString": "Local Cosmos DB emulator or Cosmos DB in Azure connection string",
8 | "CosmosDatabaseName": "testdb",
9 | "CosmosContainerName": "my-todos",
10 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
11 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo"
12 | }
13 | }
--------------------------------------------------------------------------------
/samples/assistant/powershell/profile.ps1:
--------------------------------------------------------------------------------
1 | # Azure Functions profile.ps1
2 | #
3 | # This profile.ps1 will get executed every "cold start" of your Function App.
4 | # "cold start" occurs when:
5 | #
6 | # * A Function App starts up for the very first time
7 | # * A Function App starts up after being de-allocated due to inactivity
8 | #
9 | # You can define helper functions, run commands, or specify environment variables
10 | # NOTE: any variables defined that are not environment variables will get reset after the first execution
11 |
12 | # Authenticate with Azure PowerShell using MSI.
13 | # Remove this if you are not planning on using MSI or Azure PowerShell.
14 | if ($env:MSI_SECRET) {
15 | Disable-AzContextAutosave -Scope Process | Out-Null
16 | Connect-AzAccount -Identity
17 | }
18 |
19 | Import-Module -Name ./TodoManager/TodoManager.ps1
20 | Import-Module -Name CosmosDB
21 |
22 | # Uncomment the next line to enable legacy AzureRm alias in Azure PowerShell.
23 | # Enable-AzureRmAlias
24 |
25 | # You can also define functions or aliases that can be referenced in any of your PowerShell functions.
26 |
--------------------------------------------------------------------------------
/samples/assistant/powershell/requirements.psd1:
--------------------------------------------------------------------------------
1 | # This file enables modules to be automatically managed by the Functions service.
2 | # See https://aka.ms/functionsmanageddependency for additional information.
3 | #
4 | @{
5 | # For latest supported version, go to 'https://www.powershellgallery.com/packages/Az'. Uncomment the next line and replace the MAJOR_VERSION, e.g., 'Az' = '5.*'
6 | # 'Az' = 'MAJOR_VERSION.*'
7 | 'CosmosDb' = '4.7.0'
8 | }
--------------------------------------------------------------------------------
/samples/assistant/python/.funcignore:
--------------------------------------------------------------------------------
1 | .git*
2 | .vscode
3 | __azurite_db*__.json
4 | __blobstorage__
5 | __queuestorage__
6 | local.settings.json
7 | test
8 | .venv
--------------------------------------------------------------------------------
/samples/assistant/python/assistant_skills.py:
--------------------------------------------------------------------------------
1 | import json
2 | import logging
3 | import uuid
4 | import azure.functions as func
5 |
6 | from todo_manager import CreateTodoManager, TodoItem
7 |
8 | skills = func.Blueprint()
9 |
10 | todo_manager = CreateTodoManager()
11 |
12 |
13 | @skills.function_name("AddTodo")
14 | @skills.assistant_skill_trigger(
15 | arg_name="taskDescription", function_description="Create a new todo task"
16 | )
17 | def add_todo(taskDescription: str) -> None:
18 | if not taskDescription:
19 | raise ValueError("Task description cannot be empty")
20 |
21 | logging.info(f"Adding todo: {taskDescription}")
22 |
23 | todo_id = str(uuid.uuid4())[0:6]
24 | todo_manager.add_todo(TodoItem(id=todo_id, task=taskDescription))
25 | return
26 |
27 |
28 | @skills.function_name("GetTodos")
29 | @skills.assistant_skill_trigger(
30 | arg_name="inputIgnored",
31 | function_description="Fetch the list of previously created todo tasks",
32 | )
33 | def get_todos(inputIgnored: str) -> str:
34 | logging.info("Fetching list of todos")
35 | results = todo_manager.get_todos()
36 | return json.dumps(results)
37 |
--------------------------------------------------------------------------------
/samples/assistant/python/function_app.py:
--------------------------------------------------------------------------------
1 | import azure.functions as func
2 |
3 | from assistant_apis import apis
4 | from assistant_skills import skills
5 |
6 | app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS)
7 |
8 | app.register_functions(apis)
9 | app.register_functions(skills)
10 |
--------------------------------------------------------------------------------
/samples/assistant/python/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | },
8 | "extensionBundle": {
9 | "id": "Microsoft.Azure.Functions.ExtensionBundle.Preview",
10 | "version": "[4.*, 5.0.0)"
11 | }
12 | }
--------------------------------------------------------------------------------
/samples/assistant/python/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "AzureWebJobsFeatureFlags": "EnableWorkerIndexing",
6 | "FUNCTIONS_WORKER_RUNTIME": "python",
7 | "CosmosDbConnectionEndpoint": "Placeholder for Azure Cosmos DB for NoSQL Endpoint",
8 | "CosmosDatabaseName": "testdb",
9 | "CosmosContainerName": "my-todos",
10 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
11 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo",
12 | "PYTHON_ISOLATE_WORKER_DEPENDENCIES": "1"
13 | }
14 | }
--------------------------------------------------------------------------------
/samples/assistant/python/requirements.txt:
--------------------------------------------------------------------------------
1 | # DO NOT include azure-functions-worker in this file
2 | # The Python Worker is managed by Azure Functions platform
3 | # Manually managing azure-functions-worker may cause unexpected issues
4 |
5 | azure-functions>=1.24.0b1
6 | azure-cosmos
7 | azure-identity
--------------------------------------------------------------------------------
/samples/assistant/typescript/.funcignore:
--------------------------------------------------------------------------------
1 | *.js.map
2 | *.ts
3 | .git*
4 | .vscode
5 | __azurite_db*__.json
6 | __blobstorage__
7 | __queuestorage__
8 | local.settings.json
9 | test
10 | tsconfig.json
--------------------------------------------------------------------------------
/samples/assistant/typescript/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | },
8 | "extensionBundle": {
9 | "id": "Microsoft.Azure.Functions.ExtensionBundle.Preview",
10 | "version": "[4.*, 5.0.0)"
11 | }
12 | }
--------------------------------------------------------------------------------
/samples/assistant/typescript/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "AzureWebJobsFeatureFlags": "EnableWorkerIndexing",
6 | "FUNCTIONS_WORKER_RUNTIME": "node",
7 | "CosmosDbConnectionString": "Local Cosmos DB emulator or Cosmos DB in Azure connection string",
8 | "CosmosDatabaseName": "",
9 | "CosmosContainerName": "",
10 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
11 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo"
12 | }
13 | }
--------------------------------------------------------------------------------
/samples/assistant/typescript/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "assistant",
3 | "version": "1.0.0",
4 | "description": "",
5 | "scripts": {
6 | "build": "tsc",
7 | "watch": "tsc -w",
8 | "prestart": "npm run build",
9 | "start": "func start",
10 | "test": "echo \"No tests yet...\""
11 | },
12 | "dependencies": {
13 | "@azure/cosmos": "^4.0.0",
14 | "@azure/functions": "^4.0.0"
15 | },
16 | "devDependencies": {
17 | "@types/node": "^18.x",
18 | "rimraf": "^5.0.0",
19 | "typescript": "^4.0.0"
20 | },
21 | "main": "dist/src/functions/*.js"
22 | }
23 |
--------------------------------------------------------------------------------
/samples/assistant/typescript/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es6",
5 | "outDir": "dist",
6 | "rootDir": ".",
7 | "sourceMap": true,
8 | "strict": false
9 | }
10 | }
--------------------------------------------------------------------------------
/samples/chat/csharp-legacy/ChatBotSample.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net8.0
4 | v4
5 | enable
6 | 11.0
7 |
8 |
9 |
10 |
11 |
12 |
14 |
15 |
16 |
17 | PreserveNewest
18 |
19 |
20 | PreserveNewest
21 | Never
22 |
23 |
24 |
--------------------------------------------------------------------------------
/samples/chat/csharp-legacy/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env
2 |
3 | # Add support for .NET 8 (required for Azure Functions build process)
4 | COPY --from=mcr.microsoft.com/dotnet/sdk:8.0 /usr/share/dotnet/shared /usr/share/dotnet/shared
5 |
6 | # Need to build the full repo to get the samples to work
7 | COPY . /root
8 | RUN cd /root/samples/chat/csharp-legacy && \
9 | mkdir -p /home/site/wwwroot && \
10 | dotnet restore --verbosity normal && \
11 | dotnet build --no-restore -c Release && \
12 | dotnet publish --no-restore -c Release -o /home/site/wwwroot
13 |
14 | # The final image is based on the Azure Functions 4.0 runtime image
15 | FROM mcr.microsoft.com/azure-functions/dotnet:4
16 |
17 | # This is the standard setup for Azure Functions running in Docker containers
18 | ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
19 | AzureFunctionsJobHost__Logging__Console__IsEnabled=true
20 | COPY --from=build-env ["/home/site/wwwroot", "/home/site/wwwroot"]
21 |
--------------------------------------------------------------------------------
/samples/chat/csharp-legacy/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | }
8 | }
--------------------------------------------------------------------------------
/samples/chat/csharp-legacy/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "FUNCTIONS_WORKER_RUNTIME": "dotnet",
6 | "FUNCTIONS_INPROC_NET8_ENABLED": "1",
7 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
8 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo"
9 | }
10 | }
--------------------------------------------------------------------------------
/samples/chat/csharp-ooproc/Program.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using System.Text.Json;
5 | using System.Text.Json.Serialization;
6 | using Microsoft.Extensions.DependencyInjection;
7 | using Microsoft.Extensions.Hosting;
8 |
9 |
10 | var host = new HostBuilder()
11 | .ConfigureFunctionsWebApplication()
12 | .ConfigureServices(services =>
13 | {
14 | services.Configure(options =>
15 | {
16 | options.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
17 | options.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
18 | });
19 | })
20 | .Build();
21 |
22 | host.Run();
23 |
--------------------------------------------------------------------------------
/samples/chat/csharp-ooproc/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/samples/chat/csharp-ooproc/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
6 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
7 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo"
8 | }
9 | }
--------------------------------------------------------------------------------
/samples/chat/demo.http:
--------------------------------------------------------------------------------
1 | ### Create a new chatbot
2 | PUT http://localhost:7071/api/chats/test123
3 | Content-Type: application/json
4 |
5 | {
6 | "instructions": "You are a helpful chatbot. In all your English responses, speak as if you are Shakespeare."
7 | }
8 |
9 |
10 | ### Send the first message to the chatbot - Who won SuperBowl XLVIII in 2014?
11 | POST http://localhost:7071/api/chats/test123?message=Who%20won%20SuperBowl%20XLVIII%20in%202014?
12 |
13 |
14 | ### Get the chatbot's response
15 | GET http://localhost:7071/api/chats/test123?timestampUTC=2023-08-10T07:51:10Z
16 |
17 |
18 | ### Send the second message to the chatbot - Amazing! Do you know who performed the halftime show?
19 | POST http://localhost:7071/api/chats/test123?message=Amazing!%20Do%20you%20know%20who%20performed%20the%20halftime%20show?
20 |
--------------------------------------------------------------------------------
/samples/chat/java/.funcignore:
--------------------------------------------------------------------------------
1 | local.settings.json
--------------------------------------------------------------------------------
/samples/chat/java/extensions.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net80
4 |
5 | **
6 | target/azure-functions/azfs-java-openai-sample/bin
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/samples/chat/java/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | }
8 | }
--------------------------------------------------------------------------------
/samples/chat/java/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "AzureWebJobsFeatureFlags": "EnableWorkerIndexing",
6 | "FUNCTIONS_WORKER_RUNTIME": "java",
7 | "AZURE_OPENAI_ENDPOINT": "https://.openai.azure.com/",
8 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo"
9 | }
10 | }
--------------------------------------------------------------------------------
/samples/chat/javascript/.funcignore:
--------------------------------------------------------------------------------
1 | *.js.map
2 | *.ts
3 | .git*
4 | .vscode
5 | __azurite_db*__.json
6 | __blobstorage__
7 | __queuestorage__
8 | local.settings.json
9 | test
10 | tsconfig.json
--------------------------------------------------------------------------------
/samples/chat/javascript/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | },
8 | "extensionBundle": {
9 | "id": "Microsoft.Azure.Functions.ExtensionBundle.Preview",
10 | "version": "[4.*, 5.0.0)"
11 | }
12 | }
--------------------------------------------------------------------------------
/samples/chat/javascript/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "AzureWebJobsFeatureFlags": "EnableWorkerIndexing",
6 | "FUNCTIONS_WORKER_RUNTIME": "node",
7 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
8 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo"
9 | }
10 | }
--------------------------------------------------------------------------------
/samples/chat/javascript/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "chat",
3 | "version": "1.0.0",
4 | "description": "",
5 | "scripts": {
6 | "start": "func start",
7 | "test": "echo \"No tests yet...\""
8 | },
9 | "dependencies": {
10 | "@azure/functions": "^4.0.0"
11 | },
12 | "devDependencies": {
13 | },
14 | "main": "src/*.js"
15 | }
--------------------------------------------------------------------------------
/samples/chat/powershell/.funcignore:
--------------------------------------------------------------------------------
1 | .git*
2 | .vscode
3 | __azurite_db*__.json
4 | __blobstorage__
5 | __queuestorage__
6 | local.settings.json
7 | test
--------------------------------------------------------------------------------
/samples/chat/powershell/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | # Azure Functions artifacts
3 | bin
4 | obj
5 | appsettings.json
6 |
7 | # Azurite artifacts
8 | __blobstorage__
9 | __queuestorage__
10 | __azurite_db*__.json
--------------------------------------------------------------------------------
/samples/chat/powershell/CreateChatBot/function.json:
--------------------------------------------------------------------------------
1 | {
2 | "bindings": [
3 | {
4 | "authLevel": "function",
5 | "type": "httpTrigger",
6 | "direction": "in",
7 | "name": "Request",
8 | "route": "chats/{chatId}",
9 | "methods": [
10 | "put"
11 | ]
12 | },
13 | {
14 | "type": "http",
15 | "direction": "out",
16 | "name": "Response"
17 | },
18 | {
19 | "type": "assistantCreate",
20 | "direction": "out",
21 | "name": "ChatBotCreate"
22 | }
23 | ]
24 | }
--------------------------------------------------------------------------------
/samples/chat/powershell/CreateChatBot/run.ps1:
--------------------------------------------------------------------------------
1 | using namespace System.Net
2 |
3 | param($Request, $TriggerMetadata)
4 |
5 | $chatID = $Request.params.ChatId
6 | $inputJson = $Request.Body
7 | Write-Host "Creating chat $chatID from input parameters $($inputJson)"
8 |
9 | $createRequest = @{
10 | id = $chatID
11 | instructions = $inputJson.Instructions
12 | chatStorageConnectionSetting = "AzureWebJobsStorage"
13 | collectionName = "ChatState"
14 | }
15 |
16 | Push-OutputBinding -Name ChatBotCreate -Value $createRequest
17 |
18 | Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
19 | StatusCode = [HttpStatusCode]::Accepted
20 | Body = @{
21 | chatId = $chatID
22 | }
23 | })
--------------------------------------------------------------------------------
/samples/chat/powershell/GetChatState/function.json:
--------------------------------------------------------------------------------
1 | {
2 | "bindings": [
3 | {
4 | "authLevel": "function",
5 | "type": "httpTrigger",
6 | "direction": "in",
7 | "name": "Request",
8 | "route": "chats/{chatId}",
9 | "methods": [
10 | "get"
11 | ]
12 | },
13 | {
14 | "type": "http",
15 | "direction": "out",
16 | "name": "Response"
17 | },
18 | {
19 | "type": "assistantQuery",
20 | "direction": "in",
21 | "name": "ChatBotState",
22 | "id": "{chatId}",
23 | "timeStampUtc": "{Query.timestampUTC}",
24 | "chatStorageConnectionSetting": "AzureWebJobsStorage",
25 | "collectionName": "ChatState"
26 | }
27 | ]
28 | }
--------------------------------------------------------------------------------
/samples/chat/powershell/GetChatState/run.ps1:
--------------------------------------------------------------------------------
1 | using namespace System.Net
2 |
3 | param($Request, $TriggerMetadata, $ChatBotState)
4 |
5 | Write-Host "Query state for chat $($ChatBotState.Id) by timeStampUtc $($ChatBotState.TimeStampUtc)"
6 |
7 | Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
8 | StatusCode = [HttpStatusCode]::OK
9 | Body = $ChatBotState
10 | })
--------------------------------------------------------------------------------
/samples/chat/powershell/PostUserResponse/function.json:
--------------------------------------------------------------------------------
1 | {
2 | "bindings": [
3 | {
4 | "authLevel": "function",
5 | "type": "httpTrigger",
6 | "direction": "in",
7 | "name": "Request",
8 | "route": "chats/{chatId}",
9 | "methods": [
10 | "post"
11 | ]
12 | },
13 | {
14 | "type": "http",
15 | "direction": "out",
16 | "name": "Response"
17 | },
18 | {
19 | "type": "assistantPost",
20 | "direction": "in",
21 | "name": "ChatBotState",
22 | "id": "{chatId}",
23 | "chatModel": "%CHAT_MODEL_DEPLOYMENT_NAME%",
24 | "userMessage": "{Query.message}",
25 | "chatStorageConnectionSetting": "AzureWebJobsStorage",
26 | "collectionName": "ChatState"
27 | }
28 | ]
29 | }
--------------------------------------------------------------------------------
/samples/chat/powershell/PostUserResponse/run.ps1:
--------------------------------------------------------------------------------
1 | using namespace System.Net
2 |
3 | param($Request, $TriggerMetadata, $ChatBotState)
4 |
5 | Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
6 | StatusCode = [HttpStatusCode]::OK
7 | Body = $ChatBotState.recentMessages[0].content
8 | Headers = @{
9 | "Content-Type" = "text/plain"
10 | }
11 | })
--------------------------------------------------------------------------------
/samples/chat/powershell/extensions.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net80
4 |
5 | **
6 | bin
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/samples/chat/powershell/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | }
8 | }
--------------------------------------------------------------------------------
/samples/chat/powershell/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "FUNCTIONS_WORKER_RUNTIME_VERSION": "7.2",
6 | "FUNCTIONS_WORKER_RUNTIME": "powershell",
7 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
8 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo"
9 | }
10 | }
--------------------------------------------------------------------------------
/samples/chat/powershell/profile.ps1:
--------------------------------------------------------------------------------
1 | # Azure Functions profile.ps1
2 | #
3 | # This profile.ps1 will get executed every "cold start" of your Function App.
4 | # "cold start" occurs when:
5 | #
6 | # * A Function App starts up for the very first time
7 | # * A Function App starts up after being de-allocated due to inactivity
8 | #
9 | # You can define helper functions, run commands, or specify environment variables
10 | # NOTE: any variables defined that are not environment variables will get reset after the first execution
11 |
12 | # Authenticate with Azure PowerShell using MSI.
13 | # Remove this if you are not planning on using MSI or Azure PowerShell.
14 | if ($env:MSI_SECRET) {
15 | Disable-AzContextAutosave -Scope Process | Out-Null
16 | Connect-AzAccount -Identity
17 | }
18 |
19 | # Uncomment the next line to enable legacy AzureRm alias in Azure PowerShell.
20 | # Enable-AzureRmAlias
21 |
22 | # You can also define functions or aliases that can be referenced in any of your PowerShell functions.
23 |
--------------------------------------------------------------------------------
/samples/chat/powershell/requirements.psd1:
--------------------------------------------------------------------------------
1 | # This file enables modules to be automatically managed by the Functions service.
2 | # See https://aka.ms/functionsmanageddependency for additional information.
3 | #
4 | @{
5 | # For latest supported version, go to 'https://www.powershellgallery.com/packages/Az'. Uncomment the next line and replace the MAJOR_VERSION, e.g., 'Az' = '5.*'
6 | # 'Az' = 'MAJOR_VERSION.*'
7 | }
--------------------------------------------------------------------------------
/samples/chat/python/.funcignore:
--------------------------------------------------------------------------------
1 | .git*
2 | .vscode
3 | __azurite_db*__.json
4 | __blobstorage__
5 | __queuestorage__
6 | local.settings.json
7 | test
8 | .venv
--------------------------------------------------------------------------------
/samples/chat/python/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | },
7 | "extensionBundle": {
8 | "id": "Microsoft.Azure.Functions.ExtensionBundle.Preview",
9 | "version": "[4.*, 5.0.0)"
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/samples/chat/python/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "AzureWebJobsFeatureFlags": "EnableWorkerIndexing",
6 | "FUNCTIONS_WORKER_RUNTIME": "python",
7 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
8 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo",
9 | "PYTHON_ISOLATE_WORKER_DEPENDENCIES": "1"
10 | }
11 | }
--------------------------------------------------------------------------------
/samples/chat/python/requirements.txt:
--------------------------------------------------------------------------------
1 | # DO NOT include azure-functions-worker in this file
2 | # The Python Worker is managed by Azure Functions platform
3 | # Manually managing azure-functions-worker may cause unexpected issues
4 |
5 | azure-functions>=1.24.0b1
--------------------------------------------------------------------------------
/samples/chat/typescript/.funcignore:
--------------------------------------------------------------------------------
1 | *.js.map
2 | *.ts
3 | .git*
4 | .vscode
5 | __azurite_db*__.json
6 | __blobstorage__
7 | __queuestorage__
8 | local.settings.json
9 | test
10 | tsconfig.json
--------------------------------------------------------------------------------
/samples/chat/typescript/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | },
8 | "extensionBundle": {
9 | "id": "Microsoft.Azure.Functions.ExtensionBundle.Preview",
10 | "version": "[4.*, 5.0.0)"
11 | }
12 | }
--------------------------------------------------------------------------------
/samples/chat/typescript/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "AzureWebJobsFeatureFlags": "EnableWorkerIndexing",
6 | "FUNCTIONS_WORKER_RUNTIME": "node",
7 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
8 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo"
9 | }
10 | }
--------------------------------------------------------------------------------
/samples/chat/typescript/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "chat",
3 | "version": "1.0.0",
4 | "description": "",
5 | "scripts": {
6 | "build": "tsc",
7 | "watch": "tsc -w",
8 | "prestart": "npm run build",
9 | "start": "func start",
10 | "test": "echo \"No tests yet...\""
11 | },
12 | "dependencies": {
13 | "@azure/functions": "^4.0.0"
14 | },
15 | "devDependencies": {
16 | "@types/node": "^18.x",
17 | "typescript": "^4.0.0",
18 | "rimraf": "^5.0.0"
19 | },
20 | "main": "dist/src/functions/*.js"
21 | }
--------------------------------------------------------------------------------
/samples/chat/typescript/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es6",
5 | "outDir": "dist",
6 | "rootDir": ".",
7 | "sourceMap": true,
8 | "strict": false
9 | }
10 | }
--------------------------------------------------------------------------------
/samples/embeddings/csharp-legacy/EmbeddingsLegacy.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net8.0
4 | v4
5 | enable
6 | 11.0
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
17 |
18 |
19 |
20 | PreserveNewest
21 |
22 |
23 | PreserveNewest
24 | Never
25 |
26 |
27 |
--------------------------------------------------------------------------------
/samples/embeddings/csharp-legacy/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | }
8 | }
--------------------------------------------------------------------------------
/samples/embeddings/csharp-legacy/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "FUNCTIONS_WORKER_RUNTIME": "dotnet",
6 | "FUNCTIONS_INPROC_NET8_ENABLED": "1",
7 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
8 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo",
9 | "EMBEDDING_MODEL_DEPLOYMENT_NAME": "text-embedding-ada-002"
10 | }
11 | }
--------------------------------------------------------------------------------
/samples/embeddings/csharp-ooproc/Embeddings/Program.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Azure.Functions.Worker;
5 | using Microsoft.Extensions.DependencyInjection;
6 | using Microsoft.Extensions.Hosting;
7 |
8 | var host = new HostBuilder()
9 | .ConfigureFunctionsWebApplication()
10 | .ConfigureServices(services =>
11 | {
12 | services.AddApplicationInsightsTelemetryWorkerService();
13 | services.ConfigureFunctionsApplicationInsights();
14 | })
15 | .Build();
16 |
17 | host.Run();
18 |
--------------------------------------------------------------------------------
/samples/embeddings/csharp-ooproc/Embeddings/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "Embeddings": {
4 | "commandName": "Project",
5 | "commandLineArgs": "--port 7071",
6 | "launchBrowser": false
7 | }
8 | }
9 | }
--------------------------------------------------------------------------------
/samples/embeddings/csharp-ooproc/Embeddings/Properties/serviceDependencies.json:
--------------------------------------------------------------------------------
1 | {
2 | "dependencies": {
3 | "appInsights1": {
4 | "type": "appInsights"
5 | },
6 | "storage1": {
7 | "type": "storage",
8 | "connectionId": "AzureWebJobsStorage"
9 | }
10 | }
11 | }
--------------------------------------------------------------------------------
/samples/embeddings/csharp-ooproc/Embeddings/Properties/serviceDependencies.local.json:
--------------------------------------------------------------------------------
1 | {
2 | "dependencies": {
3 | "appInsights1": {
4 | "type": "appInsights.sdk"
5 | },
6 | "storage1": {
7 | "type": "storage.emulator",
8 | "connectionId": "AzureWebJobsStorage"
9 | }
10 | }
11 | }
--------------------------------------------------------------------------------
/samples/embeddings/csharp-ooproc/Embeddings/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | }
8 | }
--------------------------------------------------------------------------------
/samples/embeddings/csharp-ooproc/Embeddings/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
6 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
7 | "EMBEDDING_MODEL_DEPLOYMENT_NAME": "text-embedding-ada-002"
8 | }
9 | }
--------------------------------------------------------------------------------
/samples/embeddings/demo.http:
--------------------------------------------------------------------------------
1 | ### Embeddings from Raw Text
2 | POST http://localhost:7071/api/embeddings
3 | Content-Type: application/json
4 |
5 | {"rawText": "Enter raw text here for embedding generation."}
6 |
7 |
8 | ### Embeddings from File
9 | POST http://localhost:7071/api/embeddings-from-file
10 | Content-Type: application/json
11 |
12 | {"filePath": "D:\\test\\test_file.txt"}
13 |
14 | ### Embeddings from Url
15 | POST http://localhost:7071/api/embeddings-from-url
16 | Content-Type: application/json
17 |
18 | {"url":"https://url/test/test_file.txt"}
--------------------------------------------------------------------------------
/samples/embeddings/java/.funcignore:
--------------------------------------------------------------------------------
1 | local.settings.json
--------------------------------------------------------------------------------
/samples/embeddings/java/extensions.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net80
4 |
5 | **
6 | target/azure-functions/azfs-java-openai-sample/bin
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/samples/embeddings/java/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | }
8 | }
--------------------------------------------------------------------------------
/samples/embeddings/java/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "FUNCTIONS_WORKER_RUNTIME": "java",
6 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
7 | "EMBEDDING_MODEL_DEPLOYMENT_NAME": "text-embedding-ada-002"
8 | }
9 | }
--------------------------------------------------------------------------------
/samples/embeddings/javascript/.funcignore:
--------------------------------------------------------------------------------
1 | *.js.map
2 | *.ts
3 | .git*
4 | .vscode
5 | __azurite_db*__.json
6 | __blobstorage__
7 | __queuestorage__
8 | local.settings.json
9 | test
10 | tsconfig.json
--------------------------------------------------------------------------------
/samples/embeddings/javascript/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | },
8 | "extensionBundle": {
9 | "id": "Microsoft.Azure.Functions.ExtensionBundle.Preview",
10 | "version": "[4.*, 5.0.0)"
11 | }
12 | }
--------------------------------------------------------------------------------
/samples/embeddings/javascript/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "AzureWebJobsFeatureFlags": "EnableWorkerIndexing",
6 | "FUNCTIONS_WORKER_RUNTIME": "node",
7 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
8 | "EMBEDDING_MODEL_DEPLOYMENT_NAME": "text-embedding-ada-002"
9 | }
10 | }
--------------------------------------------------------------------------------
/samples/embeddings/javascript/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "embeddings",
3 | "version": "1.0.0",
4 | "description": "",
5 | "scripts": {
6 | "start": "func start",
7 | "test": "echo \"No tests yet...\""
8 | },
9 | "dependencies": {
10 | "@azure/functions": "^4.0.0"
11 | },
12 | "devDependencies": {
13 | },
14 | "main": "src/*.js"
15 | }
--------------------------------------------------------------------------------
/samples/embeddings/powershell/.funcignore:
--------------------------------------------------------------------------------
1 | .git*
2 | .vscode
3 | __azurite_db*__.json
4 | __blobstorage__
5 | __queuestorage__
6 | local.settings.json
7 | test
--------------------------------------------------------------------------------
/samples/embeddings/powershell/GenerateEmbeddings/function.json:
--------------------------------------------------------------------------------
1 | {
2 | "bindings": [
3 | {
4 | "authLevel": "function",
5 | "type": "httpTrigger",
6 | "direction": "in",
7 | "name": "Request",
8 | "route": "embeddings",
9 | "methods": [
10 | "post"
11 | ]
12 | },
13 | {
14 | "type": "http",
15 | "direction": "out",
16 | "name": "Response"
17 | },
18 | {
19 | "name": "Embeddings",
20 | "type": "embeddings",
21 | "direction": "in",
22 | "inputType": "RawText",
23 | "input": "{rawText}",
24 | "embeddingsModel": "%EMBEDDING_MODEL_DEPLOYMENT_NAME%"
25 | }
26 | ]
27 | }
--------------------------------------------------------------------------------
/samples/embeddings/powershell/GenerateEmbeddings/run.ps1:
--------------------------------------------------------------------------------
1 | using namespace System.Net
2 |
3 | param($Request, $TriggerMetadata, $Embeddings)
4 |
5 | $input = $Request.Body.RawText
6 |
7 | Write-Host "Received $($Embeddings.Count) embedding(s) for input text containing $($input.Length) characters."
8 |
9 | Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
10 | StatusCode = [HttpStatusCode]::Accepted
11 | })
--------------------------------------------------------------------------------
/samples/embeddings/powershell/GetEmbeddingsFilePath/function.json:
--------------------------------------------------------------------------------
1 | {
2 | "bindings": [
3 | {
4 | "authLevel": "function",
5 | "type": "httpTrigger",
6 | "direction": "in",
7 | "name": "Request",
8 | "route": "embeddings-from-file",
9 | "methods": [
10 | "post"
11 | ]
12 | },
13 | {
14 | "type": "http",
15 | "direction": "out",
16 | "name": "Response"
17 | },
18 | {
19 | "name": "Embeddings",
20 | "type": "embeddings",
21 | "direction": "in",
22 | "inputType": "FilePath",
23 | "input": "{filePath}",
24 | "maxChunkLength": 512,
25 | "embeddingsModel": "%EMBEDDING_MODEL_DEPLOYMENT_NAME%"
26 | }
27 | ]
28 | }
--------------------------------------------------------------------------------
/samples/embeddings/powershell/GetEmbeddingsFilePath/run.ps1:
--------------------------------------------------------------------------------
1 | using namespace System.Net
2 |
3 | param($Request, $TriggerMetadata, $Embeddings)
4 |
5 | Write-Host "Received $($Embeddings.Count) embedding(s) for input file '$($Request.Body.FilePath)'."
6 |
7 | Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
8 | StatusCode = [HttpStatusCode]::Accepted
9 | })
--------------------------------------------------------------------------------
/samples/embeddings/powershell/GetEmbeddingsURL/function.json:
--------------------------------------------------------------------------------
1 | {
2 | "bindings": [
3 | {
4 | "authLevel": "function",
5 | "type": "httpTrigger",
6 | "direction": "in",
7 | "name": "Request",
8 | "route": "embeddings-from-url",
9 | "methods": [
10 | "post"
11 | ]
12 | },
13 | {
14 | "type": "http",
15 | "direction": "out",
16 | "name": "Response"
17 | },
18 | {
19 | "name": "Embeddings",
20 | "type": "embeddings",
21 | "direction": "in",
22 | "inputType": "Url",
23 | "input": "{url}",
24 | "maxChunkLength": 512,
25 | "embeddingsModel": "%EMBEDDING_MODEL_DEPLOYMENT_NAME%"
26 | }
27 | ]
28 | }
--------------------------------------------------------------------------------
/samples/embeddings/powershell/GetEmbeddingsURL/run.ps1:
--------------------------------------------------------------------------------
1 | using namespace System.Net
2 |
3 | param($Request, $TriggerMetadata, $Embeddings)
4 |
5 | Write-Host "Received $($Embeddings.Count) embedding(s) for input url '$($Request.Body.Url)'."
6 |
7 | Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
8 | StatusCode = [HttpStatusCode]::Accepted
9 | })
--------------------------------------------------------------------------------
/samples/embeddings/powershell/extensions.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net80
4 |
5 | **
6 | bin
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/samples/embeddings/powershell/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | },
8 | "extensions": {
9 | "openai": {
10 | "storageConnectionName": "AzureWebJobsStorage",
11 | "collectionName": "ChatBotRequests"
12 | }
13 | }
14 | }
--------------------------------------------------------------------------------
/samples/embeddings/powershell/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "FUNCTIONS_WORKER_RUNTIME_VERSION": "7.2",
6 | "FUNCTIONS_WORKER_RUNTIME": "powershell",
7 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
8 | "EMBEDDING_MODEL_DEPLOYMENT_NAME": "text-embedding-ada-002"
9 | }
10 | }
--------------------------------------------------------------------------------
/samples/embeddings/powershell/profile.ps1:
--------------------------------------------------------------------------------
1 | # Azure Functions profile.ps1
2 | #
3 | # This profile.ps1 will get executed every "cold start" of your Function App.
4 | # "cold start" occurs when:
5 | #
6 | # * A Function App starts up for the very first time
7 | # * A Function App starts up after being de-allocated due to inactivity
8 | #
9 | # You can define helper functions, run commands, or specify environment variables
10 | # NOTE: any variables defined that are not environment variables will get reset after the first execution
11 |
12 | # Authenticate with Azure PowerShell using MSI.
13 | # Remove this if you are not planning on using MSI or Azure PowerShell.
14 | if ($env:MSI_SECRET) {
15 | Disable-AzContextAutosave -Scope Process | Out-Null
16 | Connect-AzAccount -Identity
17 | }
18 |
19 | # Uncomment the next line to enable legacy AzureRm alias in Azure PowerShell.
20 | # Enable-AzureRmAlias
21 |
22 | # You can also define functions or aliases that can be referenced in any of your PowerShell functions.
23 |
--------------------------------------------------------------------------------
/samples/embeddings/powershell/requirements.psd1:
--------------------------------------------------------------------------------
1 | # This file enables modules to be automatically managed by the Functions service.
2 | # See https://aka.ms/functionsmanageddependency for additional information.
3 | #
4 | @{
5 | # For latest supported version, go to 'https://www.powershellgallery.com/packages/Az'. Uncomment the next line and replace the MAJOR_VERSION, e.g., 'Az' = '5.*'
6 | # 'Az' = 'MAJOR_VERSION.*'
7 | }
--------------------------------------------------------------------------------
/samples/embeddings/python/.funcignore:
--------------------------------------------------------------------------------
1 | .git*
2 | .vscode
3 | __azurite_db*__.json
4 | __blobstorage__
5 | __queuestorage__
6 | local.settings.json
7 | test
8 | .venv
--------------------------------------------------------------------------------
/samples/embeddings/python/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | },
8 | "extensionBundle": {
9 | "id": "Microsoft.Azure.Functions.ExtensionBundle.Preview",
10 | "version": "[4.*, 5.0.0)"
11 | }
12 | }
--------------------------------------------------------------------------------
/samples/embeddings/python/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "AzureWebJobsFeatureFlags": "EnableWorkerIndexing",
6 | "FUNCTIONS_WORKER_RUNTIME": "python",
7 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
8 | "EMBEDDING_MODEL_DEPLOYMENT_NAME": "text-embedding-ada-002",
9 | "PYTHON_ISOLATE_WORKER_DEPENDENCIES": "1"
10 | }
11 | }
--------------------------------------------------------------------------------
/samples/embeddings/python/requirements.txt:
--------------------------------------------------------------------------------
1 | # DO NOT include azure-functions-worker in this file
2 | # The Python Worker is managed by Azure Functions platform
3 | # Manually managing azure-functions-worker may cause unexpected issues
4 |
5 | azure-functions>=1.24.0b1
--------------------------------------------------------------------------------
/samples/embeddings/typescript/.funcignore:
--------------------------------------------------------------------------------
1 | *.js.map
2 | *.ts
3 | .git*
4 | .vscode
5 | __azurite_db*__.json
6 | __blobstorage__
7 | __queuestorage__
8 | local.settings.json
9 | test
10 | tsconfig.json
--------------------------------------------------------------------------------
/samples/embeddings/typescript/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | },
8 | "extensionBundle": {
9 | "id": "Microsoft.Azure.Functions.ExtensionBundle.Preview",
10 | "version": "[4.*, 5.0.0)"
11 | }
12 | }
--------------------------------------------------------------------------------
/samples/embeddings/typescript/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "AzureWebJobsFeatureFlags": "EnableWorkerIndexing",
6 | "FUNCTIONS_WORKER_RUNTIME": "node",
7 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
8 | "EMBEDDING_MODEL_DEPLOYMENT_NAME": "text-embedding-ada-002"
9 | }
10 | }
--------------------------------------------------------------------------------
/samples/embeddings/typescript/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "embeddings",
3 | "version": "1.0.0",
4 | "description": "",
5 | "scripts": {
6 | "build": "tsc",
7 | "watch": "tsc -w",
8 | "prestart": "npm run build",
9 | "start": "func start",
10 | "test": "echo \"No tests yet...\""
11 | },
12 | "dependencies": {
13 | "@azure/functions": "^4.0.0"
14 | },
15 | "devDependencies": {
16 | "@types/node": "^18.x",
17 | "typescript": "^4.0.0",
18 | "rimraf": "^5.0.0"
19 | },
20 | "main": "dist/src/*.js"
21 | }
--------------------------------------------------------------------------------
/samples/embeddings/typescript/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es6",
5 | "outDir": "dist",
6 | "rootDir": ".",
7 | "sourceMap": true,
8 | "strict": false
9 | }
10 | }
--------------------------------------------------------------------------------
/samples/rag-aisearch/csharp-legacy/SemanticAISearchEmbeddingsLegacy.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net8.0
4 | v4
5 | enable
6 | 11.0
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | PreserveNewest
18 |
19 |
20 | PreserveNewest
21 | Never
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/samples/rag-aisearch/csharp-legacy/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | },
8 | "extensions": {
9 | "openai": {
10 | "searchProvider": {
11 | "type": "azureAiSearch",
12 | "isSemanticSearchEnabled": true,
13 | "useSemanticCaptions": true,
14 | "vectorSearchDimensions": 1536
15 | }
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/samples/rag-aisearch/csharp-legacy/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "FUNCTIONS_WORKER_RUNTIME": "dotnet",
6 | "FUNCTIONS_INPROC_NET8_ENABLED": "1",
7 | "AISearchEndpoint": "https://.search.windows.net",
8 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
9 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo",
10 | "EMBEDDING_MODEL_DEPLOYMENT_NAME": "text-embedding-ada-002"
11 | }
12 | }
--------------------------------------------------------------------------------
/samples/rag-aisearch/csharp-ooproc/Program.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Azure.Functions.Worker;
5 | using Microsoft.Extensions.DependencyInjection;
6 | using Microsoft.Extensions.Hosting;
7 |
8 | var host = new HostBuilder()
9 | .ConfigureFunctionsWebApplication()
10 | .ConfigureServices(services =>
11 | {
12 | services.AddApplicationInsightsTelemetryWorkerService();
13 | services.ConfigureFunctionsApplicationInsights();
14 | })
15 | .Build();
16 |
17 | host.Run();
18 |
--------------------------------------------------------------------------------
/samples/rag-aisearch/csharp-ooproc/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | },
8 | "extensions": {
9 | "openai": {
10 | "searchProvider": {
11 | "type": "azureAiSearch",
12 | "isSemanticSearchEnabled": true,
13 | "useSemanticCaptions": true,
14 | "vectorSearchDimensions": 1536
15 | }
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/samples/rag-aisearch/csharp-ooproc/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
6 | "AISearchEndpoint": "https://.search.windows.net",
7 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
8 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo",
9 | "EMBEDDING_MODEL_DEPLOYMENT_NAME": "text-embedding-ada-002"
10 | }
11 | }
--------------------------------------------------------------------------------
/samples/rag-aisearch/demo.http:
--------------------------------------------------------------------------------
1 | ### Ingest first file into database
2 |
3 | POST http://localhost:7071/api/IngestFile
4 | Content-Type: application/json
5 |
6 | {"url":"https://url/test/test_file.txt"}
7 |
8 | ### Ingest second file into database
9 | POST http://localhost:7071/api/IngestFile
10 | Content-Type: application/json
11 |
12 | {"url":"https://url/test/test_file.txt"}
13 |
14 |
15 | ### Send a search query (Example #1)
16 | POST http://localhost:7071/api/PromptFile
17 | Content-Type: application/json
18 |
19 | {"prompt":"INSERT PROMPT HERE."}
20 |
21 |
22 | ### Send a search query (Example #2)
23 | POST http://localhost:7071/api/PromptFile
24 | Content-Type: application/json
25 |
26 | {"prompt":"INSERT PROMPT HERE."}
--------------------------------------------------------------------------------
/samples/rag-aisearch/java/.funcignore:
--------------------------------------------------------------------------------
1 | local.settings.json
--------------------------------------------------------------------------------
/samples/rag-aisearch/java/extensions.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net80
4 |
5 | **
6 | target/azure-functions/azfs-java-openai-sample/bin
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/samples/rag-aisearch/java/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | },
8 | "extensions": {
9 | "openai": {
10 | "searchProvider": {
11 | "type": "azureAiSearch",
12 | "isSemanticSearchEnabled": true,
13 | "useSemanticCaptions": true,
14 | "vectorSearchDimensions": 1536
15 | }
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/samples/rag-aisearch/java/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "FUNCTIONS_WORKER_RUNTIME": "java",
6 | "AISearchEndpoint": "https://.search.windows.net",
7 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
8 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo",
9 | "EMBEDDING_MODEL_DEPLOYMENT_NAME": "text-embedding-ada-002"
10 | }
11 | }
--------------------------------------------------------------------------------
/samples/rag-aisearch/javascript/.funcignore:
--------------------------------------------------------------------------------
1 | *.js.map
2 | *.ts
3 | .git*
4 | .vscode
5 | __azurite_db*__.json
6 | __blobstorage__
7 | __queuestorage__
8 | local.settings.json
9 | test
10 | tsconfig.json
--------------------------------------------------------------------------------
/samples/rag-aisearch/javascript/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | },
8 | "extensionBundle": {
9 | "id": "Microsoft.Azure.Functions.ExtensionBundle.Preview",
10 | "version": "[4.*, 5.0.0)"
11 | },
12 | "extensions": {
13 | "openai": {
14 | "searchProvider": {
15 | "type": "azureAiSearch",
16 | "isSemanticSearchEnabled": true,
17 | "useSemanticCaptions": true,
18 | "vectorSearchDimensions": 1536
19 | }
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/samples/rag-aisearch/javascript/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "AzureWebJobsFeatureFlags": "EnableWorkerIndexing",
6 | "FUNCTIONS_WORKER_RUNTIME": "node",
7 | "AISearchEndpoint": "https://.search.windows.net",
8 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
9 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo",
10 | "EMBEDDING_MODEL_DEPLOYMENT_NAME": "text-embedding-ada-002"
11 | }
12 | }
--------------------------------------------------------------------------------
/samples/rag-aisearch/javascript/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "rag-aisearch",
3 | "version": "1.0.0",
4 | "description": "",
5 | "scripts": {
6 | "start": "func start",
7 | "test": "echo \"No tests yet...\""
8 | },
9 | "dependencies": {
10 | "@azure/functions": "^4.0.0"
11 | },
12 | "devDependencies": {
13 | },
14 | "main": "src/*.js"
15 | }
--------------------------------------------------------------------------------
/samples/rag-aisearch/powershell/.funcignore:
--------------------------------------------------------------------------------
1 | .git*
2 | .vscode
3 | __azurite_db*__.json
4 | __blobstorage__
5 | __queuestorage__
6 | local.settings.json
7 | test
--------------------------------------------------------------------------------
/samples/rag-aisearch/powershell/IngestFile/function.json:
--------------------------------------------------------------------------------
1 | {
2 | "bindings": [
3 | {
4 | "authLevel": "function",
5 | "type": "httpTrigger",
6 | "direction": "in",
7 | "name": "Request",
8 | "methods": [
9 | "post"
10 | ]
11 | },
12 | {
13 | "type": "http",
14 | "direction": "out",
15 | "name": "Response"
16 | },
17 | {
18 | "name": "EmbeddingsStoreOutput",
19 | "type": "embeddingsStore",
20 | "direction": "out",
21 | "input": "{url}",
22 | "inputType": "Url",
23 | "connectionName": "AISearchEndpoint",
24 | "collection": "openai-index",
25 | "embeddingsModel": "%EMBEDDING_MODEL_DEPLOYMENT_NAME%"
26 | }
27 | ]
28 | }
--------------------------------------------------------------------------------
/samples/rag-aisearch/powershell/IngestFile/run.ps1:
--------------------------------------------------------------------------------
1 | using namespace System.Net
2 |
3 | param($Request, $TriggerMetadata)
4 |
5 | $ErrorActionPreference = 'Stop'
6 |
7 | $inputJson = $Request.Body
8 |
9 | if (-not $inputJson -or -not $inputJson.Url) {
10 | throw 'Invalid request body. Make sure that you pass in {\"url\": value } as the request body.'
11 | }
12 |
13 | $uri = [URI]$inputJson.Url
14 | $filename = [System.IO.Path]::GetFileName($uri.AbsolutePath)
15 |
16 |
17 | Push-OutputBinding -Name EmbeddingsStoreOutput -Value @{
18 | "title" = $filename
19 | }
20 |
21 | $response = @{
22 | "status" = "success"
23 | "title" = $filename
24 | }
25 |
26 | Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
27 | StatusCode = [HttpStatusCode]::OK
28 | Body = $response
29 | Headers = @{
30 | "Content-Type" = "application/json"
31 | }
32 | })
--------------------------------------------------------------------------------
/samples/rag-aisearch/powershell/PromptFile/function.json:
--------------------------------------------------------------------------------
1 | {
2 | "bindings": [
3 | {
4 | "authLevel": "function",
5 | "type": "httpTrigger",
6 | "direction": "in",
7 | "name": "Request",
8 | "methods": [
9 | "post"
10 | ]
11 | },
12 | {
13 | "type": "http",
14 | "direction": "out",
15 | "name": "Response"
16 | },
17 | {
18 | "name": "SemanticSearchInput",
19 | "type": "semanticSearch",
20 | "direction": "in",
21 | "connectionName": "AISearchEndpoint",
22 | "collection": "openai-index",
23 | "query": "{prompt}",
24 | "chatModel": "%CHAT_MODEL_DEPLOYMENT_NAME%",
25 | "embeddingsModel": "%EMBEDDING_MODEL_DEPLOYMENT_NAME%"
26 | }
27 | ]
28 | }
--------------------------------------------------------------------------------
/samples/rag-aisearch/powershell/PromptFile/run.ps1:
--------------------------------------------------------------------------------
1 | using namespace System.Net
2 |
3 | param($Request, $TriggerMetadata, $SemanticSearchInput)
4 |
5 | Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
6 | StatusCode = [HttpStatusCode]::OK
7 | Body = $SemanticSearchInput.Response
8 | })
--------------------------------------------------------------------------------
/samples/rag-aisearch/powershell/extensions.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net80
4 |
5 | **
6 | bin
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/samples/rag-aisearch/powershell/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | },
8 | "extensions": {
9 | "openai": {
10 | "searchProvider": {
11 | "type": "azureAiSearch",
12 | "isSemanticSearchEnabled": true,
13 | "useSemanticCaptions": true,
14 | "vectorSearchDimensions": 1536,
15 | "searchAPIKeySetting": "SearchAPIKey"
16 | }
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/samples/rag-aisearch/powershell/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "FUNCTIONS_WORKER_RUNTIME": "powershell",
6 | "FUNCTIONS_WORKER_RUNTIME_VERSION": "7.2",
7 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
8 | "AISearchEndpoint": "https://.search.windows.net",
9 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo",
10 | "EMBEDDING_MODEL_DEPLOYMENT_NAME": "text-embedding-ada-002"
11 | }
12 | }
--------------------------------------------------------------------------------
/samples/rag-aisearch/powershell/profile.ps1:
--------------------------------------------------------------------------------
1 | # Azure Functions profile.ps1
2 | #
3 | # This profile.ps1 will get executed every "cold start" of your Function App.
4 | # "cold start" occurs when:
5 | #
6 | # * A Function App starts up for the very first time
7 | # * A Function App starts up after being de-allocated due to inactivity
8 | #
9 | # You can define helper functions, run commands, or specify environment variables
10 | # NOTE: any variables defined that are not environment variables will get reset after the first execution
11 |
12 | # Authenticate with Azure PowerShell using MSI.
13 | # Remove this if you are not planning on using MSI or Azure PowerShell.
14 | if ($env:MSI_SECRET) {
15 | Disable-AzContextAutosave -Scope Process | Out-Null
16 | Connect-AzAccount -Identity
17 | }
18 |
19 | # Uncomment the next line to enable legacy AzureRm alias in Azure PowerShell.
20 | # Enable-AzureRmAlias
21 |
22 | # You can also define functions or aliases that can be referenced in any of your PowerShell functions.
23 |
--------------------------------------------------------------------------------
/samples/rag-aisearch/powershell/requirements.psd1:
--------------------------------------------------------------------------------
1 | # This file enables modules to be automatically managed by the Functions service.
2 | # See https://aka.ms/functionsmanageddependency for additional information.
3 | #
4 | @{
5 | # For latest supported version, go to 'https://www.powershellgallery.com/packages/Az'. Uncomment the next line and replace the MAJOR_VERSION, e.g., 'Az' = '5.*'
6 | # 'Az' = 'MAJOR_VERSION.*'
7 | }
--------------------------------------------------------------------------------
/samples/rag-aisearch/python/.funcignore:
--------------------------------------------------------------------------------
1 | .git*
2 | .vscode
3 | __azurite_db*__.json
4 | __blobstorage__
5 | __queuestorage__
6 | local.settings.json
7 | test
8 | .venv
--------------------------------------------------------------------------------
/samples/rag-aisearch/python/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | },
8 | "extensionBundle": {
9 | "id": "Microsoft.Azure.Functions.ExtensionBundle.Preview",
10 | "version": "[4.*, 5.0.0)"
11 | },
12 | "extensions": {
13 | "openai": {
14 | "searchProvider": {
15 | "type": "azureAiSearch",
16 | "isSemanticSearchEnabled": true,
17 | "useSemanticCaptions": true,
18 | "vectorSearchDimensions": 1536
19 | }
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/samples/rag-aisearch/python/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "AzureWebJobsFeatureFlags": "EnableWorkerIndexing",
6 | "FUNCTIONS_WORKER_RUNTIME": "python",
7 | "AISearchEndpoint": "https://.search.windows.net",
8 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
9 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo",
10 | "EMBEDDING_MODEL_DEPLOYMENT_NAME": "text-embedding-ada-002",
11 | "PYTHON_ISOLATE_WORKER_DEPENDENCIES": "1"
12 | }
13 | }
--------------------------------------------------------------------------------
/samples/rag-aisearch/python/requirements.txt:
--------------------------------------------------------------------------------
1 | # DO NOT include azure-functions-worker in this file
2 | # The Python Worker is managed by Azure Functions platform
3 | # Manually managing azure-functions-worker may cause unexpected issues
4 |
5 | azure-functions>=1.24.0b1
--------------------------------------------------------------------------------
/samples/rag-aisearch/typescript/.funcignore:
--------------------------------------------------------------------------------
1 | *.js.map
2 | *.ts
3 | .git*
4 | .vscode
5 | __azurite_db*__.json
6 | __blobstorage__
7 | __queuestorage__
8 | local.settings.json
9 | test
10 | tsconfig.json
--------------------------------------------------------------------------------
/samples/rag-aisearch/typescript/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | },
8 | "extensionBundle": {
9 | "id": "Microsoft.Azure.Functions.ExtensionBundle.Preview",
10 | "version": "[4.*, 5.0.0)"
11 | },
12 | "extensions": {
13 | "openai": {
14 | "searchProvider": {
15 | "type": "azureAiSearch",
16 | "isSemanticSearchEnabled": true,
17 | "useSemanticCaptions": true,
18 | "vectorSearchDimensions": 1536
19 | }
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/samples/rag-aisearch/typescript/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "AzureWebJobsFeatureFlags": "EnableWorkerIndexing",
6 | "FUNCTIONS_WORKER_RUNTIME": "node",
7 | "AISearchEndpoint": "https://.search.windows.net",
8 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
9 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo",
10 | "EMBEDDING_MODEL_DEPLOYMENT_NAME": "text-embedding-ada-002"
11 | }
12 | }
--------------------------------------------------------------------------------
/samples/rag-aisearch/typescript/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "rag-aisearch",
3 | "version": "1.0.0",
4 | "description": "",
5 | "scripts": {
6 | "build": "tsc",
7 | "watch": "tsc -w",
8 | "prestart": "npm run build",
9 | "start": "func start",
10 | "test": "echo \"No tests yet...\""
11 | },
12 | "dependencies": {
13 | "@azure/functions": "^4.0.0"
14 | },
15 | "devDependencies": {
16 | "@types/node": "^18.x",
17 | "typescript": "^4.0.0",
18 | "rimraf": "^5.0.0"
19 | },
20 | "main": "dist/src/*.js"
21 | }
--------------------------------------------------------------------------------
/samples/rag-aisearch/typescript/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es6",
5 | "outDir": "dist",
6 | "rootDir": ".",
7 | "sourceMap": true,
8 | "strict": false
9 | }
10 | }
--------------------------------------------------------------------------------
/samples/rag-cosmosdb-nosql/csharp-legacy/CosmosDBNoSQLSearchLegacy.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net8.0
4 | v4
5 | enable
6 | 11.0
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | PreserveNewest
18 |
19 |
20 | PreserveNewest
21 | Never
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/samples/rag-cosmosdb-nosql/csharp-legacy/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | },
8 | "extensions": {
9 | "openai": {
10 | "searchProvider": {
11 | "type": "cosmosDBNoSqlSearch",
12 | "applicationName": "openai-functions-nosql",
13 | "vectorDataType": "float32",
14 | "vectorDimensions": 1536,
15 | "vectorDistanceFunction": "cosine",
16 | "vectorIndexType": "quantizedFlat",
17 | "databaseName": "openai-extension-db",
18 | "databaseThroughput": 5000,
19 | "containerThroughput": 5000,
20 | "embeddingKey": "/embedding",
21 | "textKey": "/text",
22 | "whereFilterClause": "",
23 | "limitOffsetFilterClause": ""
24 | }
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/samples/rag-cosmosdb-nosql/csharp-legacy/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "FUNCTIONS_WORKER_RUNTIME": "dotnet",
6 | "FUNCTIONS_INPROC_NET8_ENABLED": "1",
7 | "CosmosDBNoSqlEndpoint": "https://.documents.azure.com:443/",
8 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
9 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo",
10 | "EMBEDDING_MODEL_DEPLOYMENT_NAME": "text-embedding-ada-002"
11 | }
12 | }
--------------------------------------------------------------------------------
/samples/rag-cosmosdb-nosql/csharp-ooproc/Program.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Azure.Functions.Worker;
5 | using Microsoft.Extensions.DependencyInjection;
6 | using Microsoft.Extensions.Hosting;
7 |
8 | var host = new HostBuilder()
9 | .ConfigureFunctionsWebApplication()
10 | .ConfigureServices(services =>
11 | {
12 | services.AddApplicationInsightsTelemetryWorkerService();
13 | services.ConfigureFunctionsApplicationInsights();
14 | })
15 | .Build();
16 |
17 | host.Run();
18 |
--------------------------------------------------------------------------------
/samples/rag-cosmosdb-nosql/csharp-ooproc/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | },
8 | "extensions": {
9 | "openai": {
10 | "searchProvider": {
11 | "type": "cosmosDBNoSqlSearch",
12 | "applicationName": "openai-functions-nosql",
13 | "vectorDataType": "float32",
14 | "vectorDimensions": 1536,
15 | "vectorDistanceFunction": "cosine",
16 | "vectorIndexType": "quantizedFlat",
17 | "databaseName": "openai-extension-db",
18 | "databaseThroughput": 5000,
19 | "containerThroughput": 5000,
20 | "embeddingKey": "/embedding",
21 | "textKey": "/text",
22 | "whereFilterClause": "",
23 | "limitOffsetFilterClause": ""
24 | }
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/samples/rag-cosmosdb-nosql/csharp-ooproc/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
6 | "CosmosDBNoSqlEndpoint": "https://.documents.azure.com:443/",
7 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
8 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo",
9 | "EMBEDDING_MODEL_DEPLOYMENT_NAME": "text-embedding-ada-002"
10 | }
11 | }
--------------------------------------------------------------------------------
/samples/rag-cosmosdb-nosql/demo.http:
--------------------------------------------------------------------------------
1 | ### Ingest first file into database
2 |
3 | POST http://localhost:7071/api/IngestFile
4 | Content-Type: application/json
5 |
6 | {"Url":"https://url/test/test_file.txt"}
7 |
8 |
9 | ### Ingest second file into database
10 | POST http://localhost:7071/api/IngestFile
11 | Content-Type: application/json
12 |
13 | {"Url":"https://url/test/test_file.txt"}
14 |
15 |
16 | ### Send a search query (Example #1)
17 | POST http://localhost:7071/api/PromptFile
18 | Content-Type: application/json
19 |
20 | {"Prompt":"INSERT PROMPT HERE"}
21 |
22 |
23 | ### Send a search query (Example #2)
24 | POST http://localhost:7071/api/PromptFile
25 | Content-Type: application/json
26 |
27 | {"Prompt":"INSERT PROMPT HERE"}
--------------------------------------------------------------------------------
/samples/rag-cosmosdb-nosql/java/.funcignore:
--------------------------------------------------------------------------------
1 | local.settings.json
--------------------------------------------------------------------------------
/samples/rag-cosmosdb-nosql/java/extensions.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net80
4 |
5 | **
6 | target/azure-functions/azfs-java-openai-sample/bin
7 |
8 |
9 |
10 |
12 |
13 |
14 |
15 |
17 |
19 |
20 |
--------------------------------------------------------------------------------
/samples/rag-cosmosdb-nosql/java/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | },
8 | "extensions": {
9 | "openai": {
10 | "searchProvider": {
11 | "type": "cosmosDBNoSqlSearch",
12 | "applicationName": "openai-functions-nosql",
13 | "vectorDataType": "float32",
14 | "vectorDimensions": 1536,
15 | "vectorDistanceFunction": "cosine",
16 | "vectorIndexType": "quantizedFlat",
17 | "databaseName": "openai-extension-db",
18 | "databaseThroughput": 5000,
19 | "containerThroughput": 5000,
20 | "embeddingKey": "/embedding",
21 | "textKey": "/text",
22 | "whereFilterClause": "",
23 | "limitOffsetFilterClause": ""
24 | }
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/samples/rag-cosmosdb-nosql/java/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "FUNCTIONS_WORKER_RUNTIME": "java",
6 | "CosmosDBNoSqlEndpoint": "https://.documents.azure.com:443/",
7 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
8 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo",
9 | "EMBEDDING_MODEL_DEPLOYMENT_NAME": "text-embedding-ada-002"
10 | }
11 | }
--------------------------------------------------------------------------------
/samples/rag-cosmosdb-nosql/javascript/.funcignore:
--------------------------------------------------------------------------------
1 | *.js.map
2 | *.ts
3 | .git*
4 | .vscode
5 | __azurite_db*__.json
6 | __blobstorage__
7 | __queuestorage__
8 | local.settings.json
9 | test
10 | tsconfig.json
--------------------------------------------------------------------------------
/samples/rag-cosmosdb-nosql/javascript/extensions.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net80
4 |
5 | **
6 | bin
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/samples/rag-cosmosdb-nosql/javascript/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | },
8 | "extensions": {
9 | "openai": {
10 | "searchProvider": {
11 | "type": "cosmosDBNoSqlSearch",
12 | "applicationName": "openai-functions-nosql",
13 | "vectorDataType": "float32",
14 | "vectorDimensions": 1536,
15 | "vectorDistanceFunction": "cosine",
16 | "vectorIndexType": "quantizedFlat",
17 | "databaseName": "openai-extension-db",
18 | "databaseThroughput": 5000,
19 | "containerThroughput": 5000,
20 | "embeddingKey": "/embedding",
21 | "textKey": "/text",
22 | "whereFilterClause": "",
23 | "limitOffsetFilterClause": ""
24 | }
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/samples/rag-cosmosdb-nosql/javascript/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "AzureWebJobsFeatureFlags": "EnableWorkerIndexing",
6 | "FUNCTIONS_WORKER_RUNTIME": "node",
7 | "CosmosDBNoSqlEndpoint": "https://.documents.azure.com:443/",
8 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
9 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo",
10 | "EMBEDDING_MODEL_DEPLOYMENT_NAME": "text-embedding-ada-002"
11 | }
12 | }
--------------------------------------------------------------------------------
/samples/rag-cosmosdb-nosql/javascript/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "rag-cosmosdbnosql",
3 | "version": "1.0.0",
4 | "description": "",
5 | "scripts": {
6 | "start": "func start",
7 | "test": "echo \"No tests yet...\""
8 | },
9 | "dependencies": {
10 | "@azure/functions": "^4.0.0"
11 | },
12 | "main": "src/*.js"
13 | }
14 |
--------------------------------------------------------------------------------
/samples/rag-cosmosdb-nosql/powershell/.funcignore:
--------------------------------------------------------------------------------
1 | .git*
2 | .vscode
3 | __azurite_db*__.json
4 | __blobstorage__
5 | __queuestorage__
6 | local.settings.json
7 | test
--------------------------------------------------------------------------------
/samples/rag-cosmosdb-nosql/powershell/IngestFile/function.json:
--------------------------------------------------------------------------------
1 | {
2 | "bindings": [
3 | {
4 | "authLevel": "function",
5 | "type": "httpTrigger",
6 | "direction": "in",
7 | "name": "Request",
8 | "methods": [
9 | "post"
10 | ]
11 | },
12 | {
13 | "type": "http",
14 | "direction": "out",
15 | "name": "Response"
16 | },
17 | {
18 | "name": "EmbeddingsStoreOutput",
19 | "type": "embeddingsStore",
20 | "direction": "out",
21 | "input": "{url}",
22 | "inputType": "Url",
23 | "connectionName": "CosmosDBNoSqlEndpoint",
24 | "collection": "openai-index",
25 | "embeddingsModel": "%EMBEDDING_MODEL_DEPLOYMENT_NAME%"
26 | }
27 | ]
28 | }
--------------------------------------------------------------------------------
/samples/rag-cosmosdb-nosql/powershell/IngestFile/run.ps1:
--------------------------------------------------------------------------------
1 | using namespace System.Net
2 |
3 | param($Request, $TriggerMetadata)
4 |
5 | $ErrorActionPreference = 'Stop'
6 |
7 | $inputJson = $Request.Body
8 |
9 | if (-not $inputJson -or -not $inputJson.Url) {
10 | throw 'Invalid request body. Make sure that you pass in {\"url\": value } as the request body.'
11 | }
12 |
13 | $uri = [URI]$inputJson.Url
14 | $filename = [System.IO.Path]::GetFileName($uri.AbsolutePath)
15 |
16 |
17 | Push-OutputBinding -Name EmbeddingsStoreOutput -Value @{
18 | "title" = $filename
19 | }
20 |
21 | $response = @{
22 | "status" = "success"
23 | "title" = $filename
24 | }
25 |
26 | Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
27 | StatusCode = [HttpStatusCode]::OK
28 | Body = $response
29 | Headers = @{
30 | "Content-Type" = "application/json"
31 | }
32 | })
--------------------------------------------------------------------------------
/samples/rag-cosmosdb-nosql/powershell/PromptFile/function.json:
--------------------------------------------------------------------------------
1 | {
2 | "bindings": [
3 | {
4 | "authLevel": "function",
5 | "type": "httpTrigger",
6 | "direction": "in",
7 | "name": "Request",
8 | "methods": [
9 | "post"
10 | ]
11 | },
12 | {
13 | "type": "http",
14 | "direction": "out",
15 | "name": "Response"
16 | },
17 | {
18 | "name": "SemanticSearchInput",
19 | "type": "semanticSearch",
20 | "direction": "in",
21 | "connectionName": "CosmosDBNoSqlEndpoint",
22 | "collection": "openai-index",
23 | "query": "{prompt}",
24 | "chatModel": "%CHAT_MODEL_DEPLOYMENT_NAME%",
25 | "embeddingsModel": "%EMBEDDING_MODEL_DEPLOYMENT_NAME%"
26 | }
27 | ]
28 | }
--------------------------------------------------------------------------------
/samples/rag-cosmosdb-nosql/powershell/PromptFile/run.ps1:
--------------------------------------------------------------------------------
1 | using namespace System.Net
2 |
3 | param($Request, $TriggerMetadata, $SemanticSearchInput)
4 |
5 | Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
6 | StatusCode = [HttpStatusCode]::OK
7 | Body = $SemanticSearchInput.Response
8 | })
--------------------------------------------------------------------------------
/samples/rag-cosmosdb-nosql/powershell/extensions.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net80
4 |
5 | **
6 | bin
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/samples/rag-cosmosdb-nosql/powershell/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | },
8 | "extensions": {
9 | "openai": {
10 | "searchProvider": {
11 | "type": "cosmosDBNoSqlSearch",
12 | "applicationName": "openai-functions-nosql",
13 | "vectorDataType": "float32",
14 | "vectorDimensions": 1536,
15 | "vectorDistanceFunction": "cosine",
16 | "vectorIndexType": "quantizedFlat",
17 | "databaseName": "openai-extension-db",
18 | "databaseThroughput": 5000,
19 | "containerThroughput": 5000,
20 | "embeddingKey": "/embedding",
21 | "textKey": "/text",
22 | "whereFilterClause": "",
23 | "limitOffsetFilterClause": ""
24 | }
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/samples/rag-cosmosdb-nosql/powershell/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "FUNCTIONS_WORKER_RUNTIME": "powershell",
6 | "FUNCTIONS_WORKER_RUNTIME_VERSION": "7.2",
7 | "CosmosDBNoSqlEndpoint": "https://.documents.azure.com:443/",
8 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
9 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo",
10 | "EMBEDDING_MODEL_DEPLOYMENT_NAME": "text-embedding-ada-002"
11 | }
12 | }
--------------------------------------------------------------------------------
/samples/rag-cosmosdb-nosql/powershell/profile.ps1:
--------------------------------------------------------------------------------
1 | # Azure Functions profile.ps1
2 | #
3 | # This profile.ps1 will get executed every "cold start" of your Function App.
4 | # "cold start" occurs when:
5 | #
6 | # * A Function App starts up for the very first time
7 | # * A Function App starts up after being de-allocated due to inactivity
8 | #
9 | # You can define helper functions, run commands, or specify environment variables
10 | # NOTE: any variables defined that are not environment variables will get reset after the first execution
11 |
12 | # Authenticate with Azure PowerShell using MSI.
13 | # Remove this if you are not planning on using MSI or Azure PowerShell.
14 | if ($env:MSI_SECRET) {
15 | Disable-AzContextAutosave -Scope Process | Out-Null
16 | Connect-AzAccount -Identity
17 | }
18 |
19 | # Uncomment the next line to enable legacy AzureRm alias in Azure PowerShell.
20 | # Enable-AzureRmAlias
21 |
22 | # You can also define functions or aliases that can be referenced in any of your PowerShell functions.
23 |
--------------------------------------------------------------------------------
/samples/rag-cosmosdb-nosql/powershell/requirements.psd1:
--------------------------------------------------------------------------------
1 | # This file enables modules to be automatically managed by the Functions service.
2 | # See https://aka.ms/functionsmanageddependency for additional information.
3 | #
4 | @{
5 | # For latest supported version, go to 'https://www.powershellgallery.com/packages/Az'. Uncomment the next line and replace the MAJOR_VERSION, e.g., 'Az' = '5.*'
6 | # 'Az' = 'MAJOR_VERSION.*'
7 | }
--------------------------------------------------------------------------------
/samples/rag-cosmosdb-nosql/python/extensions.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net80
4 |
5 | **
6 | bin
7 |
8 |
9 |
10 |
12 |
13 |
14 |
15 |
17 |
19 |
20 |
--------------------------------------------------------------------------------
/samples/rag-cosmosdb-nosql/python/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | },
8 | "extensions": {
9 | "openai": {
10 | "searchProvider": {
11 | "type": "cosmosDBNoSqlSearch",
12 | "applicationName": "openai-functions-nosql",
13 | "vectorDataType": "float32",
14 | "vectorDimensions": 1536,
15 | "vectorDistanceFunction": "cosine",
16 | "vectorIndexType": "quantizedFlat",
17 | "databaseName": "openai-extension-db",
18 | "databaseThroughput": 5000,
19 | "containerThroughput": 5000,
20 | "embeddingKey": "/embedding",
21 | "textKey": "/text",
22 | "whereFilterClause": "",
23 | "limitOffsetFilterClause": ""
24 | }
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/samples/rag-cosmosdb-nosql/python/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "AzureWebJobsFeatureFlags": "EnableWorkerIndexing",
6 | "FUNCTIONS_WORKER_RUNTIME": "python",
7 | "CosmosDBNoSqlEndpoint": "https://.documents.azure.com:443/",
8 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
9 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo",
10 | "EMBEDDING_MODEL_DEPLOYMENT_NAME": "text-embedding-ada-002",
11 | "PYTHON_ISOLATE_WORKER_DEPENDENCIES": "1"
12 | }
13 | }
--------------------------------------------------------------------------------
/samples/rag-cosmosdb-nosql/python/requirements.txt:
--------------------------------------------------------------------------------
1 | # DO NOT include azure-functions-worker in this file
2 | # The Python Worker is managed by Azure Functions platform
3 | # Manually managing azure-functions-worker may cause unexpected issues
4 |
5 | azure-functions>=1.24.0b1
--------------------------------------------------------------------------------
/samples/rag-cosmosdb-nosql/typescript/.funcignore:
--------------------------------------------------------------------------------
1 | *.js.map
2 | *.ts
3 | .git*
4 | .vscode
5 | __azurite_db*__.json
6 | __blobstorage__
7 | __queuestorage__
8 | local.settings.json
9 | test
10 | tsconfig.json
--------------------------------------------------------------------------------
/samples/rag-cosmosdb-nosql/typescript/extensions.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net80
4 |
5 | **
6 | bin
7 |
8 |
9 |
11 |
12 |
13 |
14 |
16 |
18 |
19 |
--------------------------------------------------------------------------------
/samples/rag-cosmosdb-nosql/typescript/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | },
8 | "extensions": {
9 | "openai": {
10 | "searchProvider": {
11 | "type": "cosmosDBNoSqlSearch",
12 | "applicationName": "openai-functions-nosql",
13 | "vectorDataType": "float32",
14 | "vectorDimensions": 1536,
15 | "vectorDistanceFunction": "cosine",
16 | "vectorIndexType": "quantizedFlat",
17 | "databaseName": "openai-extension-db",
18 | "databaseThroughput": 5000,
19 | "containerThroughput": 5000,
20 | "embeddingKey": "/embedding",
21 | "textKey": "/text",
22 | "whereFilterClause": "",
23 | "limitOffsetFilterClause": ""
24 | }
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/samples/rag-cosmosdb-nosql/typescript/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "AzureWebJobsFeatureFlags": "EnableWorkerIndexing",
6 | "FUNCTIONS_WORKER_RUNTIME": "node",
7 | "CosmosDBNoSqlEndpoint": "https://.documents.azure.com:443/",
8 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
9 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo",
10 | "EMBEDDING_MODEL_DEPLOYMENT_NAME": "text-embedding-ada-002"
11 | }
12 | }
--------------------------------------------------------------------------------
/samples/rag-cosmosdb-nosql/typescript/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "rag-cosmosdbnosql",
3 | "version": "1.0.0",
4 | "description": "",
5 | "scripts": {
6 | "build": "tsc",
7 | "watch": "tsc -w",
8 | "prestart": "npm run build",
9 | "start": "func start",
10 | "test": "echo \"No tests yet...\""
11 | },
12 | "dependencies": {
13 | "@azure/functions": "^4.0.0"
14 | },
15 | "devDependencies": {
16 | "@types/node": "^18.x",
17 | "rimraf": "^5.0.0",
18 | "typescript": "^4.0.0"
19 | },
20 | "main": "dist/src/*.js"
21 | }
22 |
--------------------------------------------------------------------------------
/samples/rag-cosmosdb-nosql/typescript/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es6",
5 | "outDir": "dist",
6 | "rootDir": ".",
7 | "sourceMap": true,
8 | "strict": false
9 | }
10 | }
--------------------------------------------------------------------------------
/samples/rag-cosmosdb/csharp-legacy/CosmosDBSearchLegacy.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net8.0
4 | v4
5 | enable
6 | 11.0
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | PreserveNewest
21 |
22 |
23 | PreserveNewest
24 | Never
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/samples/rag-cosmosdb/csharp-legacy/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | },
8 | "extensions": {
9 | "openai": {
10 | "searchProvider": {
11 | "type": "cosmosDBSearch",
12 | "vectorSearchDimensions": 1536,
13 | "numLists": 1,
14 | "kind": "vector-ivf",
15 | "similarity": "COS",
16 | "numberOfConnections": 16,
17 | "efConstruction": 64,
18 | "efSearch": 40,
19 | "applicationName": "functionsAppName",
20 | "embeddingKey": "embedding",
21 | "textKey": "text"
22 | }
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/samples/rag-cosmosdb/csharp-legacy/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "FUNCTIONS_WORKER_RUNTIME": "dotnet",
6 | "FUNCTIONS_INPROC_NET8_ENABLED": "1",
7 | "CosmosDBMongoVCoreConnectionString": "",
8 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
9 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo",
10 | "EMBEDDING_MODEL_DEPLOYMENT_NAME": "text-embedding-ada-002"
11 | }
12 | }
--------------------------------------------------------------------------------
/samples/rag-cosmosdb/csharp-ooproc/Program.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Azure.Functions.Worker;
5 | using Microsoft.Extensions.DependencyInjection;
6 | using Microsoft.Extensions.Hosting;
7 |
8 | var host = new HostBuilder()
9 | .ConfigureFunctionsWebApplication()
10 | .ConfigureServices(services =>
11 | {
12 | services.AddApplicationInsightsTelemetryWorkerService();
13 | services.ConfigureFunctionsApplicationInsights();
14 | })
15 | .Build();
16 |
17 | host.Run();
18 |
--------------------------------------------------------------------------------
/samples/rag-cosmosdb/csharp-ooproc/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | },
8 | "extensions": {
9 | "openai": {
10 | "searchProvider": {
11 | "type": "cosmosDBSearch",
12 | "vectorSearchDimensions": 1536,
13 | "numLists": 1,
14 | "kind": "vector-ivf",
15 | "similarity": "COS",
16 | "numberOfConnections": 16,
17 | "efConstruction": 64,
18 | "efSearch": 40,
19 | "applicationName": "functionsAppName",
20 | "embeddingKey": "embedding",
21 | "textKey": "text"
22 | }
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/samples/rag-cosmosdb/csharp-ooproc/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
6 | "CosmosDBMongoVCoreConnectionString": "",
7 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
8 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo",
9 | "EMBEDDING_MODEL_DEPLOYMENT_NAME": "text-embedding-ada-002"
10 | }
11 | }
--------------------------------------------------------------------------------
/samples/rag-cosmosdb/demo.http:
--------------------------------------------------------------------------------
1 | ### Ingest first file into database
2 |
3 | POST http://localhost:7071/api/IngestFile
4 | Content-Type: application/json
5 |
6 | {"url":"https://url/test/test_file.txt"}
7 |
8 |
9 | ### Ingest second file into database
10 | POST http://localhost:7071/api/IngestFile
11 | Content-Type: application/json
12 |
13 | {"url":"https://url/test/test_file.txt"}
14 |
15 |
16 | ### Send a search query (Example #1)
17 | POST http://localhost:7071/api/PromptFile
18 | Content-Type: application/json
19 |
20 | {"prompt":"INSERT PROMPT HERE"}
21 |
22 |
23 | ### Send a search query (Example #2)
24 | POST http://localhost:7071/api/PromptFile
25 | Content-Type: application/json
26 |
27 | {"prompt":"INSERT PROMPT HERE"}
--------------------------------------------------------------------------------
/samples/rag-cosmosdb/java/.funcignore:
--------------------------------------------------------------------------------
1 | local.settings.json
--------------------------------------------------------------------------------
/samples/rag-cosmosdb/java/extensions.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net80
4 |
5 | **
6 | target/azure-functions/azfs-java-openai-sample/bin
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/samples/rag-cosmosdb/java/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | },
8 | "extensions": {
9 | "openai": {
10 | "searchProvider": {
11 | "type": "cosmosDBSearch",
12 | "vectorSearchDimensions": 1536,
13 | "numLists": 1,
14 | "kind": "vector-ivf",
15 | "similarity": "COS",
16 | "numberOfConnections": 16,
17 | "efConstruction": 64,
18 | "efSearch": 40,
19 | "applicationName": "functionsAppName",
20 | "embeddingKey": "embedding",
21 | "textKey": "text"
22 | }
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/samples/rag-cosmosdb/java/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "FUNCTIONS_WORKER_RUNTIME": "java",
6 | "CosmosDBMongoVCoreConnectionString": "",
7 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
8 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo",
9 | "EMBEDDING_MODEL_DEPLOYMENT_NAME": "text-embedding-ada-002"
10 | }
11 | }
--------------------------------------------------------------------------------
/samples/rag-cosmosdb/javascript/.funcignore:
--------------------------------------------------------------------------------
1 | *.js.map
2 | *.ts
3 | .git*
4 | .vscode
5 | __azurite_db*__.json
6 | __blobstorage__
7 | __queuestorage__
8 | local.settings.json
9 | test
10 | tsconfig.json
--------------------------------------------------------------------------------
/samples/rag-cosmosdb/javascript/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | },
8 | "extensionBundle": {
9 | "id": "Microsoft.Azure.Functions.ExtensionBundle.Preview",
10 | "version": "[4.*, 5.0.0)"
11 | },
12 | "extensions": {
13 | "openai": {
14 | "searchProvider": {
15 | "type": "cosmosDBSearch",
16 | "vectorSearchDimensions": 1536,
17 | "numLists": 1,
18 | "kind": "vector-ivf",
19 | "similarity": "COS",
20 | "numberOfConnections": 16,
21 | "efConstruction": 64,
22 | "efSearch": 40,
23 | "applicationName": "functionsAppName",
24 | "embeddingKey": "embedding",
25 | "textKey": "text"
26 | }
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/samples/rag-cosmosdb/javascript/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "AzureWebJobsFeatureFlags": "EnableWorkerIndexing",
6 | "FUNCTIONS_WORKER_RUNTIME": "node",
7 | "CosmosDBMongoVCoreConnectionString": "",
8 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
9 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo",
10 | "EMBEDDING_MODEL_DEPLOYMENT_NAME": "text-embedding-ada-002"
11 | }
12 | }
--------------------------------------------------------------------------------
/samples/rag-cosmosdb/javascript/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "rag-cosmosdb",
3 | "version": "1.0.0",
4 | "description": "",
5 | "scripts": {
6 | "start": "func start",
7 | "test": "echo \"No tests yet...\""
8 | },
9 | "dependencies": {
10 | "@azure/functions": "^4.0.0"
11 | },
12 | "devDependencies": {
13 | },
14 | "main": "src/*.js"
15 | }
--------------------------------------------------------------------------------
/samples/rag-cosmosdb/powershell/.funcignore:
--------------------------------------------------------------------------------
1 | .git*
2 | .vscode
3 | __azurite_db*__.json
4 | __blobstorage__
5 | __queuestorage__
6 | local.settings.json
7 | test
--------------------------------------------------------------------------------
/samples/rag-cosmosdb/powershell/IngestFile/function.json:
--------------------------------------------------------------------------------
1 | {
2 | "bindings": [
3 | {
4 | "authLevel": "function",
5 | "type": "httpTrigger",
6 | "direction": "in",
7 | "name": "Request",
8 | "methods": [
9 | "post"
10 | ]
11 | },
12 | {
13 | "type": "http",
14 | "direction": "out",
15 | "name": "Response"
16 | },
17 | {
18 | "name": "EmbeddingsStoreOutput",
19 | "type": "embeddingsStore",
20 | "direction": "out",
21 | "input": "{url}",
22 | "inputType": "Url",
23 | "connectionName": "CosmosDBMongoVCoreConnectionString",
24 | "collection": "openai-index",
25 | "embeddingsModel": "%EMBEDDING_MODEL_DEPLOYMENT_NAME%"
26 | }
27 | ]
28 | }
--------------------------------------------------------------------------------
/samples/rag-cosmosdb/powershell/IngestFile/run.ps1:
--------------------------------------------------------------------------------
1 | using namespace System.Net
2 |
3 | param($Request, $TriggerMetadata)
4 |
5 | $ErrorActionPreference = 'Stop'
6 |
7 | $inputJson = $Request.Body
8 |
9 | if (-not $inputJson -or -not $inputJson.Url) {
10 | throw 'Invalid request body. Make sure that you pass in {\"url\": value } as the request body.'
11 | }
12 |
13 | $uri = [URI]$inputJson.Url
14 | $filename = [System.IO.Path]::GetFileName($uri.AbsolutePath)
15 |
16 |
17 | Push-OutputBinding -Name EmbeddingsStoreOutput -Value @{
18 | "title" = $filename
19 | }
20 |
21 | $response = @{
22 | "status" = "success"
23 | "title" = $filename
24 | }
25 |
26 | Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
27 | StatusCode = [HttpStatusCode]::OK
28 | Body = $response
29 | Headers = @{
30 | "Content-Type" = "application/json"
31 | }
32 | })
--------------------------------------------------------------------------------
/samples/rag-cosmosdb/powershell/PromptFile/function.json:
--------------------------------------------------------------------------------
1 | {
2 | "bindings": [
3 | {
4 | "authLevel": "function",
5 | "type": "httpTrigger",
6 | "direction": "in",
7 | "name": "Request",
8 | "methods": [
9 | "post"
10 | ]
11 | },
12 | {
13 | "type": "http",
14 | "direction": "out",
15 | "name": "Response"
16 | },
17 | {
18 | "name": "SemanticSearchInput",
19 | "type": "semanticSearch",
20 | "direction": "in",
21 | "connectionName": "CosmosDBMongoVCoreConnectionString",
22 | "collection": "openai-index",
23 | "query": "{prompt}",
24 | "chatModel": "%CHAT_MODEL_DEPLOYMENT_NAME%",
25 | "embeddingsModel": "%EMBEDDING_MODEL_DEPLOYMENT_NAME%"
26 | }
27 | ]
28 | }
--------------------------------------------------------------------------------
/samples/rag-cosmosdb/powershell/PromptFile/run.ps1:
--------------------------------------------------------------------------------
1 | using namespace System.Net
2 |
3 | param($Request, $TriggerMetadata, $SemanticSearchInput)
4 |
5 | Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
6 | StatusCode = [HttpStatusCode]::OK
7 | Body = $SemanticSearchInput.Response
8 | })
--------------------------------------------------------------------------------
/samples/rag-cosmosdb/powershell/extensions.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net80
4 |
5 | **
6 | bin
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/samples/rag-cosmosdb/powershell/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | },
8 | "extensions": {
9 | "openai": {
10 | "searchProvider": {
11 | "type": "cosmosDBSearch",
12 | "vectorSearchDimensions": 1536,
13 | "numLists": 1,
14 | "kind": "vector-ivf",
15 | "similarity": "COS",
16 | "numberOfConnections": 16,
17 | "efConstruction": 64,
18 | "efSearch": 40,
19 | "applicationName": "functionsAppName",
20 | "embeddingKey": "embedding",
21 | "textKey": "text"
22 | }
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/samples/rag-cosmosdb/powershell/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "FUNCTIONS_WORKER_RUNTIME": "powershell",
6 | "FUNCTIONS_WORKER_RUNTIME_VERSION": "7.2",
7 | "CosmosDBMongoVCoreConnectionString": "",
8 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
9 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo",
10 | "EMBEDDING_MODEL_DEPLOYMENT_NAME": "text-embedding-ada-002"
11 | }
12 | }
--------------------------------------------------------------------------------
/samples/rag-cosmosdb/powershell/profile.ps1:
--------------------------------------------------------------------------------
1 | # Azure Functions profile.ps1
2 | #
3 | # This profile.ps1 will get executed every "cold start" of your Function App.
4 | # "cold start" occurs when:
5 | #
6 | # * A Function App starts up for the very first time
7 | # * A Function App starts up after being de-allocated due to inactivity
8 | #
9 | # You can define helper functions, run commands, or specify environment variables
10 | # NOTE: any variables defined that are not environment variables will get reset after the first execution
11 |
12 | # Authenticate with Azure PowerShell using MSI.
13 | # Remove this if you are not planning on using MSI or Azure PowerShell.
14 | if ($env:MSI_SECRET) {
15 | Disable-AzContextAutosave -Scope Process | Out-Null
16 | Connect-AzAccount -Identity
17 | }
18 |
19 | # Uncomment the next line to enable legacy AzureRm alias in Azure PowerShell.
20 | # Enable-AzureRmAlias
21 |
22 | # You can also define functions or aliases that can be referenced in any of your PowerShell functions.
23 |
--------------------------------------------------------------------------------
/samples/rag-cosmosdb/powershell/requirements.psd1:
--------------------------------------------------------------------------------
1 | # This file enables modules to be automatically managed by the Functions service.
2 | # See https://aka.ms/functionsmanageddependency for additional information.
3 | #
4 | @{
5 | # For latest supported version, go to 'https://www.powershellgallery.com/packages/Az'. Uncomment the next line and replace the MAJOR_VERSION, e.g., 'Az' = '5.*'
6 | # 'Az' = 'MAJOR_VERSION.*'
7 | }
--------------------------------------------------------------------------------
/samples/rag-cosmosdb/python/.funcignore:
--------------------------------------------------------------------------------
1 | .git*
2 | .vscode
3 | __azurite_db*__.json
4 | __blobstorage__
5 | __queuestorage__
6 | local.settings.json
7 | test
8 | .venv
--------------------------------------------------------------------------------
/samples/rag-cosmosdb/python/extensions.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net80
4 |
5 | **
6 | bin
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/samples/rag-cosmosdb/python/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | },
8 | "extensions": {
9 | "openai": {
10 | "searchProvider": {
11 | "type": "cosmosDBSearch",
12 | "vectorSearchDimensions": 1536,
13 | "numLists": 1,
14 | "kind": "vector-ivf",
15 | "similarity": "COS",
16 | "numberOfConnections": 16,
17 | "efConstruction": 64,
18 | "efSearch": 40,
19 | "applicationName": "functionsAppName",
20 | "embeddingKey": "embedding",
21 | "textKey": "text"
22 | }
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/samples/rag-cosmosdb/python/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "AzureWebJobsFeatureFlags": "EnableWorkerIndexing",
6 | "FUNCTIONS_WORKER_RUNTIME": "python",
7 | "CosmosDBMongoVCoreConnectionString": "",
8 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
9 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo",
10 | "EMBEDDING_MODEL_DEPLOYMENT_NAME": "text-embedding-ada-002",
11 | "PYTHON_ISOLATE_WORKER_DEPENDENCIES": "1"
12 | }
13 | }
--------------------------------------------------------------------------------
/samples/rag-cosmosdb/python/requirements.txt:
--------------------------------------------------------------------------------
1 | # DO NOT include azure-functions-worker in this file
2 | # The Python Worker is managed by Azure Functions platform
3 | # Manually managing azure-functions-worker may cause unexpected issues
4 |
5 | azure-functions>=1.24.0b1
--------------------------------------------------------------------------------
/samples/rag-cosmosdb/typescript/.funcignore:
--------------------------------------------------------------------------------
1 | *.js.map
2 | *.ts
3 | .git*
4 | .vscode
5 | __azurite_db*__.json
6 | __blobstorage__
7 | __queuestorage__
8 | local.settings.json
9 | test
10 | tsconfig.json
--------------------------------------------------------------------------------
/samples/rag-cosmosdb/typescript/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | },
8 | "extensionBundle": {
9 | "id": "Microsoft.Azure.Functions.ExtensionBundle.Preview",
10 | "version": "[4.*, 5.0.0)"
11 | },
12 | "extensions": {
13 | "openai": {
14 | "searchProvider": {
15 | "type": "cosmosDBSearch",
16 | "vectorSearchDimensions": 1536,
17 | "numLists": 1,
18 | "kind": "vector-ivf",
19 | "similarity": "COS",
20 | "numberOfConnections": 16,
21 | "efConstruction": 64,
22 | "efSearch": 40,
23 | "applicationName": "functionsAppName",
24 | "embeddingKey": "embedding",
25 | "textKey": "text"
26 | }
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/samples/rag-cosmosdb/typescript/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "AzureWebJobsFeatureFlags": "EnableWorkerIndexing",
6 | "FUNCTIONS_WORKER_RUNTIME": "node",
7 | "CosmosDBMongoVCoreConnectionString": "",
8 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
9 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo",
10 | "EMBEDDING_MODEL_DEPLOYMENT_NAME": "text-embedding-ada-002"
11 | }
12 | }
--------------------------------------------------------------------------------
/samples/rag-cosmosdb/typescript/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "rag-cosmosdb",
3 | "version": "1.0.0",
4 | "description": "",
5 | "scripts": {
6 | "build": "tsc",
7 | "watch": "tsc -w",
8 | "prestart": "npm run build",
9 | "start": "func start",
10 | "test": "echo \"No tests yet...\""
11 | },
12 | "dependencies": {
13 | "@azure/functions": "^4.0.0"
14 | },
15 | "devDependencies": {
16 | "@types/node": "^18.x",
17 | "typescript": "^4.0.0",
18 | "rimraf": "^5.0.0"
19 | },
20 | "main": "dist/src/*.js"
21 | }
--------------------------------------------------------------------------------
/samples/rag-cosmosdb/typescript/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es6",
5 | "outDir": "dist",
6 | "rootDir": ".",
7 | "sourceMap": true,
8 | "strict": false
9 | }
10 | }
--------------------------------------------------------------------------------
/samples/rag-kusto/csharp-legacy/KustoSearchLegacy.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net8.0
4 | v4
5 | enable
6 | 11.0
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | PreserveNewest
21 |
22 |
23 | PreserveNewest
24 | Never
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/samples/rag-kusto/csharp-legacy/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | },
8 | "extensions": {
9 | "openai": {
10 | "searchProvider": {
11 | "type": "kusto"
12 | }
13 | }
14 | }
15 | }
--------------------------------------------------------------------------------
/samples/rag-kusto/csharp-legacy/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "FUNCTIONS_WORKER_RUNTIME": "dotnet",
6 | "FUNCTIONS_INPROC_NET8_ENABLED": "1",
7 | "KustoConnectionString": "Data Source=https://YOUR-CLUSTER-HOSTNAME;Initial Catalog=YOUR-DATABASE-NAME;Fed=True",
8 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
9 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo",
10 | "EMBEDDING_MODEL_DEPLOYMENT_NAME": "text-embedding-3-small"
11 | }
12 | }
--------------------------------------------------------------------------------
/samples/rag-kusto/csharp-ooproc/Program.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Azure.Functions.Worker;
5 | using Microsoft.Extensions.DependencyInjection;
6 | using Microsoft.Extensions.Hosting;
7 |
8 | var host = new HostBuilder()
9 | .ConfigureFunctionsWebApplication()
10 | .ConfigureServices(services =>
11 | {
12 | services.AddApplicationInsightsTelemetryWorkerService();
13 | services.ConfigureFunctionsApplicationInsights();
14 | })
15 | .Build();
16 |
17 | host.Run();
18 |
--------------------------------------------------------------------------------
/samples/rag-kusto/csharp-ooproc/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "SemanticSearchEmbeddings": {
4 | "commandName": "Project",
5 | "commandLineArgs": "--port 7071",
6 | "launchBrowser": false
7 | }
8 | }
9 | }
--------------------------------------------------------------------------------
/samples/rag-kusto/csharp-ooproc/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | },
8 | "extensions": {
9 | "openai": {
10 | "searchProvider": {
11 | "type": "kusto"
12 | }
13 | }
14 | }
15 | }
--------------------------------------------------------------------------------
/samples/rag-kusto/csharp-ooproc/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
6 | "KustoConnectionString": "Data Source=https://YOUR-CLUSTER-HOSTNAME;Initial Catalog=YOUR-DATABASE-NAME;Fed=True",
7 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
8 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo",
9 | "EMBEDDING_MODEL_DEPLOYMENT_NAME": "text-embedding-3-small"
10 | }
11 | }
--------------------------------------------------------------------------------
/samples/rag-kusto/demo.http:
--------------------------------------------------------------------------------
1 | ### Ingest first email into database
2 |
3 | POST http://localhost:7071/api/IngestEmail
4 | Content-Type: application/json
5 |
6 | {"url":"https://url/test/test_file.txt"}
7 |
8 |
9 | ### Ingest second email into database
10 | POST http://localhost:7071/api/IngestEmail
11 | Content-Type: application/json
12 |
13 | {"url":"https://url/test/test_file.txt"}
14 |
15 |
16 | ### Send a search query (Example #1)
17 | POST http://localhost:7071/api/PromptEmail
18 | Content-Type: application/json
19 |
20 | {"prompt":"INSERT PROMPT HERE"}
21 |
22 |
23 | ### Send a search query (Example #2)
24 | POST http://localhost:7071/api/PromptEmail
25 | Content-Type: application/json
26 |
27 | {"prompt":"INSERT PROMPT HERE"}
--------------------------------------------------------------------------------
/samples/rag-kusto/java/.funcignore:
--------------------------------------------------------------------------------
1 | local.settings.json
--------------------------------------------------------------------------------
/samples/rag-kusto/java/extensions.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net80
4 |
5 | **
6 | target/azure-functions/azfs-java-openai-sample/bin
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/samples/rag-kusto/java/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | },
8 | "extensions": {
9 | "openai": {
10 | "searchProvider": {
11 | "type": "kusto"
12 | }
13 | }
14 | }
15 | }
--------------------------------------------------------------------------------
/samples/rag-kusto/java/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "FUNCTIONS_WORKER_RUNTIME": "java",
6 | "KustoConnectionString": "Data Source=https://YOUR-CLUSTER-HOSTNAME;Initial Catalog=YOUR-DATABASE-NAME;Fed=True",
7 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
8 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo",
9 | "EMBEDDING_MODEL_DEPLOYMENT_NAME": "text-embedding-3-small"
10 | }
11 | }
--------------------------------------------------------------------------------
/samples/rag-kusto/javascript/.funcignore:
--------------------------------------------------------------------------------
1 | *.js.map
2 | *.ts
3 | .git*
4 | .vscode
5 | __azurite_db*__.json
6 | __blobstorage__
7 | __queuestorage__
8 | local.settings.json
9 | test
10 | tsconfig.json
--------------------------------------------------------------------------------
/samples/rag-kusto/javascript/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | },
8 | "extensionBundle": {
9 | "id": "Microsoft.Azure.Functions.ExtensionBundle.Preview",
10 | "version": "[4.*, 5.0.0)"
11 | },
12 | "extensions": {
13 | "openai": {
14 | "searchProvider": {
15 | "type": "kusto"
16 | }
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/samples/rag-kusto/javascript/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "AzureWebJobsFeatureFlags": "EnableWorkerIndexing",
6 | "FUNCTIONS_WORKER_RUNTIME": "node",
7 | "KustoConnectionString": "Data Source=https://YOUR-CLUSTER-HOSTNAME;Initial Catalog=YOUR-DATABASE-NAME;Fed=True",
8 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
9 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo",
10 | "EMBEDDING_MODEL_DEPLOYMENT_NAME": "text-embedding-3-small"
11 | }
12 | }
--------------------------------------------------------------------------------
/samples/rag-kusto/javascript/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "rag-kusto",
3 | "version": "1.0.0",
4 | "description": "",
5 | "scripts": {
6 | "start": "func start",
7 | "test": "echo \"No tests yet...\""
8 | },
9 | "dependencies": {
10 | "@azure/functions": "^4.0.0"
11 | },
12 | "devDependencies": {
13 | },
14 | "main": "src/*.js"
15 | }
--------------------------------------------------------------------------------
/samples/rag-kusto/powershell/.funcignore:
--------------------------------------------------------------------------------
1 | .git*
2 | .vscode
3 | __azurite_db*__.json
4 | __blobstorage__
5 | __queuestorage__
6 | local.settings.json
7 | test
--------------------------------------------------------------------------------
/samples/rag-kusto/powershell/IngestEmail/function.json:
--------------------------------------------------------------------------------
1 | {
2 | "bindings": [
3 | {
4 | "authLevel": "function",
5 | "type": "httpTrigger",
6 | "direction": "in",
7 | "name": "Request",
8 | "methods": [
9 | "post"
10 | ]
11 | },
12 | {
13 | "type": "http",
14 | "direction": "out",
15 | "name": "Response"
16 | },
17 | {
18 | "name": "EmbeddingsStoreOutput",
19 | "type": "embeddingsStore",
20 | "direction": "out",
21 | "input": "{url}",
22 | "inputType": "Url",
23 | "connectionName": "KustoConnectionString",
24 | "collection": "Documents",
25 | "embeddingsModel": "%EMBEDDING_MODEL_DEPLOYMENT_NAME%"
26 | }
27 | ]
28 | }
--------------------------------------------------------------------------------
/samples/rag-kusto/powershell/IngestEmail/run.ps1:
--------------------------------------------------------------------------------
1 | using namespace System.Net
2 |
3 | param($Request, $TriggerMetadata)
4 |
5 | $ErrorActionPreference = 'Stop'
6 |
7 | $inputJson = $Request.Body
8 |
9 | if (-not $inputJson -or -not $inputJson.Url) {
10 | throw 'Invalid request body. Make sure that you pass in {\"url\": value } as the request body.'
11 | }
12 |
13 | $uri = [URI]$inputJson.Url
14 | $filename = [System.IO.Path]::GetFileName($uri.AbsolutePath)
15 |
16 |
17 | Push-OutputBinding -Name EmbeddingsStoreOutput -Value @{
18 | "title" = $filename
19 | }
20 |
21 | $response = @{
22 | "status" = "success"
23 | "title" = $filename
24 | }
25 |
26 | Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
27 | StatusCode = [HttpStatusCode]::OK
28 | Body = $response
29 | Headers = @{
30 | "Content-Type" = "application/json"
31 | }
32 | })
--------------------------------------------------------------------------------
/samples/rag-kusto/powershell/PromptEmail/function.json:
--------------------------------------------------------------------------------
1 | {
2 | "bindings": [
3 | {
4 | "authLevel": "function",
5 | "type": "httpTrigger",
6 | "direction": "in",
7 | "name": "Request",
8 | "methods": [
9 | "post"
10 | ]
11 | },
12 | {
13 | "type": "http",
14 | "direction": "out",
15 | "name": "Response"
16 | },
17 | {
18 | "name": "SemanticSearchInput",
19 | "type": "semanticSearch",
20 | "direction": "in",
21 | "connectionName": "KustoConnectionString",
22 | "collection": "Documents",
23 | "query": "{prompt}",
24 | "chatModel": "%CHAT_MODEL_DEPLOYMENT_NAME%",
25 | "embeddingsModel": "%EMBEDDING_MODEL_DEPLOYMENT_NAME%"
26 | }
27 | ]
28 | }
--------------------------------------------------------------------------------
/samples/rag-kusto/powershell/PromptEmail/run.ps1:
--------------------------------------------------------------------------------
1 | using namespace System.Net
2 |
3 | param($Request, $TriggerMetadata, $SemanticSearchInput)
4 |
5 | Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
6 | StatusCode = [HttpStatusCode]::OK
7 | Body = $SemanticSearchInput.Response
8 | })
--------------------------------------------------------------------------------
/samples/rag-kusto/powershell/extensions.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net80
4 |
5 | **
6 | bin
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/samples/rag-kusto/powershell/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | },
8 | "extensions": {
9 | "openai": {
10 | "searchProvider": {
11 | "type": "kusto"
12 | }
13 | }
14 | }
15 | }
--------------------------------------------------------------------------------
/samples/rag-kusto/powershell/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "FUNCTIONS_WORKER_RUNTIME": "powershell",
6 | "FUNCTIONS_WORKER_RUNTIME_VERSION": "7.2",
7 | "KustoConnectionString": "Data Source=https://YOUR-CLUSTER-HOSTNAME;Initial Catalog=YOUR-DATABASE-NAME;Fed=True",
8 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
9 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo",
10 | "EMBEDDING_MODEL_DEPLOYMENT_NAME": "text-embedding-3-small"
11 | }
12 | }
--------------------------------------------------------------------------------
/samples/rag-kusto/powershell/profile.ps1:
--------------------------------------------------------------------------------
1 | # Azure Functions profile.ps1
2 | #
3 | # This profile.ps1 will get executed every "cold start" of your Function App.
4 | # "cold start" occurs when:
5 | #
6 | # * A Function App starts up for the very first time
7 | # * A Function App starts up after being de-allocated due to inactivity
8 | #
9 | # You can define helper functions, run commands, or specify environment variables
10 | # NOTE: any variables defined that are not environment variables will get reset after the first execution
11 |
12 | # Authenticate with Azure PowerShell using MSI.
13 | # Remove this if you are not planning on using MSI or Azure PowerShell.
14 | if ($env:MSI_SECRET) {
15 | Disable-AzContextAutosave -Scope Process | Out-Null
16 | Connect-AzAccount -Identity
17 | }
18 |
19 | # Uncomment the next line to enable legacy AzureRm alias in Azure PowerShell.
20 | # Enable-AzureRmAlias
21 |
22 | # You can also define functions or aliases that can be referenced in any of your PowerShell functions.
23 |
--------------------------------------------------------------------------------
/samples/rag-kusto/powershell/requirements.psd1:
--------------------------------------------------------------------------------
1 | # This file enables modules to be automatically managed by the Functions service.
2 | # See https://aka.ms/functionsmanageddependency for additional information.
3 | #
4 | @{
5 | # For latest supported version, go to 'https://www.powershellgallery.com/packages/Az'. Uncomment the next line and replace the MAJOR_VERSION, e.g., 'Az' = '5.*'
6 | # 'Az' = 'MAJOR_VERSION.*'
7 | }
--------------------------------------------------------------------------------
/samples/rag-kusto/python/.funcignore:
--------------------------------------------------------------------------------
1 | .git*
2 | .vscode
3 | __azurite_db*__.json
4 | __blobstorage__
5 | __queuestorage__
6 | local.settings.json
7 | test
8 | .venv
--------------------------------------------------------------------------------
/samples/rag-kusto/python/extensions.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net80
4 |
5 | **
6 | bin
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/samples/rag-kusto/python/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | },
8 | "extensions": {
9 | "openai": {
10 | "searchProvider": {
11 | "type": "kusto"
12 | }
13 | }
14 | }
15 | }
--------------------------------------------------------------------------------
/samples/rag-kusto/python/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "AzureWebJobsFeatureFlags": "EnableWorkerIndexing",
6 | "FUNCTIONS_WORKER_RUNTIME": "python",
7 | "KustoConnectionString": "Data Source=https://YOUR-CLUSTER-HOSTNAME;Initial Catalog=YOUR-DATABASE-NAME;Fed=True",
8 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
9 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo",
10 | "EMBEDDING_MODEL_DEPLOYMENT_NAME": "text-embedding-3-small",
11 | "PYTHON_ISOLATE_WORKER_DEPENDENCIES": "1"
12 | }
13 | }
--------------------------------------------------------------------------------
/samples/rag-kusto/python/requirements.txt:
--------------------------------------------------------------------------------
1 | # DO NOT include azure-functions-worker in this file
2 | # The Python Worker is managed by Azure Functions platform
3 | # Manually managing azure-functions-worker may cause unexpected issues
4 |
5 | azure-functions>=1.24.0b1
--------------------------------------------------------------------------------
/samples/rag-kusto/typescript/.funcignore:
--------------------------------------------------------------------------------
1 | *.js.map
2 | *.ts
3 | .git*
4 | .vscode
5 | __azurite_db*__.json
6 | __blobstorage__
7 | __queuestorage__
8 | local.settings.json
9 | test
10 | tsconfig.json
--------------------------------------------------------------------------------
/samples/rag-kusto/typescript/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | },
8 | "extensionBundle": {
9 | "id": "Microsoft.Azure.Functions.ExtensionBundle.Preview",
10 | "version": "[4.*, 5.0.0)"
11 | },
12 | "extensions": {
13 | "openai": {
14 | "searchProvider": {
15 | "type": "kusto"
16 | }
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/samples/rag-kusto/typescript/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "AzureWebJobsFeatureFlags": "EnableWorkerIndexing",
6 | "FUNCTIONS_WORKER_RUNTIME": "node",
7 | "KustoConnectionString": "Data Source=https://YOUR-CLUSTER-HOSTNAME;Initial Catalog=YOUR-DATABASE-NAME;Fed=True",
8 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
9 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo",
10 | "EMBEDDING_MODEL_DEPLOYMENT_NAME": "text-embedding-3-small"
11 | }
12 | }
--------------------------------------------------------------------------------
/samples/rag-kusto/typescript/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "rag-kusto",
3 | "version": "1.0.0",
4 | "description": "",
5 | "scripts": {
6 | "build": "tsc",
7 | "watch": "tsc -w",
8 | "prestart": "npm run build",
9 | "start": "func start",
10 | "test": "echo \"No tests yet...\""
11 | },
12 | "dependencies": {
13 | "@azure/functions": "^4.0.0"
14 | },
15 | "devDependencies": {
16 | "@types/node": "^18.x",
17 | "typescript": "^4.0.0",
18 | "rimraf": "^5.0.0"
19 | },
20 | "main": "dist/src/*.js"
21 | }
--------------------------------------------------------------------------------
/samples/rag-kusto/typescript/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es6",
5 | "outDir": "dist",
6 | "rootDir": ".",
7 | "sourceMap": true,
8 | "strict": false
9 | }
10 | }
--------------------------------------------------------------------------------
/samples/textcompletion/csharp-legacy/TextCompletionLegacy.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net8.0
4 | v4
5 | enable
6 | 11.0
7 |
8 |
9 |
10 |
11 |
12 |
14 |
15 |
16 |
17 | PreserveNewest
18 |
19 |
20 | PreserveNewest
21 | Never
22 |
23 |
24 |
--------------------------------------------------------------------------------
/samples/textcompletion/csharp-legacy/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | }
8 | }
--------------------------------------------------------------------------------
/samples/textcompletion/csharp-legacy/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "FUNCTIONS_WORKER_RUNTIME": "dotnet",
6 | "FUNCTIONS_INPROC_NET8_ENABLED": "1",
7 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
8 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo"
9 | }
10 | }
--------------------------------------------------------------------------------
/samples/textcompletion/csharp-ooproc/Program.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Extensions.Hosting;
5 |
6 |
7 | var host = new HostBuilder()
8 | .ConfigureFunctionsWebApplication()
9 | .Build();
10 |
11 | host.Run();
12 |
--------------------------------------------------------------------------------
/samples/textcompletion/csharp-ooproc/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "TextCompletionIsolated": {
4 | "commandName": "Project",
5 | "commandLineArgs": "--port 7137",
6 | "launchBrowser": false
7 | }
8 | }
9 | }
--------------------------------------------------------------------------------
/samples/textcompletion/csharp-ooproc/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | }
8 | }
--------------------------------------------------------------------------------
/samples/textcompletion/csharp-ooproc/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
6 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
7 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo"
8 | }
9 | }
--------------------------------------------------------------------------------
/samples/textcompletion/demo.http:
--------------------------------------------------------------------------------
1 | # Invoke the "whois" function with the {name} parameter set to "pikachu"
2 | GET http://localhost:7071/api/whois/pikachu
--------------------------------------------------------------------------------
/samples/textcompletion/java/.funcignore:
--------------------------------------------------------------------------------
1 | local.settings.json
--------------------------------------------------------------------------------
/samples/textcompletion/java/extensions.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net80
4 |
5 | **
6 | target/azure-functions/azfs-java-openai-sample/bin
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/samples/textcompletion/java/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | }
8 | }
--------------------------------------------------------------------------------
/samples/textcompletion/java/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "AzureWebJobsFeatureFlags": "EnableWorkerIndexing",
6 | "FUNCTIONS_WORKER_RUNTIME": "java",
7 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
8 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo"
9 | }
10 | }
--------------------------------------------------------------------------------
/samples/textcompletion/javascript/.funcignore:
--------------------------------------------------------------------------------
1 | *.js.map
2 | *.ts
3 | .git*
4 | .vscode
5 | __azurite_db*__.json
6 | __blobstorage__
7 | __queuestorage__
8 | local.settings.json
9 | test
10 | tsconfig.json
--------------------------------------------------------------------------------
/samples/textcompletion/javascript/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | },
8 | "extensionBundle": {
9 | "id": "Microsoft.Azure.Functions.ExtensionBundle.Preview",
10 | "version": "[4.*, 5.0.0)"
11 | }
12 | }
--------------------------------------------------------------------------------
/samples/textcompletion/javascript/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "AzureWebJobsFeatureFlags": "EnableWorkerIndexing",
6 | "FUNCTIONS_WORKER_RUNTIME": "node",
7 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
8 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo"
9 | }
10 | }
--------------------------------------------------------------------------------
/samples/textcompletion/javascript/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "javascript",
3 | "version": "1.0.0",
4 | "description": "",
5 | "scripts": {
6 | "start": "func start",
7 | "test": "echo \"No tests yet...\""
8 | },
9 | "dependencies": {
10 | "@azure/functions": "^4.0.0"
11 | },
12 | "devDependencies": {
13 | "@types/node": "^18.x",
14 | "rimraf": "^5.0.0"
15 | },
16 | "main": "src/functions/*.js"
17 | }
--------------------------------------------------------------------------------
/samples/textcompletion/javascript/src/functions/whois.js:
--------------------------------------------------------------------------------
1 | const { app, input } = require("@azure/functions");
2 |
3 | // This OpenAI completion input requires a {name} binding value.
4 | const openAICompletionInput = input.generic({
5 | prompt: 'Who is {name}?',
6 | maxTokens: '100',
7 | type: 'textCompletion',
8 | chatModel: '%CHAT_MODEL_DEPLOYMENT_NAME%'
9 | })
10 |
11 | app.http('whois', {
12 | methods: ['GET'],
13 | route: 'whois/{name}',
14 | authLevel: 'function',
15 | extraInputs: [openAICompletionInput],
16 | handler: async (_request, context) => {
17 | var response = context.extraInputs.get(openAICompletionInput)
18 | return { body: response.content.trim() }
19 | }
20 | });
21 |
--------------------------------------------------------------------------------
/samples/textcompletion/powershell/.funcignore:
--------------------------------------------------------------------------------
1 | .git*
2 | .vscode
3 | __azurite_db*__.json
4 | __blobstorage__
5 | __queuestorage__
6 | local.settings.json
7 | test
--------------------------------------------------------------------------------
/samples/textcompletion/powershell/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | # Azure Functions artifacts
3 | bin
4 | obj
5 | appsettings.json
6 |
7 | # Azurite artifacts
8 | __blobstorage__
9 | __queuestorage__
10 | __azurite_db*__.json
--------------------------------------------------------------------------------
/samples/textcompletion/powershell/WhoIs/function.json:
--------------------------------------------------------------------------------
1 | {
2 | "bindings": [
3 | {
4 | "authLevel": "function",
5 | "type": "httpTrigger",
6 | "direction": "in",
7 | "name": "Request",
8 | "route": "whois/{name}",
9 | "methods": [
10 | "get"
11 | ]
12 | },
13 | {
14 | "type": "http",
15 | "direction": "out",
16 | "name": "Response"
17 | },
18 | {
19 | "type": "textCompletion",
20 | "direction": "in",
21 | "name": "TextCompletionResponse",
22 | "prompt": "Who is {name}?",
23 | "maxTokens": "100",
24 | "chatModel": "%CHAT_MODEL_DEPLOYMENT_NAME%"
25 | }
26 | ]
27 | }
--------------------------------------------------------------------------------
/samples/textcompletion/powershell/WhoIs/run.ps1:
--------------------------------------------------------------------------------
1 | using namespace System.Net
2 |
3 | param($Request, $TriggerMetadata, $TextCompletionResponse)
4 |
5 | Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
6 | StatusCode = [HttpStatusCode]::OK
7 | Body = $TextCompletionResponse.Content
8 | })
--------------------------------------------------------------------------------
/samples/textcompletion/powershell/extensions.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net80
4 |
5 | **
6 | bin
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/samples/textcompletion/powershell/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | }
8 | }
--------------------------------------------------------------------------------
/samples/textcompletion/powershell/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "FUNCTIONS_WORKER_RUNTIME_VERSION": "7.2",
6 | "FUNCTIONS_WORKER_RUNTIME": "powershell",
7 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
8 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo"
9 | }
10 | }
--------------------------------------------------------------------------------
/samples/textcompletion/powershell/profile.ps1:
--------------------------------------------------------------------------------
1 | # Azure Functions profile.ps1
2 | #
3 | # This profile.ps1 will get executed every "cold start" of your Function App.
4 | # "cold start" occurs when:
5 | #
6 | # * A Function App starts up for the very first time
7 | # * A Function App starts up after being de-allocated due to inactivity
8 | #
9 | # You can define helper functions, run commands, or specify environment variables
10 | # NOTE: any variables defined that are not environment variables will get reset after the first execution
11 |
12 | # Authenticate with Azure PowerShell using MSI.
13 | # Remove this if you are not planning on using MSI or Azure PowerShell.
14 | if ($env:MSI_SECRET) {
15 | Disable-AzContextAutosave -Scope Process | Out-Null
16 | Connect-AzAccount -Identity
17 | }
18 |
19 | # Uncomment the next line to enable legacy AzureRm alias in Azure PowerShell.
20 | # Enable-AzureRmAlias
21 |
22 | # You can also define functions or aliases that can be referenced in any of your PowerShell functions.
23 |
--------------------------------------------------------------------------------
/samples/textcompletion/powershell/requirements.psd1:
--------------------------------------------------------------------------------
1 | # This file enables modules to be automatically managed by the Functions service.
2 | # See https://aka.ms/functionsmanageddependency for additional information.
3 | #
4 | @{
5 | # For latest supported version, go to 'https://www.powershellgallery.com/packages/Az'. Uncomment the next line and replace the MAJOR_VERSION, e.g., 'Az' = '5.*'
6 | # 'Az' = 'MAJOR_VERSION.*'
7 | }
--------------------------------------------------------------------------------
/samples/textcompletion/python/.funcignore:
--------------------------------------------------------------------------------
1 | .git*
2 | .vscode
3 | __azurite_db*__.json
4 | __blobstorage__
5 | __queuestorage__
6 | local.settings.json
7 | test
8 | .venv
--------------------------------------------------------------------------------
/samples/textcompletion/python/function_app.py:
--------------------------------------------------------------------------------
1 | import json
2 | import azure.functions as func
3 |
4 | app = func.FunctionApp(http_auth_level=func.AuthLevel.FUNCTION)
5 |
6 |
7 | @app.route(route="whois/{name}", methods=["GET"])
8 | @app.text_completion_input(
9 | arg_name="response",
10 | prompt="Who is {name}?",
11 | max_tokens="100",
12 | chat_model="%CHAT_MODEL_DEPLOYMENT_NAME%",
13 | )
14 | def whois(req: func.HttpRequest, response: str) -> func.HttpResponse:
15 | response_json = json.loads(response)
16 | return func.HttpResponse(response_json["content"], status_code=200)
17 |
18 |
19 | @app.route(route="genericcompletion", methods=["POST"])
20 | @app.text_completion_input(
21 | arg_name="response",
22 | prompt="{Prompt}",
23 | chat_model="%CHAT_MODEL_DEPLOYMENT_NAME%",
24 | )
25 | def genericcompletion(
26 | req: func.HttpRequest,
27 | response: str
28 | ) -> func.HttpResponse:
29 | response_json = json.loads(response)
30 | return func.HttpResponse(response_json["content"], status_code=200)
31 |
--------------------------------------------------------------------------------
/samples/textcompletion/python/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | },
8 | "extensionBundle": {
9 | "id": "Microsoft.Azure.Functions.ExtensionBundle.Preview",
10 | "version": "[4.*, 5.0.0)"
11 | }
12 | }
--------------------------------------------------------------------------------
/samples/textcompletion/python/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "AzureWebJobsFeatureFlags": "EnableWorkerIndexing",
6 | "FUNCTIONS_WORKER_RUNTIME": "python",
7 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
8 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo",
9 | "PYTHON_ISOLATE_WORKER_DEPENDENCIES": "1"
10 | }
11 | }
--------------------------------------------------------------------------------
/samples/textcompletion/python/requirements.txt:
--------------------------------------------------------------------------------
1 | # DO NOT include azure-functions-worker in this file
2 | # The Python Worker is managed by Azure Functions platform
3 | # Manually managing azure-functions-worker may cause unexpected issues
4 |
5 | azure-functions>=1.24.0b1
--------------------------------------------------------------------------------
/samples/textcompletion/typescript/.funcignore:
--------------------------------------------------------------------------------
1 | *.js.map
2 | *.ts
3 | .git*
4 | .vscode
5 | __azurite_db*__.json
6 | __blobstorage__
7 | __queuestorage__
8 | local.settings.json
9 | test
10 | tsconfig.json
--------------------------------------------------------------------------------
/samples/textcompletion/typescript/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "logLevel": {
5 | "Microsoft.Azure.WebJobs.Extensions.OpenAI": "Information"
6 | }
7 | },
8 | "extensionBundle": {
9 | "id": "Microsoft.Azure.Functions.ExtensionBundle.Preview",
10 | "version": "[4.*, 5.0.0)"
11 | }
12 | }
--------------------------------------------------------------------------------
/samples/textcompletion/typescript/local.settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "AzureWebJobsFeatureFlags": "EnableWorkerIndexing",
6 | "FUNCTIONS_WORKER_RUNTIME": "node",
7 | "AZURE_OPENAI_ENDPOINT": "Placeholder for the Azure OpenAI endpoint value",
8 | "CHAT_MODEL_DEPLOYMENT_NAME": "gpt-3.5-turbo"
9 | }
10 | }
--------------------------------------------------------------------------------
/samples/textcompletion/typescript/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript",
3 | "version": "1.0.0",
4 | "description": "",
5 | "scripts": {
6 | "build": "tsc",
7 | "watch": "tsc -w",
8 | "prestart": "npm run build",
9 | "start": "func start",
10 | "test": "echo \"No tests yet...\""
11 | },
12 | "dependencies": {
13 | "@azure/functions": "^4.0.0"
14 | },
15 | "devDependencies": {
16 | "@types/node": "^18.x",
17 | "typescript": "^4.0.0",
18 | "rimraf": "^5.0.0"
19 | },
20 | "main": "dist/src/functions/*.js"
21 | }
--------------------------------------------------------------------------------
/samples/textcompletion/typescript/src/functions/whois.ts:
--------------------------------------------------------------------------------
1 | import { app, input } from "@azure/functions";
2 |
3 | // This OpenAI completion input requires a {name} binding value.
4 | const openAICompletionInput = input.generic({
5 | prompt: 'Who is {name}?',
6 | maxTokens: '100',
7 | type: 'textCompletion',
8 | chatModel: '%CHAT_MODEL_DEPLOYMENT_NAME%'
9 | })
10 |
11 | app.http('whois', {
12 | methods: ['GET'],
13 | route: 'whois/{name}',
14 | authLevel: 'function',
15 | extraInputs: [openAICompletionInput],
16 | handler: async (_request, context) => {
17 | var response: any = context.extraInputs.get(openAICompletionInput)
18 | return { body: response.content.trim() }
19 | }
20 | });
21 |
--------------------------------------------------------------------------------
/samples/textcompletion/typescript/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es6",
5 | "outDir": "dist",
6 | "rootDir": ".",
7 | "sourceMap": true,
8 | "strict": false
9 | }
10 | }
--------------------------------------------------------------------------------
/src/Directory.Build.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 | Microsoft.Azure.$(AssemblyName)
4 |
5 |
--------------------------------------------------------------------------------
/src/Functions.Worker.Extensions.OpenAI.AzureAISearch/Functions.Worker.Extensions.OpenAI.AzureAISearch.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.1
5 | Microsoft Azure Functions .NET Isolated Worker Extension for OpenAI Azure AI Search
6 | $(AzureAISearchVersion)
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | <_Parameter1>Microsoft.Azure.WebJobs.Extensions.OpenAI.AzureAISearch
16 | <_Parameter2>$(AzureAISearchVersion)
17 | <_Parameter3>true
18 | <_Parameter3_IsLiteral>true
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/src/Functions.Worker.Extensions.OpenAI.CosmosDBNoSqlSearch/Functions.Worker.Extensions.OpenAI.CosmosDBNoSqlSearch.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.1
5 | Microsoft Azure Functions .NET Isolated Worker Extension for CosmosDB Search
6 | $(CosmosDBNoSqlSearchVersion)
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | <_Parameter1>Microsoft.Azure.WebJobs.Extensions.OpenAI.CosmosDBNoSqlSearch
16 | <_Parameter2>$(CosmosDBNoSqlSearchVersion)
17 | <_Parameter3>true
18 | <_Parameter3_IsLiteral>true
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/src/Functions.Worker.Extensions.OpenAI.CosmosDBSearch/Functions.Worker.Extensions.OpenAI.CosmosDBSearch.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.1
5 | Microsoft Azure Functions .NET Isolated Worker Extension for CosmosDB Search
6 | $(CosmosDBSearchVersion)
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | <_Parameter1>Microsoft.Azure.WebJobs.Extensions.OpenAI.CosmosDBSearch
16 | <_Parameter2>$(CosmosDBSearchVersion)
17 | <_Parameter3>true
18 | <_Parameter3_IsLiteral>true
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/src/Functions.Worker.Extensions.OpenAI.Kusto/Functions.Worker.Extensions.OpenAI.Kusto.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.1
5 | Microsoft Azure Functions .NET Isolated Worker Extension for OpenAI Kusto
6 | $(KustoVersion)
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | <_Parameter1>Microsoft.Azure.WebJobs.Extensions.OpenAI.Kusto
16 | <_Parameter2>$(KustoVersion)
17 | <_Parameter3>true
18 | <_Parameter3_IsLiteral>true
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/src/Functions.Worker.Extensions.OpenAI/Assistants/AssistantCreateOutputAttribute.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Azure.Functions.Worker.Extensions.Abstractions;
5 |
6 | namespace Microsoft.Azure.Functions.Worker.Extensions.OpenAI.Assistants;
7 |
8 | ///
9 | /// Assistant create output binding attribute which is used to create a assistant.
10 | ///
11 | public sealed class AssistantCreateOutputAttribute : OutputBindingAttribute
12 | {
13 | }
14 |
--------------------------------------------------------------------------------
/src/Functions.Worker.Extensions.OpenAI/Assistants/ChatCompletionJsonConverter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using System.ClientModel.Primitives;
5 | using System.Text.Json;
6 | using System.Text.Json.Serialization;
7 | using OpenAI.Chat;
8 |
9 | namespace Microsoft.Azure.Functions.Worker.Extensions.OpenAI.Assistants;
10 | public class ChatCompletionJsonConverter : JsonConverter
11 | {
12 | static readonly ModelReaderWriterOptions modelReaderWriterOptions = new("J");
13 | public override ChatCompletion Read(
14 | ref Utf8JsonReader reader,
15 | Type typeToConvert,
16 | JsonSerializerOptions options)
17 | {
18 | using JsonDocument jsonDocument = JsonDocument.ParseValue(ref reader);
19 | return ModelReaderWriter.Read(
20 | BinaryData.FromString(jsonDocument.RootElement.GetRawText()))!;
21 | }
22 |
23 | public override void Write(Utf8JsonWriter writer, ChatCompletion value, JsonSerializerOptions options)
24 | {
25 | ((IJsonModel)value).Write(writer, modelReaderWriterOptions);
26 | }
27 | }
--------------------------------------------------------------------------------
/src/Functions.Worker.Extensions.OpenAI/Embeddings/EmbeddingsContext.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using OpenAI.Embeddings;
5 |
6 | namespace Microsoft.Azure.Functions.Worker.Extensions.OpenAI.Embeddings;
7 |
8 | public class EmbeddingsContext
9 | {
10 | public EmbeddingsContext(IList Request, OpenAIEmbeddingCollection? Response)
11 | {
12 | this.Request = Request;
13 | this.Response = Response;
14 | }
15 |
16 | ///
17 | /// Embeddings request sent to OpenAI.
18 | ///
19 | public IList Request { get; set; }
20 |
21 | ///
22 | /// Embeddings response from OpenAI.
23 | ///
24 | public OpenAIEmbeddingCollection? Response { get; set; }
25 |
26 | ///
27 | /// Gets the number of embeddings that were returned in the response.
28 | ///
29 | public int Count => this.Response?.Count ?? 0;
30 | }
31 |
--------------------------------------------------------------------------------
/src/Functions.Worker.Extensions.OpenAI/Embeddings/InputType.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Azure.Functions.Worker.Extensions.OpenAI.Embeddings;
5 |
6 | ///
7 | /// Options for interpreting input binding data.
8 | ///
9 | public enum InputType
10 | {
11 | ///
12 | /// The input data is raw text.
13 | ///
14 | RawText,
15 |
16 | ///
17 | /// The input data is a file path that contains the text.
18 | ///
19 | FilePath,
20 |
21 | ///
22 | /// The input data is a Url.
23 | ///
24 | Url
25 | }
26 |
--------------------------------------------------------------------------------
/src/Functions.Worker.Extensions.OpenAI/Functions.Worker.Extensions.OpenAI.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.1
5 | Microsoft Azure Functions .NET Isolated Worker Extension for OpenAI
6 | $(VersionPrefix)-$(VersionSuffix)
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | <_Parameter1>Microsoft.Azure.WebJobs.Extensions.OpenAI
18 | <_Parameter2>$(WebJobsVersion)
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/src/Functions.Worker.Extensions.OpenAI/OpenAIModels.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Azure.Functions.Worker.Extensions.OpenAI;
5 |
6 | static class OpenAIModels
7 | {
8 | // Reference - https://platform.openai.com/docs/models
9 |
10 | ///
11 | /// GPT 3 Turbo, refer to https://platform.openai.com/docs/models/continuous-model-upgrades for exact model being pointed to
12 | ///
13 | internal const string DefaultChatModel = "gpt-3.5-turbo";
14 |
15 | ///
16 | /// The default embeddings model, currently pointing to text-embedding-ada-002
17 | ///
18 | ///
19 | /// Changing the default embeddings model is a breaking change, since any changes will be stored in a vector database for lookup. Changing the default model can cause the lookups to start misbehaving if they don't match the data that was previously ingested into the vector database.
20 | ///
21 | internal const string DefaultEmbeddingsModel = "text-embedding-ada-002";
22 | }
23 |
--------------------------------------------------------------------------------
/src/WebJobs.Extensions.OpenAI.AzureAISearch/AzureAISearchConfigOptions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Azure.WebJobs.Extensions.OpenAI.AzureAISearch;
5 |
6 | ///
7 | /// Open AI Configuration Options used for reading host.json values.
8 | ///
9 | public class AzureAISearchConfigOptions
10 | {
11 | public bool IsSemanticSearchEnabled { get; set; }
12 |
13 | public bool UseSemanticCaptions { get; set; }
14 |
15 | public int VectorSearchDimensions { get; set; } = 1536;
16 |
17 | public string? SearchAPIKeySetting { get; set; }
18 | }
19 |
--------------------------------------------------------------------------------
/src/WebJobs.Extensions.OpenAI.AzureAISearch/OpenAIAzureAISearch.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Azure.Functions.Extensions.DependencyInjection;
5 | using Microsoft.Azure.WebJobs.Extensions.OpenAI.AzureAISearch;
6 | using Microsoft.Azure.WebJobs.Extensions.OpenAI.Search;
7 | using Microsoft.Extensions.Configuration;
8 | using Microsoft.Extensions.DependencyInjection;
9 |
10 | // Reference: https://docs.microsoft.com/en-us/azure/azure-functions/functions-dotnet-dependency-injection
11 | [assembly: FunctionsStartup(typeof(OpenAIAzureAISearch))]
12 |
13 | namespace Microsoft.Azure.WebJobs.Extensions.OpenAI.AzureAISearch;
14 |
15 | class OpenAIAzureAISearch : FunctionsStartup
16 | {
17 | public override void Configure(IFunctionsHostBuilder builder)
18 | {
19 | builder.Services.AddOptions()
20 | .Configure((options, config) =>
21 | {
22 | config.GetSection("azurefunctionsjobhost:extensions:openai:searchprovider").Bind(options);
23 | });
24 | builder.Services.AddSingleton();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/WebJobs.Extensions.OpenAI.AzureAISearch/WebJobs.Extensions.OpenAI.AzureAISearch.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | Microsoft Azure WebJobs SDK Extension for OpenAI - Azure AI Search Package.
4 | $(AzureAISearchVersion)
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/WebJobs.Extensions.OpenAI.CosmosDBNoSqlSearch/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | All notable changes to this project will be documented in this file.
4 |
5 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7 |
8 | ## v0.1.0 - 2025/05/08
9 |
10 | ### Added
11 |
12 | - Added support for CosmosDB (NoSql) Search Provider. Refer [README](../../samples/rag-cosmosdb-nosql/README.md) for more information on usage.
13 |
--------------------------------------------------------------------------------
/src/WebJobs.Extensions.OpenAI.CosmosDBNoSqlSearch/WebJobs.Extensions.OpenAI.CosmosDBNoSqlSearch.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | Microsoft Azure WebJobs SDK Extension for OpenAI - Cosmos DB Search for NoSql Package.
4 | $(CosmosDBNoSqlSearchVersion)
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/WebJobs.Extensions.OpenAI.CosmosDBSearch/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | All notable changes to this project will be documented in this file.
4 |
5 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7 |
8 | ## v0.4.0 - 2025/05/05
9 |
10 | ### Added
11 |
12 | - Added DiskANN support for CosmosDB (MongoDB) Search Provider. Refer [README](../../samples/rag-cosmosdb/README.md) for more information on usage.
13 |
14 | ### Changed
15 |
16 | - Updated Microsoft.Azure.WebJobs.Extensions.OpenAI to 0.19.0
17 |
18 | ## v0.3.0 - 2024/10/08
19 |
20 | ### Added
21 |
22 | - Added HNSW support for CosmosDB (MongoDB) Search Provider. Refer [README](../../samples/rag-cosmosdb/README.md) for more information on usage.
23 |
24 | ### Changed
25 |
26 | - Updated nuget dependencies
27 |
28 | ## v0.2.0 - 2024/05/06
29 |
30 | - Updated Microsoft.Azure.WebJobs.Extensions.OpenAI to 0.15.0
31 |
32 | ## v0.1.0 - 2024/04/24
33 |
34 | ### Added
35 |
36 | - Added support for CosmosDB (MongoDB) Search Provider. Refer [README](../../samples/rag-cosmosdb/README.md) for more information on usage.
37 |
--------------------------------------------------------------------------------
/src/WebJobs.Extensions.OpenAI.CosmosDBSearch/WebJobs.Extensions.OpenAI.CosmosDBSearch.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | Microsoft Azure WebJobs SDK Extension for OpenAI - Cosmos DB Search for MongoDB Package.
4 | $(CosmosDBSearchVersion)
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/WebJobs.Extensions.OpenAI.Kusto/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | All notable changes to this project will be documented in this file.
4 |
5 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7 |
8 | ## v0.17.0 - 2025/05/08
9 |
10 | - Updated Microsoft.Azure.WebJobs.Extensions.OpenAI to 0.19.0
11 |
12 | ## v0.16.0 - 2024/10/08
13 |
14 | ### Changed
15 |
16 | - Updated nuget dependencies
17 |
18 | ## v0.15.0 - 2024/05/06
19 |
20 | ### Changed
21 |
22 | - Updated Microsoft.Azure.WebJobs.Extensions.OpenAI to 0.15.0
23 |
24 | ## v0.14.0 - 2024/04/24
25 |
26 | ### Changed
27 |
28 | - Updated Microsoft.Azure.WebJobs.Extensions.OpenAI to 0.14.0
29 |
30 | ## v0.13.0 - 2024/04/05
31 |
32 | ### Added and Breaking Change
33 |
34 | - Added support for multiple search providers and named Kusto search provider type to `Kusto`. Refer [README](../../samples/rag/README.md) for usage information
35 |
36 | ## For previous versions
37 |
38 | Refer root Changelog.
39 |
--------------------------------------------------------------------------------
/src/WebJobs.Extensions.OpenAI.Kusto/OpenAIKusto.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Azure.Functions.Extensions.DependencyInjection;
5 | using Microsoft.Azure.WebJobs.Extensions.OpenAI.Kusto;
6 | using Microsoft.Azure.WebJobs.Extensions.OpenAI.Search;
7 | using Microsoft.Extensions.DependencyInjection;
8 |
9 | // Reference: https://docs.microsoft.com/en-us/azure/azure-functions/functions-dotnet-dependency-injection
10 | [assembly: FunctionsStartup(typeof(OpenAIKusto))]
11 |
12 | namespace Microsoft.Azure.WebJobs.Extensions.OpenAI.Kusto;
13 |
14 | class OpenAIKusto : FunctionsStartup
15 | {
16 | public override void Configure(IFunctionsHostBuilder builder)
17 | {
18 | builder.Services.AddSingleton();
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/WebJobs.Extensions.OpenAI.Kusto/WebJobs.Extensions.OpenAI.Kusto.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Microsoft Azure WebJobs SDK Extension for OpenAI - Kusto Search Package.
5 | $(KustoVersion)
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/WebJobs.Extensions.OpenAI/Assistants/AssistantRuntimeState.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Azure.WebJobs.Extensions.OpenAI.Models;
5 | using Newtonsoft.Json;
6 |
7 | namespace Microsoft.Azure.WebJobs.Extensions.OpenAI.Assistants;
8 |
9 | record struct MessageRecord(DateTime Timestamp, AssistantMessage ChatMessageEntity);
10 |
11 | [JsonObject(MemberSerialization.OptIn)]
12 | class AssistantRuntimeState
13 | {
14 | [JsonProperty("messages")]
15 | public List? ChatMessages { get; set; }
16 |
17 | [JsonProperty("totalTokens")]
18 | public int TotalTokens { get; set; } = 0;
19 | }
--------------------------------------------------------------------------------
/src/WebJobs.Extensions.OpenAI/Assistants/ChatCompletionsJsonConverter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using System.ClientModel.Primitives;
5 | using System.Text.Json;
6 | using System.Text.Json.Serialization;
7 | using OpenAI.Chat;
8 |
9 | namespace Microsoft.Azure.WebJobs.Extensions.OpenAI.Assistants;
10 | class ChatCompletionsJsonConverter : JsonConverter
11 | {
12 | static readonly ModelReaderWriterOptions modelReaderWriterOptions = new("J");
13 | public override ChatCompletion Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
14 | {
15 | throw new NotImplementedException();
16 | }
17 |
18 | public override void Write(Utf8JsonWriter writer, ChatCompletion value, JsonSerializerOptions options)
19 | {
20 | ((IJsonModel)value).Write(writer, modelReaderWriterOptions);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/WebJobs.Extensions.OpenAI/Embeddings/EmbeddingsOptionsJsonConverter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using System.ClientModel.Primitives;
5 | using System.Text.Json;
6 | using System.Text.Json.Serialization;
7 | using OpenAI.Embeddings;
8 |
9 | namespace Microsoft.Azure.WebJobs.Extensions.OpenAI.Embeddings;
10 | class EmbeddingsOptionsJsonConverter : JsonConverter
11 | {
12 | static readonly ModelReaderWriterOptions modelReaderWriterOptions = new("J");
13 | public override EmbeddingGenerationOptions Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
14 | {
15 | throw new NotImplementedException();
16 | }
17 |
18 | public override void Write(Utf8JsonWriter writer, EmbeddingGenerationOptions value, JsonSerializerOptions options)
19 | {
20 | ((IJsonModel)value).Write(writer, modelReaderWriterOptions);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/WebJobs.Extensions.OpenAI/Embeddings/InputType.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Azure.WebJobs.Extensions.OpenAI.Embeddings;
5 |
6 | ///
7 | /// Options for interpreting input binding data.
8 | ///
9 | public enum InputType
10 | {
11 | ///
12 | /// The input data is raw text.
13 | ///
14 | RawText,
15 |
16 | ///
17 | /// The input data is a file path that contains the text.
18 | ///
19 | FilePath,
20 |
21 | ///
22 | /// The input data is a Url.
23 | ///
24 | Url
25 | }
26 |
--------------------------------------------------------------------------------
/src/WebJobs.Extensions.OpenAI/Models/OpenAIModels.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Azure.WebJobs.Extensions.OpenAI.Models;
5 |
6 | static class OpenAIModels
7 | {
8 | // Reference - https://platform.openai.com/docs/models
9 |
10 | ///
11 | /// GPT 3 Turbo, refer to https://platform.openai.com/docs/models/continuous-model-upgrades for exact model being pointed to
12 | ///
13 | internal const string DefaultChatModel = "gpt-3.5-turbo";
14 |
15 | ///
16 | /// The default embeddings model, currently pointing to text-embedding-ada-002
17 | ///
18 | ///
19 | /// Changing the default embeddings model is a breaking change, since any changes will be stored in a vector database for lookup. Changing the default model can cause the lookups to start misbehaving if they don't match the data that was previously ingested into the vector database.
20 | ///
21 | internal const string DefaultEmbeddingsModel = "text-embedding-ada-002";
22 | }
23 |
--------------------------------------------------------------------------------
/src/WebJobs.Extensions.OpenAI/Models/TextCompletionResponse.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using Newtonsoft.Json;
5 |
6 | namespace Microsoft.Azure.WebJobs.Extensions.OpenAI.Models;
7 |
8 | ///
9 | /// Text Completion Response Class
10 | ///
11 | [JsonObject(MemberSerialization.OptIn)]
12 | public class TextCompletionResponse
13 | {
14 | ///
15 | /// Initiliazes a new instance of the class.
16 | ///
17 | /// The text completion message content.
18 | /// The total token usage.
19 | public TextCompletionResponse(string content, int totalTokens)
20 | {
21 | this.Content = content;
22 | this.TotalTokens = totalTokens;
23 | }
24 |
25 | ///
26 | /// The text completion message content.
27 | ///
28 | [JsonProperty("content")]
29 | public string Content { get; set; }
30 |
31 | ///
32 | /// The total token usage.
33 | ///
34 | [JsonProperty("totalTokens")]
35 | public int TotalTokens { get; set; }
36 | }
--------------------------------------------------------------------------------
/src/WebJobs.Extensions.OpenAI/OpenAIConfigOptions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | namespace Microsoft.Azure.WebJobs.Extensions.OpenAI;
5 |
6 | ///
7 | /// Open AI Configuration Options used for reading host.json values.
8 | ///
9 | public class OpenAIConfigOptions
10 | {
11 | ///
12 | /// The section of configuration related to search providers for semantic search.
13 | ///
14 | public IDictionary SearchProvider { get; set; } = new Dictionary();
15 | }
16 |
--------------------------------------------------------------------------------
/src/WebJobs.Extensions.OpenAI/OpenAIServiceAttribute.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Azure.WebJobs.Description;
5 |
6 | namespace Microsoft.Azure.WebJobs.Extensions.OpenAI;
7 |
8 | ///
9 | /// Input binding attribute for getting an instance of the class.
10 | ///
11 | ///
12 | /// WARNING: This may be removed in a future version.
13 | ///
14 | [Binding]
15 | [AttributeUsage(AttributeTargets.Parameter)]
16 | public sealed class OpenAIServiceAttribute : Attribute
17 | {
18 | }
19 |
--------------------------------------------------------------------------------
/src/WebJobs.Extensions.OpenAI/OpenAIWebJobsStartup.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.Azure.WebJobs.Extensions.OpenAI;
5 | using Microsoft.Azure.WebJobs.Hosting;
6 |
7 | // This auto-registers the OpenAI extension when a webjobs/functions host starts up.
8 | [assembly: WebJobsStartup(typeof(OpenAIWebJobsStartup))]
9 |
10 | namespace Microsoft.Azure.WebJobs.Extensions.OpenAI;
11 |
12 | class OpenAIWebJobsStartup : IWebJobsStartup2
13 | {
14 | public void Configure(WebJobsBuilderContext context, IWebJobsBuilder builder)
15 | {
16 | this.Configure(builder);
17 | }
18 |
19 | public void Configure(IWebJobsBuilder builder)
20 | {
21 | builder.AddOpenAIBindings();
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/WebJobs.Extensions.OpenAI/WebJobs.Extensions.OpenAI.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Microsoft Azure WebJobs SDK Extension for OpenAI
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/tests/SampleValidation/SampleValidation.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | enable
6 | enable
7 |
8 | false
9 |
10 |
11 |
12 |
13 |
14 |
15 | runtime; build; native; contentfiles; analyzers; buildtransitive
16 | all
17 |
18 |
19 | runtime; build; native; contentfiles; analyzers; buildtransitive
20 | all
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------