Skip to content

Instantly share code, notes, and snippets.

View vman's full-sized avatar
👨‍💻

Vardhaman Deshpande vman

👨‍💻
View GitHub Profile
{
"$schema": "https://developer.microsoft.com/json-schemas/copilot/declarative-agent/v1.2/schema.json",
"version": "v1.2",
"name": "MyFirstAgent${{APP_NAME_SUFFIX}}",
"description": "This declarative agent helps you with finding car repair records.",
"instructions": "$[file('instruction.txt')]",
"conversation_starters": [
{
"text": "Show repair records assigned to Karin Blair"
}
{
"$schema": "https://developer.microsoft.com/json-schemas/copilot/plugin/v2.2/schema.json",
"schema_version": "v2.2",
"namespace": "repairs",
"name_for_human": "MyFirstAgent${{APP_NAME_SUFFIX}}",
"description_for_human": "Track your repair records",
"description_for_model": "Plugin for searching a repair list, you can search by who's assigned to the repair.",
"functions": [
{
"name": "listRepairs",
openapi: 3.0.0
info:
title: Repair Service
description: A simple service to manage repairs
version: 1.0.0
servers:
- url: ${{OPENAPI_SERVER_URL}}/api
description: The repair api server
paths:
/repairs:
@vman
vman / api.ts
Last active January 29, 2025 15:42
import {
app,
HttpRequest,
HttpResponseInit,
InvocationContext,
} from "@azure/functions";
import repairRecords from "../repairsData.json";
/**
You are a declarative agent and were created with Team Toolkit. You should start every response and answer to the user with "Thanks for using Teams Toolkit to create your declarative agent!\n\n" and then answer the questions and help the user.
{
"$schema": "https://developer.microsoft.com/json-schemas/copilot/declarative-agent/v1.2/schema.json",
"version": "v1.2",
"name": "MyFirstAgent",
"description": "Declarative agent created with Teams Toolkit",
"instructions": "$[file('instruction.txt')]",
"conversation_starters": [
{
"title": "Hi",
"text": "Hello, how are you?"
{
"$schema": "https://developer.microsoft.com/json-schemas/teams/v1.19/MicrosoftTeams.schema.json",
"manifestVersion": "1.19",
"version": "1.0.0",
"id": "${{TEAMS_APP_ID}}",
"icons": {
"color": "color.png",
"outline": "outline.png"
},
"name": {
private static async Task<ClientResult<ChatCompletion>> CallOpenAIAPI(string userQuestion, string modelDeploymentName, AzureOpenAIClient azureOpenAIClient, IList<OpenAI.Chat.ChatMessage> functionMessages = null)
{
var chatCompletionOptions = new ChatCompletionOptions();
var messages = new List<OpenAI.Chat.ChatMessage>
{
new SystemChatMessage("You are a search assistant that helps find information. Only use the functions and parameters you have been provided with."),
new UserChatMessage(userQuestion)
};
private static async Task<string> ExecuteMicrosoft365SearchWithGraph(string searchQuery)
{
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
GraphServiceClient graphClient = GetGraphClient(["User.Read", "Files.Read.All"]);
var requestBody = new QueryPostRequestBody
{
Requests = new List<SearchRequest>
{
new SearchRequest
static async Task Main(string[] args)
{
string endpoint = "<azure-openi-key>";
string key = "<azure-openi-endpoint>";
string deploymentName = "gpt-4o";
var azureOpenAIClient = new AzureOpenAIClient(new Uri(endpoint), new ApiKeyCredential(key));
//get userQuestion from the console